简体   繁体   English

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

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

I have a Google Map in my Sencha Touch app, and I draw many SVG elements on top of it.我的 Sencha Touch 应用中有一个谷歌地图,我在它上面绘制了许多 SVG 元素。

Now I'd like to add touch and hold (means it will be triggered when user touch and hold figure on a SVG element longer than 1.5 second) on each of SVG elements and when the even is triggered, I'd like pop up an information dialog associated with the clicked SVG element.现在我想在每个 SVG 元素上添加触摸和保持(意味着当用户在 SVG 元素上触摸并按住图形超过 1.5 秒时会触发它),当触发偶数时,我想弹出一个与单击的 SVG 元素关联的信息对话框。

I have tried: Ext.util.TaPrepeater(doesn't work)我试过: 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");
                    }
                }
            }
        });

And also tried adding events directly on the SVG (doesn't work either)并且还尝试直接在 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");
        }

    });

and found very limited relevant posts.并找到了非常有限的相关帖子。

touchstart and touchend events have arguments. touchstart 和 touchend 事件有参数。 One of them is touch details(arguments[0]).其中之一是触摸细节(参数[0])。 You can use something like this:你可以使用这样的东西:

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

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

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