0
使用hammer.js(v 2.0)我試圖觸發pandown手勢的事件,但是當我應用手勢事件的元素比瀏覽器具有更多內容時佈局高度,默認滾動停止時,看到這個codepen http://codepen.io/shmdhussain/pen/GomRVw#0垂直滾動不適用於iOS設備Hammer.js
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)
看到這個問題我發佈在hammerjs github頁面https://github.com/hammerjs/hammer.js/issues/902#event-510200753 –
任何人都有這個解決方案嗎? – cgatian