Skip to content

Commit

Permalink
Added mobile coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
laura-dumitru committed Feb 7, 2024
1 parent b74209d commit 8d5410b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,25 @@ const overlayRect = overlay.getBoundingClientRect();

let userInteraction;
function pointerMove(e) {
console.log(e);
e.preventDefault();
clearInterval(userInteraction);

const x = e.offsetX;
const y = e.offsetY;
const regex = /Mobi|Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
const mobile = regex.test(navigator.userAgent);

if (mobile) {
// For mobile, use touch event coordinates
x = e.touches[0].clientX;
y = e.touches[0].clientY;
} else {
// For desktop, use mouse event coordinates
x = e.offsetX;
y = e.offsetY;
}

//const x = e.offsetX;
//const y = e.offsetY;
const edges = gsap.timeline();

//const edge = 3
Expand Down

0 comments on commit 8d5410b

Please sign in to comment.