Merge bfa14db2cb
into ea9bd9fc74
This commit is contained in:
commit
250a28864d
|
@ -220,6 +220,38 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
modal.tabIndex = 0
|
modal.tabIndex = 0
|
||||||
modal.addEventListener('keydown', modalKeyHandler, true)
|
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(e);
|
||||||
|
} else if (xValue > 0.3) {
|
||||||
|
modalNextImage(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 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')
|
||||||
modalControls.className = 'modalControls gradio-container';
|
modalControls.className = 'modalControls gradio-container';
|
||||||
modal.append(modalControls);
|
modal.append(modalControls);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user