From 7bd21a9583c4d3f6bb2851ba8f841e855ba9d407 Mon Sep 17 00:00:00 2001 From: Elon Mallin Date: Sat, 18 Feb 2017 02:23:27 +0100 Subject: [PATCH] fix: make drag on touch work in scrollable element With Chrome version 56 the passive capture option in addEventListener defaults to true instead of false which causes dragging on touch devices to simultaneously also scroll. Tested on Android Chrome, and device mode in Edge, Chrome and Firefox. --- Sortable.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Sortable.js b/Sortable.js index ec154fe..2adfcc6 100644 --- a/Sortable.js +++ b/Sortable.js @@ -25,6 +25,16 @@ throw new Error("Sortable.js requires a window with a document"); }; } + + var supportsPassive = false; + try { + var opts = Object.defineProperty({}, 'passive', { + get: function() { + supportsPassive = true; + } + }); + window.addEventListener("test", null, opts); + } catch (e) {} var dragEl, parentEl, @@ -67,7 +77,7 @@ $ = win.jQuery || win.Zepto, Polymer = win.Polymer, - captureMode = false, + captureMode = supportsPassive ? {capture: false, passive: false} : false, supportDraggable = !!('draggable' in document.createElement('div')), supportCssPointerEvents = (function (el) { @@ -230,7 +240,6 @@ // Export instance el[expando] = this; - el.style['touch-action'] = 'none'; // #1022 // Default options var defaults = {