Skip to content

Commit

Permalink
fix: passive touch events
Browse files Browse the repository at this point in the history
closes #12256
  • Loading branch information
joeworkman committed Sep 1, 2021
1 parent 4339da7 commit 12aaac0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/foundation.util.touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down

0 comments on commit 12aaac0

Please sign in to comment.