Skip to content

Commit

Permalink
add preventDefault in touch event
Browse files Browse the repository at this point in the history
Add a preventDefault call in the touch event callback.
On Safari, the passive option is set to true by default, so we need to set it to false. Issue #36.
  • Loading branch information
ClementCariou committed Jan 31, 2024
1 parent 06aabe2 commit 674e29b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/fps.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ module.exports = function ({getGridSegments, getGridParts}, fovY) {
let lastTouch = false;
let touchTimestamp = 0;
const handleTouch = (e) => {
e.preventDefault();
if(pointer) {
pointer.destroy();
pointer = false;
Expand Down Expand Up @@ -197,9 +198,9 @@ module.exports = function ({getGridSegments, getGridParts}, fovY) {
}
//console.log(e);
}
window.addEventListener('touchstart', handleTouch);
window.addEventListener('touchmove', handleTouch);
window.addEventListener('touchend', handleTouch);
window.addEventListener('touchstart', handleTouch, {passive: false});
window.addEventListener('touchmove', handleTouch, {passive: false});
window.addEventListener('touchend', handleTouch, {passive: false});

// Keyboard input
var keys = {};
Expand Down

0 comments on commit 674e29b

Please sign in to comment.