【发布时间】:2016-01-09 11:41:00
【问题描述】:
使用hammer.js(v 2.0)我尝试触发pandown手势事件,但是当我应用手势事件的元素的内容超过浏览器布局高度时,默认滚动停止,请参阅此codepen http://codepen.io/shmdhussain/pen/GomRVw#0
var myElement = document.getElementById('myElement');
var myElement1 = document.getElementById('myElement1');
// create a simple instance
// by default, it only adds horizontal recognizers
var mc = new Hammer(myElement);
// let the pan gesture support all directions.
// this will block the vertical scrolling on a touch-device while on the element
mc.get('pan').set({ direction: Hammer.DIRECTION_ALL });
// listen to events...
mc.on("panleft panright panup pandown tap press", function(ev) {
myElement1.textContent = ev.type +" gesture detected.";
});
#myElement {
background: silver;
height: 300px;
text-align: center;
font: 30px/300px Helvetica, Arial, sans-serif;
}
<script src="https://hammerjs.github.io/dist/hammer.js"></script>
<div id="myElement">
<p id="myElement1">hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
<p>hekko</p>
</div>
iOS 设备 iPhone 中发生的问题(在 iPhone 6Plus 和 iOS 8.4.1 上测试)
【问题讨论】:
标签: javascript hammer.js