Skip to content

Commit

Permalink
make sure the button in mousedown is leftclick lol
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Mar 5, 2024
1 parent 4650342 commit 6447ca3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/Gallery.astro
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ const imgCount = gallery.match(/<\s*img/gs)?.length;
// Navigating by swiping / clicking on the sides
gallery.querySelector('main')!.addEventListener('mousedown', e => {
const touchPos = e.clientX;

// Make sure it's left click lol
if (e.button != 0) {
return;
}

// Remove any existing touch-start attribute
gallery.removeAttribute('touch-start');
Expand All @@ -85,6 +90,10 @@ const imgCount = gallery.match(/<\s*img/gs)?.length;
}
});
gallery.querySelector('main')!.addEventListener('mousemove', e => {
// Make sure it's left click lol
if (e.button != 0) {
return;
}
const start = gallery.getAttribute('touch-start');
if (start) {
const startPos = parseInt(start);
Expand Down

0 comments on commit 6447ca3

Please sign in to comment.