Home  >  Q&A  >  body text

javascript - How to distinguish whether hammer.js panend ends with panleft or panright?

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..

扔个三星炸死你扔个三星炸死你2683 days ago896

reply all(1)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-07-05 10:37:49

    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. 🎜

    reply
    0
  • Cancelreply