Touchstart and click may cause a double fire event on mobile devices Stop the events from propagating.
Jeremy D

Jeremy D commited on 2021-10-15 18:26:45
Showing 1 changed files, with 5 additions and 1 deletions.

... ...
@@ -58,7 +58,7 @@
58 58
 			inputParentCss: 'input-group numberControl',
59 59
 			inputParent: 'div',
60 60
 			inputCss: 'numberControlInput form-control px-1',
61
-			bindButtonEvents: 'click tap touch touchstart',
61
+			bindButtonEvents: 'click touchend',
62 62
 			keyboardLanguage: {
63 63
 				'UP' : '<span class="oi oi-chevron-top" />',
64 64
 				'DOWN' : '<span class="oi oi-chevron-bottom" />',
... ...
@@ -177,6 +177,7 @@
177 177
 			var $decreaseButton = $parent.find('.btn-decrease');
178 178
 			$decreaseButton.on(options.bindButtonEvents, function (event) {
179 179
 				event.preventDefault();
180
+				event.stopPropagation();
180 181
 
181 182
 				if (options.onBeforeClickDecrease !== undefined)
182 183
 					options.onBeforeClickDecrease(this, event);
... ...
@@ -192,6 +193,7 @@
192 193
 			var $increaseButton = $parent.find('.btn-increase');
193 194
 			$increaseButton.on(options.bindButtonEvents, function (event) {
194 195
 				event.preventDefault();
196
+				event.stopPropagation();
195 197
 
196 198
 				if (options.onBeforeClickIncrease !== undefined)
197 199
 					options.onBeforeClickIncrease(this, event);
... ...
@@ -212,6 +214,7 @@
212 214
 					options.onBeforeVirtualKeyboardInitalized(this);
213 215
 
214 216
 				$base.on(options.bindButtonEvents, function (event) {
217
+					event.preventDefault();
215 218
 					event.stopPropagation();
216 219
 
217 220
 					if (options.onBeforeVirtualKeyboardOpen !== undefined)
... ...
@@ -276,6 +279,7 @@
276 279
 					// Bind the virtual Keyboard action.
277 280
 					$VirtualKeyboard.find('.numberControlVirtualNumPad').on(options.bindButtonEvents, function(event){						
278 281
 						event.preventDefault();
282
+						event.stopPropagation();
279 283
 
280 284
 						if (options.debug) console.log('numbercontrl: numberControlVirtualNumPad: Click', event, $base.val(), $VirtualKeyboardInput.val().toString(), $(this).attr('data-function'));
281 285
 
282 286