]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: passive touch events
authorJoe Workman <joe@workmanmail.com>
Wed, 1 Sep 2021 22:59:22 +0000 (15:59 -0700)
committerJoe Workman <joe@workmanmail.com>
Wed, 1 Sep 2021 22:59:53 +0000 (15:59 -0700)
closes #12256

js/foundation.util.touch.js

index 79e8881e6bc0ce8312a7e9d6745bf1dc21ee799f..7a927950ae780859f5fec5371165e5212365f4a0 100644 (file)
@@ -31,13 +31,13 @@ function onTouchEnd(e) {
 }
 
 function onTouchMove(e) {
-  if ($.spotSwipe.preventDefault) { e.preventDefault(); }
+  if (true === $.spotSwipe.preventDefault) { e.preventDefault(); }
 
   if(isMoving) {
     var x = e.touches[0].pageX;
-    var y = e.touches[0].pageY;
+    // var y = e.touches[0].pageY;
     var dx = startPosX - x;
-    var dy = startPosY - y;
+    // var dy = startPosY - y;
     var dir;
     didMoved = true;
     elapsedTime = new Date().getTime() - startTime;
@@ -60,20 +60,20 @@ function onTouchMove(e) {
 
 function onTouchStart(e) {
 
-  if (e.touches.length == 1) {
+  if (e.touches.length === 1) {
     startPosX = e.touches[0].pageX;
     startPosY = e.touches[0].pageY;
     startEvent = e;
     isMoving = true;
     didMoved = false;
     startTime = new Date().getTime();
-    this.addEventListener('touchmove', onTouchMove, false);
+    this.addEventListener('touchmove', onTouchMove, { passive : true === $.spotSwipe.preventDefault });
     this.addEventListener('touchend', onTouchEnd, false);
   }
 }
 
 function init() {
-  this.addEventListener && this.addEventListener('touchstart', onTouchStart, false);
+  this.addEventListener && this.addEventListener('touchstart', onTouchStart, { passive : true });
 }
 
 function teardown() {