2015-05-03 62 views
0

当用户拖动地图时,更改光标的正确方法是什么?下面的例子并不是那么好,因为它只有在指针拖动开始拖动时触发,然后在没有事件125毫秒后将其改回。有没有其他方法?在透明层拖动时更改光标3

var timer = null; 
    this.map().on("pointerdrag",() => { 
     this.map().getViewport().style.cursor = "-webkit-grabbing"; 
     clearTimeout(timer); 
     timer = setTimeout(() => this.map().getViewport().style.cursor = "-webkit-grab", 125); 
    }); 

回答

2

怎么样收听pointerup重置光标?

map.getViewport().style.cursor = "-webkit-grab"; 
map.on('pointerdrag', function(evt) { 
    map.getViewport().style.cursor = "-webkit-grabbing"; 
}); 

map.on('pointerup', function(evt) { 
    map.getViewport().style.cursor = "-webkit-grab"; 
}); 

http://jsfiddle.net/9vwgdcyr/