enable gallery scrolling functionality for horizontal scroll and gamepads
This commit is contained in:
parent
501d4e9cf1
commit
bfa14db2cb
@ -219,18 +219,37 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
modal.id = "lightboxModal";
|
modal.id = "lightboxModal";
|
||||||
modal.tabIndex = 0
|
modal.tabIndex = 0
|
||||||
modal.addEventListener('keydown', modalKeyHandler, true)
|
modal.addEventListener('keydown', modalKeyHandler, true)
|
||||||
|
|
||||||
|
let delay = 350//ms
|
||||||
window.addEventListener('gamepadconnected', (e) => {
|
window.addEventListener('gamepadconnected', (e) => {
|
||||||
console.log("Gamepad connected!")
|
console.log("Gamepad connected!")
|
||||||
const gamepad = e.gamepad;
|
const gamepad = e.gamepad;
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
const xValue = gamepad.axes[0].toFixed(2);
|
const xValue = gamepad.axes[0].toFixed(2);
|
||||||
if (xValue < -0.3) {
|
if (xValue < -0.3) {
|
||||||
modalPrevImage();
|
modalPrevImage(e);
|
||||||
} else if (xValue > 0.3) {
|
} else if (xValue > 0.3) {
|
||||||
modalNextImage();
|
modalNextImage(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 350);
|
}, delay);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
let isScrolling = false;
|
||||||
|
window.addEventListener('wheel', (e) => {
|
||||||
|
if (isScrolling) return;
|
||||||
|
isScrolling = true;
|
||||||
|
|
||||||
|
if (e.deltaX <= -0.6) {
|
||||||
|
modalPrevImage(e);
|
||||||
|
} else if (e.deltaX >= 0.6) {
|
||||||
|
modalNextImage(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
isScrolling = false;
|
||||||
|
}, delay);
|
||||||
});
|
});
|
||||||
|
|
||||||
const modalControls = document.createElement('div')
|
const modalControls = document.createElement('div')
|
||||||
|
Loading…
Reference in New Issue
Block a user