【问题标题】:Trying to enable swipe left尝试启用向左滑动
【发布时间】:2014-11-27 01:16:36
【问题描述】:

以下是我的代码:

<script type="text/javascript" src="js/hammer.min.js"> </script>

<script>

    Hammer($(document)).on("swipeleft", function() 
    { 
        alert("Swipe Left"); 
    });

</script>

而且我没有看到“向左滑动”警报。怎么了?

【问题讨论】:

  • 试试Hammer(document.body).on(...

标签: javascript jquery jquery-mobile swipe hammer.js


【解决方案1】:

据我所知,Document 过于笼统。您需要有一个正在滑动的对象:

例如,当您在 ID 为 box1 的 DIV 上向左滑动时,这会执行一个操作。

<div id="box1" style="width: 100%; height: 100%;">SOME TEST</div>

<script>
$(function(){  
  var objbox1 = document.getElementById("box1");

  //Swipe
  Hammer(objbox1).on("swipeleft", function() {
        alert('Swiped Left');
    });
});
</script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-25
    • 2013-02-17
    • 1970-01-01
    • 2015-07-10
    • 1970-01-01
    相关资源
    最近更新 更多