javascript - How to distinguish whether hammer.js panend ends with panleft or panright?
扔个三星炸死你
扔个三星炸死你 2017-07-05 10:35:49
0
1
833

hammer.js panend How to distinguish whether it ends with panleft or panright?
Looking at the output parameters, I don’t seem to find it..

扔个三星炸死你
扔个三星炸死你

reply all(1)
给我你的怀抱

You can use e.originalEvent.gesture.deltaX to determine whether the end of is moving left or right compared to the beginning :

var deltaX = e.originalEvent.gesture.deltaX;
if (deltaX > 0) {
    // 右移
} else if (deltaX < 0) {
    // 左移
}
The

panleft and panright events are constantly triggered during the movement, and are judged to move left or right relative to the position last time was triggered. If you want to see whether
is moved left or right when ends compared to when begins
, then the above method is OK; If you want to see whether the panleft event or was triggered last panright event, then we can only monitor the panleft and panright events, but it seems impossible to monitor the panend

event. 🎜
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!