Skip to content

Commit

Permalink
ELEMENTS-723: delay move handler on draggable list behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabez0r committed Jul 11, 2018
1 parent 8562dd5 commit 5d2b1b2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nuxeo-draggable-list-behavior.html
Expand Up @@ -58,7 +58,11 @@
const bodyEl = document.querySelector('body');
// mouse move handler
const moveFn = (e) => {
// block list pointer events while dragging and apply grabbing cursor
// ELEMENTS-723: prevent dragging from beginning too early, which can interfere with other mouse events
if (((new Date()).getTime() - this._mouseDownStarted) <= 150) {
return;
}
// block list pointer events while dragging and apply grabbing cursor
this.style.pointerEvents = 'none';
bodyEl.setAttribute('style', 'cursor: grabbing; cursor: -webkit-grabbing;');
// create proxy with number of items that are being dragged
Expand Down Expand Up @@ -95,7 +99,8 @@

// mouse up handler
const upFn = () => {
// restore list pointer events, restore cursor and remove proxy
// restore list pointer events, restore cursor and remove proxy
this._mouseDownStarted = null;
this.style.pointerEvents = '';
bodyEl.style.cursor = '';
if (proxy) {
Expand All @@ -120,6 +125,7 @@
// prevent default behavior to make sure cursors are applied across all browsers
e.preventDefault();
if (e.target && this.draggableFilter(e.target)) {
this._mouseDownStarted = this._mouseDownStarted || (new Date()).getTime();
// setup listeners when drag starts
document.addEventListener('mousemove', moveFn);
document.addEventListener('mouseup', upFn);
Expand Down

0 comments on commit 5d2b1b2

Please sign in to comment.