Commit 7124e510 authored by Phil Hughes's avatar Phil Hughes

Updated simulateDrag JS

parent 17c576c1
...@@ -85,14 +85,10 @@ ...@@ -85,14 +85,10 @@
simulateEvent(fromEl, 'mousedown', {button: 0}); simulateEvent(fromEl, 'mousedown', {button: 0});
options.ontap && options.ontap(); options.ontap && options.ontap();
requestAnimationFrame(function () { var dragInterval = setInterval(function loop() {
options.ondragstart && options.ondragstart();
});
requestAnimationFrame(function loop() {
var progress = (new Date().getTime() - startTime) / duration; var progress = (new Date().getTime() - startTime) / duration;
var x = (fromRect.cx + (toRect.cx - fromRect.cx) * progress) - scrollable.scrollLeft; var x = (fromRect.cx + (toRect.cx - fromRect.cx) * progress) - scrollable.scrollLeft;
var y = fromRect.cy + (toRect.cy - fromRect.cy) * progress; var y = (fromRect.cy + (toRect.cy - fromRect.cy) * progress) - scrollable.scrollTop;
var overEl = fromEl.ownerDocument.elementFromPoint(x, y); var overEl = fromEl.ownerDocument.elementFromPoint(x, y);
simulateEvent(overEl, 'mousemove', { simulateEvent(overEl, 'mousemove', {
...@@ -100,13 +96,12 @@ ...@@ -100,13 +96,12 @@
clientY: y clientY: y
}); });
if (progress < 1) { if (progress >= 1) {
requestAnimationFrame(loop);
} else {
options.ondragend && options.ondragend(); options.ondragend && options.ondragend();
simulateEvent(toEl, 'mouseup'); simulateEvent(toEl, 'mouseup');
clearInterval(dragInterval);
} }
}); }, 100);
return { return {
target: fromEl, target: fromEl,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment