mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-02-27 07:42:12 +01:00
29 lines
828 B
JavaScript
29 lines
828 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 })
|
|
}
|
|
}
|
|
})()
|