繁体   English   中英

如何在 Sencha Touch 中的 Google 地图上的 svg 上添加触摸和保持事件

[英]How to add touch and hold event on svg on Google Map in Sencha Touch

我的 Sencha Touch 应用中有一个谷歌地图,我在它上面绘制了许多 SVG 元素。

现在我想在每个 SVG 元素上添加触摸和保持(意味着当用户在 SVG 元素上触摸并按住图形超过 1.5 秒时会触发它),当触发偶数时,我想弹出一个与单击的 SVG 元素关联的信息对话框。

我试过: Ext.util.TaPrepeater(不起作用)

  var startTime
      Ext.create('Ext.util.TapRepeater', {
            el: drawnElements[uniqueTrackID],
            listeners: {
                touchstart: function () {
                    startTime = new Date();
                },
                touchend: function () {
                    var now = new Date();
                    if (now - startTime >= 1500)
                    {
                        Ext.Msg.alert("haha");
                    }
                }
            }
        });

并且还尝试直接在 SVG 上添加事件(也不起作用)

  drawnElements[uniqueTrackID].on('touchstart', function () {
        startTime = new Date();
    });

    drawnElements[uniqueTrackID].on('touchend', function () {
        var rightNow = new Date();
        if (rightNow - startTime >= 1500) {
            Ext.Msg.alert("haha");
        }

    });

并找到了非常有限的相关帖子。

touchstart 和 touchend 事件有参数。 其中之一是触摸细节(参数[0])。 你可以使用这样的东西:

touchstart: function (details) {
                    userTime = details.touch.timeStamp;
                }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM