在openlayers 3的拖动上更改光标 [英] Changing cursor on drag in openlayers 3

查看:259
本文介绍了在openlayers 3的拖动上更改光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户拖动地图时更改光标的正确方法是什么?下面的示例并不是很好,因为它仅在pointerdrag启动拖动时触发,然后在无事件持续125ms之后将其更改回.还有其他办法吗?

What are the proper way of changing the cursor when user is dragging the map. Below example is not that good as it only triggers when pointerdrag starts the drag and then change it back after no events for 125ms. Is there any other way?

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

推荐答案

如何收听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/

这篇关于在openlayers 3的拖动上更改光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆