未验证 提交 bfa14db2 编写于 作者: U unknown

enable gallery scrolling functionality for horizontal scroll and gamepads

上级 501d4e9c
......@@ -219,18 +219,37 @@ document.addEventListener("DOMContentLoaded", function() {
modal.id = "lightboxModal";
modal.tabIndex = 0
modal.addEventListener('keydown', modalKeyHandler, true)
let delay = 350//ms
window.addEventListener('gamepadconnected', (e) => {
console.log("Gamepad connected!")
const gamepad = e.gamepad;
setInterval(() => {
const xValue = gamepad.axes[0].toFixed(2);
if (xValue < -0.3) {
modalPrevImage();
modalPrevImage(e);
} 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')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册