Bläddra i källkod

improve simulate

Adam Shaw 7 år sedan
förälder
incheckning
a1d19c8615
1 ändrade filer med 13 tillägg och 2 borttagningar
  1. 13 2
      tests/automated/lib/simulate.js

+ 13 - 2
tests/automated/lib/simulate.js

@@ -247,7 +247,12 @@ function simulateDrag(self, targetNode, startPoint, dx, dy, moveCnt, duration, o
     moveIndex++
     updateCoords() // update clientCoords before mousemove
 
-    self.simulateEvent(docNode, isTouch ? 'touchmove' : 'mousemove', clientCoords)
+    if (isTouch) {
+      // touchmove happens on the originating element
+      self.simulateEvent(targetNode, 'touchmove', clientCoords)
+    } else {
+      self.simulateEvent(docNode, 'mousemove', clientCoords)
+    }
 
     if (moveIndex >= moveCnt) {
       stopMoving()
@@ -282,7 +287,13 @@ function simulateDrag(self, targetNode, startPoint, dx, dy, moveCnt, duration, o
     }
 
     dragStackCnt--;
-    (options.onRelease || options.callback || function() {})() // TODO: deprecate "callback" ?
+
+    // we wait because the there might be a FullCalendar drag interaction that finishes asynchronously
+    // after the mouseend/touchend happens, and it's really convenient if our callback fires after that.
+    setTimeout(
+      options.onRelease || options.callback || function() {}, // TODO: deprecate "callback" ?
+      0
+    )
   }
 
   startDrag()