From e9b86ad8a606f8281acdeab07b4718c4a428b18b Mon Sep 17 00:00:00 2001 From: Kendall Arneaud Date: Mon, 15 Aug 2022 22:58:37 -0400 Subject: [PATCH 1/4] Option to disable scroll tap outside provided options to disable scrolling to tapped position --- src/dragdealer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dragdealer.js b/src/dragdealer.js index f1c60ff..6fe9bae 100644 --- a/src/dragdealer.js +++ b/src/dragdealer.js @@ -450,9 +450,12 @@ Dragdealer.prototype = { this.activity = true; }, onWrapperMouseDown: function(e) { - Cursor.refresh(e); - preventEventDefaults(e); - this.startTap(); + if (!this.options.scrollToTap) { + return; + } + Cursor.refresh(e); + preventEventDefaults(e); + this.startTap(); }, onWrapperTouchStart: function(e) { Cursor.refresh(e); From 9d944b438867ef71f4cdc8825d53a3bb0715ab3e Mon Sep 17 00:00:00 2001 From: Kendall Arneaud Date: Mon, 15 Aug 2022 23:01:14 -0400 Subject: [PATCH 2/4] Add property option to allow scroll to tap Add option property to be set for user to disable scroll to on tap outside of handle --- src/dragdealer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dragdealer.js b/src/dragdealer.js index 6fe9bae..4cdb80e 100644 --- a/src/dragdealer.js +++ b/src/dragdealer.js @@ -125,6 +125,8 @@ var Dragdealer = function(wrapper, options) { * * - number right=0: Right padding between the wrapper and the handle. * + * - bool scrollToTap=false: Option to only allow movement on handle drag. + * * - fn callback(x, y): Called when releasing handle, with the projected * x, y position of the handle. Projected value means * the value the slider will have after finishing a From 0e1abb8d700bf750c74bfd8217eda579b990b419 Mon Sep 17 00:00:00 2001 From: Kendall Arneaud Date: Mon, 15 Aug 2022 23:02:29 -0400 Subject: [PATCH 3/4] Add default option scrollToTap adding default option false for scrollToTap --- src/dragdealer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dragdealer.js b/src/dragdealer.js index 4cdb80e..403d44f 100644 --- a/src/dragdealer.js +++ b/src/dragdealer.js @@ -229,6 +229,7 @@ Dragdealer.prototype = { snap: false, loose: false, speed: 0.1, + scrollToTap: false, xPrecision: 0, yPrecision: 0, handleClass: 'handle', From 392c07ba225a99e560058cc5d2d38a8b0fc6e353 Mon Sep 17 00:00:00 2001 From: Kendall Arneaud Date: Wed, 17 Aug 2022 11:17:13 -0400 Subject: [PATCH 4/4] Update modifications Fixed logic to more appropriately initiate scrollToTap option. --- src/dragdealer.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/dragdealer.js b/src/dragdealer.js index 403d44f..eb12179 100644 --- a/src/dragdealer.js +++ b/src/dragdealer.js @@ -125,7 +125,7 @@ var Dragdealer = function(wrapper, options) { * * - number right=0: Right padding between the wrapper and the handle. * - * - bool scrollToTap=false: Option to only allow movement on handle drag. + * - bool scrollToTap=true: Option to only allow movement on handle drag. * * - fn callback(x, y): Called when releasing handle, with the projected * x, y position of the handle. Projected value means @@ -229,7 +229,7 @@ Dragdealer.prototype = { snap: false, loose: false, speed: 0.1, - scrollToTap: false, + scrollToTap: true, xPrecision: 0, yPrecision: 0, handleClass: 'handle', @@ -413,7 +413,7 @@ Dragdealer.prototype = { this.startDrag(); }, onHandleTouchStart: function(e) { - Cursor.refresh(e); + Cursor.refresh(e); // Unlike in the `mousedown` event handler, we don't prevent defaults here, // because this would disable the dragging altogether. Instead, we prevent // it in the `touchmove` handler. Read more about touch events @@ -436,6 +436,9 @@ Dragdealer.prototype = { } }, onWrapperTouchMove: function(e) { + if (!this.options.scrollToTap && (e.target != this.handle && e.target != this.wrapper) ) { + return; + } Cursor.refresh(e); // Dragging on a disabled axis (horizontal or vertical) shouldn't prevent // defaults on touch devices. !this.activity denotes this is the first move @@ -453,15 +456,16 @@ Dragdealer.prototype = { this.activity = true; }, onWrapperMouseDown: function(e) { - if (!this.options.scrollToTap) { - return; - } - Cursor.refresh(e); + Cursor.refresh(e); preventEventDefaults(e); this.startTap(); }, onWrapperTouchStart: function(e) { - Cursor.refresh(e); + if (!this.options.scrollToTap && (e.target != this.handle && e.target != this.wrapper) ) { + return; + } + + Cursor.refresh(e); preventEventDefaults(e); this.startTap(); },