【问题标题】:How to add touch and hold event on svg on Google Map in Sencha Touch如何在 Sencha Touch 的 Google Map 上的 svg 上添加触摸和按住事件
【发布时间】:2014-06-09 03:38:10
【问题描述】:

我的 Sencha Touch 应用中有一个 Google 地图,我在上面绘制了许多 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");
        }

    });

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

【问题讨论】:

    标签: javascript extjs svg sencha-touch sencha-touch-2


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多