forked from extern/easydiffusion
9410879b73
Error report: https://discord.com/channels/1014774730907209781/1085803885500825600/1108150298289115187
33 lines
886 B
JavaScript
33 lines
886 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 }
|
|
)
|
|
}
|
|
}
|
|
})()
|