对的OpenLayers拖动光标改变3(Changing cursor on drag in ope

2019-10-22 22:44发布

是什么改变光标当用户拖动地图的正确方法。 下面的例子并不好当pointerdrag开始拖动,然后没有任何事件为125ms后改回只触发。 有没有其他办法?

    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); 
    });

Answer 1:

怎么样听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/



文章来源: Changing cursor on drag in openlayers 3