mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-12-25 03:11:32 -08:00
modularize
This commit is contained in:
parent
bfa14db2cb
commit
40dc0132df
2 changed files with 40 additions and 31 deletions
|
|
@ -220,37 +220,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
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(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);
|
||||
});
|
||||
// detect gamepads and enable related functionality
|
||||
let gamepadScript = document.createElement('script');
|
||||
gamepadScript.src = 'imageviewerGamepad.js';
|
||||
document.body.appendChild(gamepadScript);
|
||||
|
||||
const modalControls = document.createElement('div')
|
||||
modalControls.className = 'modalControls gradio-container';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue