MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / init

Function init

ui/media/js/image-modal.js:144–175  ·  view source on GitHub ↗

* @param {() => (string | ImageModalRequest) | string | ImageModalRequest} optionsFactory

(optionsFactory)

Source from the content-addressed store, hash-verified

142 * @param {() => (string | ImageModalRequest) | string | ImageModalRequest} optionsFactory
143 */
144 function init(optionsFactory) {
145 if (!optionsFactory) {
146 close()
147 return
148 }
149
150 clear()
151
152 const options = typeof optionsFactory === "function" ? optionsFactory() : optionsFactory
153 const src = typeof options === "string" ? options : options.src
154
155 const imgElem = createElement("img", { src }, "natural-zoom")
156 addImageGrabbing(imgElem)
157 imageContainer.appendChild(imgElem)
158 modalElem.classList.add("active")
159 document.body.style.overflow = "hidden"
160 setZoomLevel(false)
161
162 if (typeof options === "object" && options.previous) {
163 state.previous = options.previous
164 backElem.style.display = "unset"
165 } else {
166 backElem.style.display = "none"
167 }
168
169 if (typeof options === "object" && options.next) {
170 state.next = options.next
171 forwardElem.style.display = "unset"
172 } else {
173 forwardElem.style.display = "none"
174 }
175 }
176
177 const back = () => {
178 if (state.previous) {

Callers 3

backFunction · 0.70
forwardFunction · 0.70
image-modal.jsFile · 0.70

Calls 7

closeFunction · 0.85
clearFunction · 0.85
createElementFunction · 0.85
addImageGrabbingFunction · 0.85
setZoomLevelFunction · 0.85
appendChildMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected