mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-04-22 02:18:26 +02:00
33 lines
885 B
JavaScript
33 lines
885 B
JavaScript
;(function() {
|
|
"use strict"
|
|
|
|
let autoScroll = document.querySelector("#auto_scroll")
|
|
|
|
// observe for changes in the preview pane
|
|
var observer = new MutationObserver(function(mutations) {
|
|
mutations.forEach(function(mutation) {
|
|
if (mutation.target.className == "img-batch") {
|
|
Autoscroll(mutation.target)
|
|
}
|
|
})
|
|
})
|
|
|
|
observer.observe(document.getElementById("preview"), {
|
|
childList: true,
|
|
subtree: true,
|
|
})
|
|
|
|
function Autoscroll(target) {
|
|
if (autoScroll.checked && target !== null) {
|
|
const img = target.querySelector("img")
|
|
img.addEventListener(
|
|
"load",
|
|
function() {
|
|
img.closest(".imageTaskContainer").scrollIntoView()
|
|
},
|
|
{ once: true }
|
|
)
|
|
}
|
|
}
|
|
})()
|