kornelski / slip

Slip.js — UI library for manipulating lists via swipe and drag gestures
BSD 2-Clause "Simplified" License
2.44k stars 213 forks source link

'reorder' is raised on click without delay #104

Open Samlibardi opened 6 years ago

Samlibardi commented 6 years ago

Problem: Clicking an element in a Slip list without delay triggers a 'reorder' event. This happens because there is no detection whether the element actually gets dragged around or if it's released in the same place it was before. This causes some implications:

What should happen: clicking raises a click, reorder should only be raised when the element is actually dragged around.

To solve: Some dragging checks before putting Slip into reorder state. My workaround is the following code in the 'undecided' state:

var delayed = true;
if (!this.dispatch(this.target.originalTarget, 'beforewait', {'isTouch': isTouch})) {
  if (this.dispatch(this.target.originalTarget, 'beforereorder')) {
    delayed = false;
    //this.setState(this.states.reorder);
}

...

onMove: function() {
  var move = this.getAbsoluteMovement();
  if (!delayed && move.y > 5) {
    this.setState(this.states.reorder);
  }

I've seen some bugs in this workaround though.