Download extensions/Stable-Diffusion-WebUI-StepExplorer/javascript/scroll.js from dikdimon/test: direct link, hf CLI and curl.
- Browser
- Download file 862 Bytes
-
https://huggingface.co/dikdimon/test/resolve/main/extensions/Stable-Diffusion-WebUI-StepExplorer/javascript/scroll.js
- Command line
-
hf download hf://dikdimon/test/extensions/Stable-Diffusion-WebUI-StepExplorer/javascript/scroll.js
-
curl -L -o scroll.js https://huggingface.co/dikdimon/test/resolve/main/extensions/Stable-Diffusion-WebUI-StepExplorer/javascript/scroll.js
862 Bytes
| let stepCursor = {txt: 0, img: 0}; | |
| function setupScroll(tab) { | |
| const buttons = gradioApp().querySelectorAll(`#${tab}2img_gallery.gradio-gallery * button.thumbnail-small`); | |
| if (buttons.length > 0) { | |
| const gallery = gradioApp().querySelector(`#${tab}2img_gallery.gradio-gallery`); | |
| gallery.onwheel = (event) => { | |
| event.preventDefault(); | |
| const dir = Math.sign(event.deltaY); | |
| const nextStepCursor = Math.min(Math.max(0, (stepCursor[tab] - dir)), buttons.length - 1); | |
| if (stepCursor[tab] != nextStepCursor) { | |
| stepCursor[tab] = nextStepCursor; | |
| buttons[stepCursor[tab]].click(); | |
| } | |
| } | |
| } | |
| } | |
| onAfterUiUpdate(function() { | |
| setupScroll("txt"); | |
| setupScroll("img"); | |
| updateOnBackgroundChange(); | |
| }); |