我试图平滑我用JavaScript构建的地图应用程序的性能。我初步实现了用IE在拖动时平滑地图平移
- onmousedown事件
- 的OnMouseMove
- onmouseup
然而,在IE浏览器,感觉真的很呆滞,看来,当你真正将光标移动快速的地图没有按”一拖盘t更新它的位置,直到你停止移动。
我转换我的代码使用本地IE事件
- ondragstart使用这些事件时
- ondrag当
- ondragend
的表现要好得多,但似乎我能使用标准的CSS属性设置鼠标光标。我只能将游标设置为几个预定义的游标,这不是我想要的。
所以我的问题是。我如何使用第一组事件平滑IE中的拖动,或者如何使用本机事件设置自定义游标。
编辑:代码示例
的代码非常非常简单。即使我删除加载新瓷砖的逻辑(即只有容器正在移动),它仍然感到笨重。下面是平移功能:
// the "this" object refers to the div containing all the tile layers.
function movemap(e)
{
e = e || window.event;
var dx = this.mouseX - e.clientX;
var dy = this.mouseY - e.clientY;
if (dx !== 0 || dy !== 0) {
this.style.left = parseInt(this.style.left) + dx + 'px';
this.style.top = parseInt(this.style.top) + dy + 'px';
this.mouseX = e.clientX;
this.mouseY = e.clientY;
}
}
完全重复:http://stackoverflow.com/questions/2181482/ie-ondrag-event-setting-mouse-cursor-to-no-drop – jvenema 2010-02-02 06:05:30
我删除了我的旧问题,因为我认为这是一个更好地解释问题。 谢谢。 – Alex 2010-02-02 06:12:50