forked from extern/easydiffusion
Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta
This commit is contained in:
commit
ca19a488a8
@ -70,6 +70,14 @@
|
|||||||
max-height: calc(100vh - (var(--popup-padding) * 2) - 4px);
|
max-height: calc(100vh - (var(--popup-padding) * 2) - 4px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#viewFullSizeImgModal img:not(.natural-zoom) {
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
|
||||||
|
#viewFullSizeImgModal .grabbing img:not(.natural-zoom) {
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
#viewFullSizeImgModal .content > div::-webkit-scrollbar-track, #viewFullSizeImgModal .content > div::-webkit-scrollbar-corner {
|
#viewFullSizeImgModal .content > div::-webkit-scrollbar-track, #viewFullSizeImgModal .content > div::-webkit-scrollbar-corner {
|
||||||
background: rgba(0, 0, 0, .5)
|
background: rgba(0, 0, 0, .5)
|
||||||
}
|
}
|
||||||
|
@ -63,15 +63,73 @@ const imageModal = (function() {
|
|||||||
setZoomLevel(imageContainer.querySelector("img")?.classList?.contains("natural-zoom"))
|
setZoomLevel(imageContainer.querySelector("img")?.classList?.contains("natural-zoom"))
|
||||||
)
|
)
|
||||||
|
|
||||||
const state = {
|
const initialState = () => ({
|
||||||
previous: undefined,
|
previous: undefined,
|
||||||
next: undefined,
|
next: undefined,
|
||||||
|
|
||||||
|
start: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
},
|
||||||
|
|
||||||
|
scroll: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const state = initialState()
|
||||||
|
|
||||||
|
// Allow grabbing the image to scroll
|
||||||
|
const stopGrabbing = (e) => {
|
||||||
|
if(imageContainer.classList.contains("grabbing")) {
|
||||||
|
imageContainer.classList.remove("grabbing")
|
||||||
|
e?.preventDefault()
|
||||||
|
console.log(`stopGrabbing()`, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const addImageGrabbing = (image) => {
|
||||||
|
image?.addEventListener('mousedown', (e) => {
|
||||||
|
if (!image.classList.contains("natural-zoom")) {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.stopImmediatePropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
imageContainer.classList.add("grabbing")
|
||||||
|
state.start.x = e.pageX - imageContainer.offsetLeft
|
||||||
|
state.scroll.x = imageContainer.scrollLeft
|
||||||
|
state.start.y = e.pageY - imageContainer.offsetTop
|
||||||
|
state.scroll.y = imageContainer.scrollTop
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
image?.addEventListener('mouseup', stopGrabbing)
|
||||||
|
image?.addEventListener('mouseleave', stopGrabbing)
|
||||||
|
image?.addEventListener('mousemove', (e) => {
|
||||||
|
if(imageContainer.classList.contains("grabbing")) {
|
||||||
|
e.stopPropagation()
|
||||||
|
e.stopImmediatePropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
// Might need to increase this multiplier based on the image size to window size ratio
|
||||||
|
// The default 1:1 is pretty slow
|
||||||
|
const multiplier = 1.0
|
||||||
|
|
||||||
|
const deltaX = e.pageX - imageContainer.offsetLeft - state.start.x
|
||||||
|
imageContainer.scrollLeft = state.scroll.x - (deltaX * multiplier)
|
||||||
|
const deltaY = e.pageY - imageContainer.offsetTop - state.start.y
|
||||||
|
imageContainer.scrollTop = state.scroll.y - (deltaY * multiplier)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const clear = () => {
|
const clear = () => {
|
||||||
imageContainer.innerHTML = ""
|
imageContainer.innerHTML = ""
|
||||||
|
|
||||||
Object.keys(state).forEach((key) => delete state[key])
|
Object.entries(initialState()).forEach(([key, value]) => state[key] = value)
|
||||||
|
|
||||||
|
stopGrabbing()
|
||||||
}
|
}
|
||||||
|
|
||||||
const close = () => {
|
const close = () => {
|
||||||
@ -95,6 +153,7 @@ const imageModal = (function() {
|
|||||||
const src = typeof options === "string" ? options : options.src
|
const src = typeof options === "string" ? options : options.src
|
||||||
|
|
||||||
const imgElem = createElement("img", { src }, "natural-zoom")
|
const imgElem = createElement("img", { src }, "natural-zoom")
|
||||||
|
addImageGrabbing(imgElem)
|
||||||
imageContainer.appendChild(imgElem)
|
imageContainer.appendChild(imgElem)
|
||||||
modalElem.classList.add("active")
|
modalElem.classList.add("active")
|
||||||
document.body.style.overflow = "hidden"
|
document.body.style.overflow = "hidden"
|
||||||
|
@ -246,7 +246,7 @@ function refreshInactiveTags(inactiveTags) {
|
|||||||
overlays.forEach((i) => {
|
overlays.forEach((i) => {
|
||||||
let modifierName = i.parentElement.getElementsByClassName("modifier-card-label")[0].getElementsByTagName("p")[0]
|
let modifierName = i.parentElement.getElementsByClassName("modifier-card-label")[0].getElementsByTagName("p")[0]
|
||||||
.dataset.fullName
|
.dataset.fullName
|
||||||
if (inactiveTags?.find((element) => element === modifierName) !== undefined) {
|
if (inactiveTags?.find((element) => trimModifiers(element) === modifierName) !== undefined) {
|
||||||
i.parentElement.classList.add("modifier-toggle-inactive")
|
i.parentElement.classList.add("modifier-toggle-inactive")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user