summaryrefslogtreecommitdiff
path: root/dist/libra.min.js.map
diff options
context:
space:
mode:
Diffstat (limited to 'dist/libra.min.js.map')
-rw-r--r--dist/libra.min.js.map2
1 files changed, 1 insertions, 1 deletions
diff --git a/dist/libra.min.js.map b/dist/libra.min.js.map
index 6a178be..3bb87bb 100644
--- a/dist/libra.min.js.map
+++ b/dist/libra.min.js.map
@@ -1 +1 @@
-{"mappings":"AEAA,MAAM,+BAAS;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;QAAE,GAAG;QAAG,GAAG;IAAE;IACrB,oBAAoB;IACpB,aAAa;AACf;AAEA,SAAS,gCAAU,MAAM,EAAE,MAAM;IAC/B,IAAK,MAAM,OAAO,OAChB,IACE,OAAO,MAAM,CAAC,IAAI,KAAK,YACvB,MAAM,CAAC,IAAI,KAAK,QAChB,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,GAC1B;QACA,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,CAAC;QACjC,gCAAU,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI;IACpC,OACE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;IAG7B,OAAO;AACT;AAEO,SAAS,0CAAU,SAAS;IACjC,gCAAU,8BAAQ;AACpB;IAEA,2CAAe;;;AD1BA;IACb,aAAc;QACZ,MAAM,UAAU,SAAS,aAAa,CAAC;QACvC,QAAQ,EAAE,GAAG;QACb,QAAQ,SAAS,CAAC,GAAG,CAAC,iBAAiB;QAEvC,sCAAsC;QACtC,QAAQ,KAAK,CAAC,kBAAkB,GAAG,CAAA,GAAA,wCAAK,EAAE,kBAAkB,GAAG;QAE/D,IAAI,CAAC,OAAO,GAAG;QACf,SAAS,IAAI,CAAC,WAAW,CAAC;QAE1B,OAAO,IAAI;IACb;IAEA,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,S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E;QACV,IAAI,CAAC,YAAY,GAAG;QAEpB,MAAM,SAAS,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,CAAA,GAAA,wCAAK,EAAE;QACpD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EACzB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG;QAG3B,OAAO,IAAI;QACX,IAAI,CAAC,OAAO,CAAC,IAAI;IACnB;IAEA,gDAAgD;IAChD,MAAM,KAAK,EAAE;QACX,IAAI,CAAC,YAAY,GAAG;QAEpB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE;QAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK;QAE5B,IAAI,CAAC,OAAO,CAAC,IAAI;IACnB;IAEA,eAAe;QACb,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;QACxB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY;IAC9B;AACF","sources":["src/lightbox.js","src/overlay.js","src/config.js","src/shadow.js","src/animation.js"],"sourcesContent":["import Overlay from './overlay';\nimport Shadow from './shadow';\nimport config from './config';\nimport { setConfig } from './config';\n\nexport default class LightBox {\n currentImage = null;\n shadows = {};\n\n /**\n * ============\n * Initializers\n * ============\n */\n\n constructor(config) {\n setConfig(config);\n\n this.initOverlay();\n this.initImages();\n this.initControls();\n }\n\n initOverlay() {\n this.overlay = new Overlay();\n this.overlay.element.addEventListener('click', () => {\n this.closeCurrent();\n });\n }\n\n initImages() {\n this.images = document.querySelectorAll(config.selector);\n this.images.forEach(image => {\n if (image.tagName !== 'IMG') return;\n image.id = crypto.randomUUID(); // generate unique id for each image\n image.style.cursor = config.imageCursor;\n image.addEventListener('click', () => this.open(image)); // click image to open lightbox\n });\n }\n\n initControls() {\n // keyboard shortcuts\n document.addEventListener('keydown', e => {\n if (e.key === 'Escape' || e.key === ' ')\n this.closeCurrent();\n });\n // scroll to dismiss\n document.body.addEventListener('wheel', e => this.closeCurrent());\n document.body.addEventListener('touchmove', e => this.closeCurrent());\n }\n\n /**\n * ============\n * Actions\n * ============\n */\n\n // open lightbox = open shadow + show overlay\n open(image) {\n this.currentImage = image;\n\n const shadow = this.shadows[image.id] || new Shadow(image);\n if (!this.shadows[image.id]) {\n this.shadows[image.id] = shadow;\n }\n\n shadow.open();\n this.overlay.show();\n }\n\n // close lightbox = remove shadow + hide overlay\n close(image) {\n this.currentImage = null;\n\n if (!this.shadows[image.id]) return;\n this.shadows[image.id].close();\n\n this.overlay.hide();\n }\n\n closeCurrent() {\n if (!this.currentImage) return;\n this.close(this.currentImage);\n }\n}\n","import config from './config';\n\nexport default class Overlay {\n constructor() {\n const overlay = document.createElement('div');\n overlay.id = 'libra-overlay';\n overlay.classList.add('libra-overlay', 'libra-hidden');\n\n // Set transition duration from config\n overlay.style.transitionDuration = config.transitionDuration + 'ms';\n\n this.element = overlay;\n document.body.appendChild(overlay);\n\n return this;\n }\n\n show() {\n this.element.classList.remove('libra-hidden');\n this.element.classList.add('libra-visible');\n }\n\n hide() {\n this.element.classList.remove('libra-visible');\n this.element.classList.add('libra-hidden');\n }\n}\n","const config = {\n selector: '[data-libra]',\n margin: 50,\n offset: { x: 0, y: 0 },\n transitionDuration: 200, // milliseconds\n imageCursor: 'zoom-in',\n};\n\nfunction deepMerge(target, source) {\n for (const key in source) {\n if (\n typeof source[key] === 'object' &&\n source[key] !== null &&\n !Array.isArray(source[key])\n ) {\n if (!target[key]) target[key] = {};\n deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n return target;\n}\n\nexport function setConfig(newConfig) {\n deepMerge(config, newConfig);\n}\n\nexport default config;\n","import Animation from './animation.js';\nimport config from './config';\n\nexport default class Shadow {\n isOpen = false;\n\n /**\n * ============\n * Constructors\n * ============\n */\n\n constructor(image) {\n this.original = image;\n\n const rect = this.original.getBoundingClientRect();\n this.originalPosition = {\n top: rect.top + window.scrollY + config.offset.y,\n left: rect.left + window.scrollX + config.offset.x,\n width: rect.width,\n height: rect.height,\n };\n\n this.create(image);\n\n return this;\n }\n\n create(image) {\n // create shadow image\n const shadow = document.createElement('img');\n shadow.src = image.src;\n shadow.id = `libra-shadow-${image.id}`;\n shadow.classList.add('libra-shadow');\n\n // style and position shadow image\n shadow.style.top = `${this.originalPosition.top}px`;\n shadow.style.left = `${this.originalPosition.left}px`;\n shadow.style.width = `${this.originalPosition.width}px`;\n shadow.style.height = `${this.originalPosition.height}px`;\n // Set transition duration from config\n shadow.style.transitionDuration = config.transitionDuration + 'ms';\n\n document.body.appendChild(shadow);\n this.element = shadow;\n }\n\n /**\n * ============\n * Actions\n * ============\n */\n\n updateOriginalPosition() {\n const rect = this.original.getBoundingClientRect();\n this.originalPosition = {\n top: rect.top + window.scrollY + config.offset.y,\n left: rect.left + window.scrollX + config.offset.x,\n width: rect.width,\n height: rect.height,\n };\n }\n\n open() {\n this.isOpen = true;\n this.element.classList.add('open');\n\n // Update original position before animation in case viewport changed\n this.updateOriginalPosition();\n this.element.style.top = `${this.originalPosition.top}px`;\n this.element.style.left = `${this.originalPosition.left}px`;\n this.element.style.width = `${this.originalPosition.width}px`;\n this.element.style.height = `${this.originalPosition.height}px`;\n\n this.original.style.visibility = 'hidden';\n if (!document.body.contains(this.element)) this.placeItself();\n\n // Wait for image to load before animating\n if (this.element.naturalWidth === 0 || this.element.naturalHeight === 0) {\n this.element.addEventListener(\n 'load',\n () => {\n Animation.transformMatrix(\n this.element,\n this.originalPosition,\n Animation.calculateFinalState(this.element),\n );\n },\n { once: true },\n );\n } else {\n Animation.transformMatrix(\n this.element,\n this.originalPosition,\n Animation.calculateFinalState(this.element),\n );\n }\n }\n\n close() {\n this.isOpen = false;\n this.element.classList.remove('open');\n\n Animation.resetTransformMatrix(this.element);\n // Wait for animation to complete before showing original and destroying shadow\n setTimeout(() => {\n this.original.style.visibility = 'visible';\n this.destroyItself();\n }, config.transitionDuration);\n }\n\n placeItself() {\n document.body.appendChild(this.element);\n }\n\n destroyItself() {\n if (!document.body.contains(this.element)) return;\n document.body.removeChild(this.element);\n }\n}\n","import config from './config';\n\nexport default class Animation {\n static calculateFinalState(element) {\n let finals = {};\n\n const margin = config.margin;\n const nw = element.naturalWidth;\n const nh = element.naturalHeight;\n const ratio = nw / nh;\n const ww = window.innerWidth - 2 * margin;\n const wh = window.innerHeight - 2 * margin;\n\n // size image based on width first\n finals.width = nw > ww ? ww : nw;\n finals.height = nw > ww ? ww / ratio : nh;\n\n // if height is too big, adjust based on height\n if (finals.height > wh) {\n finals.height = wh;\n finals.width = wh * ratio;\n }\n\n finals.top =\n (wh - finals.height) / 2 + window.scrollY + margin + config.offset.y;\n finals.left =\n (ww - finals.width) / 2 + window.scrollX + margin + config.offset.x;\n\n return finals;\n }\n\n static transformMatrix(element, starts, finals) {\n // Calculate scaling factors based on width and height interpolation\n const scaleX = finals.width / starts.width;\n const scaleY = finals.height / starts.height;\n\n // Calculate the center of the starting and final positions\n const startCenterX = starts.left + starts.width / 2;\n const startCenterY = starts.top + starts.height / 2;\n const finalCenterX = finals.left + finals.width / 2;\n const finalCenterY = finals.top + finals.height / 2;\n\n const translateX = finalCenterX - startCenterX;\n const translateY = finalCenterY - startCenterY;\n\n // Apply the transform with matrix (scale + translate)\n element.style.transform = `matrix(${scaleX}, 0, 0, ${scaleY}, ${translateX}, ${translateY})`;\n }\n\n static resetTransformMatrix(element) {\n element.style.transform = `matrix(1, 0, 0, 1, 0, 0)`;\n }\n}\n"],"names":[],"version":3,"file":"libra.min.js.map","sourceRoot":"../"} \ No newline at end of file
+{"mappings":"AGAA,IAAM,EAAS,CACb,SAAU,eACV,OAAQ,GACR,OAAQ,CAAE,EAAG,EAAG,EAAG,CAAE,EACrB,mBAAoB,IACpB,YAAa,SACf,CDJe,OAAA,EACb,aAAc,CACZ,IAAM,EAAU,SAAS,aAAa,CAAC,OAUvC,OATA,EAAQ,EAAE,CAAG,gBACb,EAAQ,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cesContent":["const $0c04c0cc2b6985d8$var$config = {\n selector: '[data-libra]',\n margin: 50,\n offset: {\n x: 0,\n y: 0\n },\n transitionDuration: 200,\n imageCursor: 'zoom-in'\n};\nfunction $0c04c0cc2b6985d8$var$deepMerge(target, source) {\n for(const key in source)if (typeof source[key] === 'object' && source[key] !== null && !Array.isArray(source[key])) {\n if (!target[key]) target[key] = {};\n $0c04c0cc2b6985d8$var$deepMerge(target[key], source[key]);\n } else target[key] = source[key];\n return target;\n}\nfunction $0c04c0cc2b6985d8$export$940a7873bb071df8(newConfig) {\n $0c04c0cc2b6985d8$var$deepMerge($0c04c0cc2b6985d8$var$config, newConfig);\n}\nvar $0c04c0cc2b6985d8$export$2e2bcd8739ae039 = $0c04c0cc2b6985d8$var$config;\n\n\nclass $e49d13fc7942bae1$export$2e2bcd8739ae039 {\n constructor(){\n const overlay = document.createElement('div');\n overlay.id = 'libra-overlay';\n overlay.classList.add('libra-overlay', 'libra-hidden');\n // Set transition duration from config\n overlay.style.transitionDuration = (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).transitionDuration + 'ms';\n this.element = overlay;\n document.body.appendChild(overlay);\n return this;\n }\n show() {\n this.element.classList.remove('libra-hidden');\n this.element.classList.add('libra-visible');\n }\n hide() {\n this.element.classList.remove('libra-visible');\n this.element.classList.add('libra-hidden');\n }\n}\n\n\n\nclass $6e8e6c64a3263339$export$2e2bcd8739ae039 {\n static calculateFinalState(element) {\n let finals = {};\n const margin = (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).margin;\n const nw = element.naturalWidth;\n const nh = element.naturalHeight;\n const ratio = nw / nh;\n const ww = window.innerWidth - 2 * margin;\n const wh = window.innerHeight - 2 * margin;\n // size image based on width first\n finals.width = nw > ww ? ww : nw;\n finals.height = nw > ww ? ww / ratio : nh;\n // if height is too big, adjust based on height\n if (finals.height > wh) {\n finals.height = wh;\n finals.width = wh * ratio;\n }\n finals.top = (wh - finals.height) / 2 + window.scrollY + margin + (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).offset.y;\n finals.left = (ww - finals.width) / 2 + window.scrollX + margin + (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).offset.x;\n return finals;\n }\n static transformMatrix(element, starts, finals) {\n // Calculate scaling factors based on width and height interpolation\n const scaleX = finals.width / starts.width;\n const scaleY = finals.height / starts.height;\n // Calculate the center of the starting and final positions\n const startCenterX = starts.left + starts.width / 2;\n const startCenterY = starts.top + starts.height / 2;\n const finalCenterX = finals.left + finals.width / 2;\n const finalCenterY = finals.top + finals.height / 2;\n const translateX = finalCenterX - startCenterX;\n const translateY = finalCenterY - startCenterY;\n // Apply the transform with matrix (scale + translate)\n element.style.transform = `matrix(${scaleX}, 0, 0, ${scaleY}, ${translateX}, ${translateY})`;\n }\n static resetTransformMatrix(element) {\n element.style.transform = `matrix(1, 0, 0, 1, 0, 0)`;\n }\n}\n\n\n\nclass $2f427fc7e1c3703f$export$2e2bcd8739ae039 {\n isOpen = false;\n /**\n * ============\n * Constructors\n * ============\n */ constructor(image){\n this.original = image;\n this.fetchOriginalPosition();\n this.create(image);\n return this;\n }\n create(image) {\n // create shadow image\n const shadow = document.createElement('img');\n shadow.src = image.src;\n shadow.id = `libra-shadow-${image.id}`;\n shadow.classList.add('libra-shadow');\n shadow.style.transitionDuration = (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).transitionDuration + 'ms';\n this.element = shadow;\n // set positioning and place shadow element\n this.positionShadow();\n this.placeItself();\n }\n fetchOriginalPosition() {\n const rect = this.original.getBoundingClientRect();\n this.originalPosition = {\n top: rect.top + window.scrollY + (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).offset.y,\n left: rect.left + window.scrollX + (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).offset.x,\n width: rect.width,\n height: rect.height\n };\n }\n positionShadow() {\n this.element.style.top = this.originalPosition.top + 'px';\n this.element.style.left = this.originalPosition.left + 'px';\n this.element.style.width = this.originalPosition.width + 'px';\n this.element.style.height = this.originalPosition.height + 'px';\n }\n /**\n * ============\n * Actions\n * ============\n */ open() {\n this.isOpen = true;\n this.element.classList.add('open');\n // Update original position before animation in case viewport changed\n this.fetchOriginalPosition();\n this.positionShadow();\n this.original.style.visibility = 'hidden';\n if (!document.body.contains(this.element)) this.placeItself();\n // play animation\n const animate = ()=>(0, $6e8e6c64a3263339$export$2e2bcd8739ae039).transformMatrix(this.element, this.originalPosition, (0, $6e8e6c64a3263339$export$2e2bcd8739ae039).calculateFinalState(this.element));\n if (this.element.naturalWidth === 0 || this.element.naturalHeight === 0) // Wait for image to load before animating\n this.element.addEventListener('load', animate, {\n once: true\n });\n else // animate directly if loaded\n animate();\n }\n close() {\n this.isOpen = false;\n this.element.classList.remove('open');\n (0, $6e8e6c64a3263339$export$2e2bcd8739ae039).resetTransformMatrix(this.element);\n // Wait for animation to complete before showing original and destroying shadow\n setTimeout(()=>{\n this.original.style.visibility = 'visible';\n this.destroyItself();\n }, (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).transitionDuration);\n }\n placeItself() {\n document.body.appendChild(this.element);\n }\n destroyItself() {\n if (!document.body.contains(this.element)) return;\n document.body.removeChild(this.element);\n }\n}\n\n\n\nclass $e220af4964903f87$export$2e2bcd8739ae039 {\n currentImage = null;\n shadows = {};\n /**\n * ============\n * Initializers\n * ============\n */ constructor(config){\n (0, $0c04c0cc2b6985d8$export$940a7873bb071df8)(config);\n this.initOverlay();\n this.initImages();\n this.initControls();\n }\n initOverlay() {\n this.overlay = new (0, $e49d13fc7942bae1$export$2e2bcd8739ae039)();\n this.overlay.element.addEventListener('click', ()=>{\n this.closeCurrent();\n });\n }\n initImages() {\n this.images = document.querySelectorAll((0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).selector);\n this.images.forEach((image)=>{\n if (image.tagName !== 'IMG') return;\n image.id = crypto.randomUUID(); // generate unique id for each image\n image.style.cursor = (0, $0c04c0cc2b6985d8$export$2e2bcd8739ae039).imageCursor;\n image.addEventListener('click', ()=>this.open(image)); // click image to open lightbox\n });\n }\n initControls() {\n // keyboard shortcuts\n document.addEventListener('keydown', (e)=>{\n if (e.key === 'Escape' || e.key === ' ') this.closeCurrent();\n });\n // scroll to dismiss\n document.body.addEventListener('wheel', (e)=>this.closeCurrent());\n document.body.addEventListener('touchmove', (e)=>this.closeCurrent());\n }\n /**\n * ============\n * Actions\n * ============\n */ // open lightbox = open shadow + show overlay\n open(image) {\n this.currentImage = image;\n const shadow = this.shadows[image.id] || new (0, $2f427fc7e1c3703f$export$2e2bcd8739ae039)(image);\n if (!this.shadows[image.id]) this.shadows[image.id] = shadow;\n shadow.open();\n this.overlay.show();\n }\n // close lightbox = remove shadow + hide overlay\n close(image) {\n this.currentImage = null;\n if (!this.shadows[image.id]) return;\n this.shadows[image.id].close();\n this.overlay.hide();\n }\n closeCurrent() {\n if (!this.currentImage) return;\n this.close(this.currentImage);\n }\n}\n\n\nexport {$e220af4964903f87$export$2e2bcd8739ae039 as default};\n//# sourceMappingURL=libra.min.js.map\n","import Overlay from './overlay';\nimport Shadow from './shadow';\nimport config from './config';\nimport { setConfig } from './config';\n\nexport default class LightBox {\n currentImage = null;\n shadows = {};\n\n /**\n * ============\n * Initializers\n * ============\n */\n\n constructor(config) {\n setConfig(config);\n\n this.initOverlay();\n this.initImages();\n this.initControls();\n }\n\n initOverlay() {\n this.overlay = new Overlay();\n this.overlay.element.addEventListener('click', () => {\n this.closeCurrent();\n });\n }\n\n initImages() {\n this.images = document.querySelectorAll(config.selector);\n this.images.forEach(image => {\n if (image.tagName !== 'IMG') return;\n image.id = crypto.randomUUID(); // generate unique id for each image\n image.style.cursor = config.imageCursor;\n image.addEventListener('click', () => this.open(image)); // click image to open lightbox\n });\n }\n\n initControls() {\n // keyboard shortcuts\n document.addEventListener('keydown', e => {\n if (e.key === 'Escape' || e.key === ' ')\n this.closeCurrent();\n });\n // scroll to dismiss\n document.body.addEventListener('wheel', e => this.closeCurrent());\n document.body.addEventListener('touchmove', e => this.closeCurrent());\n }\n\n /**\n * ============\n * Actions\n * ============\n */\n\n // open lightbox = open shadow + show overlay\n open(image) {\n this.currentImage = image;\n\n const shadow = this.shadows[image.id] || new Shadow(image);\n if (!this.shadows[image.id]) {\n this.shadows[image.id] = shadow;\n }\n\n shadow.open();\n this.overlay.show();\n }\n\n // close lightbox = remove shadow + hide overlay\n close(image) {\n this.currentImage = null;\n\n if (!this.shadows[image.id]) return;\n this.shadows[image.id].close();\n\n this.overlay.hide();\n }\n\n closeCurrent() {\n if (!this.currentImage) return;\n this.close(this.currentImage);\n }\n}\n","import config from './config';\n\nexport default class Overlay {\n constructor() {\n const overlay = document.createElement('div');\n overlay.id = 'libra-overlay';\n overlay.classList.add('libra-overlay', 'libra-hidden');\n\n // Set transition duration from config\n overlay.style.transitionDuration = config.transitionDuration + 'ms';\n\n this.element = overlay;\n document.body.appendChild(overlay);\n\n return this;\n }\n\n show() {\n this.element.classList.remove('libra-hidden');\n this.element.classList.add('libra-visible');\n }\n\n hide() {\n this.element.classList.remove('libra-visible');\n this.element.classList.add('libra-hidden');\n }\n}\n","const config = {\n selector: '[data-libra]',\n margin: 50,\n offset: { x: 0, y: 0 },\n transitionDuration: 200, // milliseconds\n imageCursor: 'zoom-in',\n};\n\nfunction deepMerge(target, source) {\n for (const key in source) {\n if (\n typeof source[key] === 'object' &&\n source[key] !== null &&\n !Array.isArray(source[key])\n ) {\n if (!target[key]) target[key] = {};\n deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n return target;\n}\n\nexport function setConfig(newConfig) {\n deepMerge(config, newConfig);\n}\n\nexport default config;\n","import Animation from './animation.js'\nimport config from './config'\n\nexport default class Shadow {\n isOpen = false;\n\n /**\n * ============\n * Constructors\n * ============\n */\n\n constructor(image) {\n this.original = image;\n this.fetchOriginalPosition();\n this.create(image);\n\n return this;\n }\n\n create(image) {\n // create shadow image\n const shadow = document.createElement('img');\n shadow.src = image.src;\n shadow.id = `libra-shadow-${image.id}`;\n shadow.classList.add('libra-shadow');\n shadow.style.transitionDuration = config.transitionDuration + 'ms';\n\n this.element = shadow;\n\n // set positioning and place shadow element\n this.positionShadow();\n this.placeItself();\n }\n\n fetchOriginalPosition() {\n const rect = this.original.getBoundingClientRect();\n this.originalPosition = {\n top: rect.top + window.scrollY + config.offset.y,\n left: rect.left + window.scrollX + config.offset.x,\n width: rect.width,\n height: rect.height,\n };\n }\n\n positionShadow() {\n this.element.style.top = this.originalPosition.top + 'px';\n this.element.style.left = this.originalPosition.left + 'px';\n this.element.style.width = this.originalPosition.width + 'px';\n this.element.style.height = this.originalPosition.height + 'px';\n }\n\n /**\n * ============\n * Actions\n * ============\n */\n\n open() {\n this.isOpen = true;\n this.element.classList.add('open');\n\n // Update original position before animation in case viewport changed\n this.fetchOriginalPosition();\n this.positionShadow();\n\n this.original.style.visibility = 'hidden';\n if (!document.body.contains(this.element)) this.placeItself();\n\n // play animation\n const animate = () =>\n Animation.transformMatrix(\n this.element,\n this.originalPosition,\n Animation.calculateFinalState(this.element),\n );\n\n if (this.element.naturalWidth === 0 || this.element.naturalHeight === 0) {\n // Wait for image to load before animating\n this.element.addEventListener('load', animate, { once: true });\n } else {\n // animate directly if loaded\n animate();\n }\n }\n\n close() {\n this.isOpen = false;\n this.element.classList.remove('open');\n\n Animation.resetTransformMatrix(this.element);\n // Wait for animation to complete before showing original and destroying shadow\n setTimeout(() => {\n this.original.style.visibility = 'visible';\n this.destroyItself();\n }, config.transitionDuration);\n }\n\n placeItself() {\n document.body.appendChild(this.element);\n }\n\n destroyItself() {\n if (!document.body.contains(this.element)) return;\n document.body.removeChild(this.element);\n }\n}\n","import config from './config';\n\nexport default class Animation {\n static calculateFinalState(element) {\n let finals = {}\n\n const margin = config.margin;\n const nw = element.naturalWidth;\n const nh = element.naturalHeight;\n const ratio = nw / nh;\n const ww = window.innerWidth - 2*margin;\n const wh = window.innerHeight - 2*margin;\n\n // size image based on width first\n finals.width = (nw > ww) ? ww : nw;\n finals.height = (nw > ww) ? ww / ratio : nh;\n\n // if height is too big, adjust based on height\n if (finals.height > wh) {\n finals.height = wh;\n finals.width = wh * ratio;\n }\n\n finals.top = (wh - finals.height) / 2 + window.scrollY + margin + config.offset.y;\n finals.left = (ww - finals.width) / 2 + window.scrollX + margin + config.offset.x;\n\n return finals;\n }\n\n static transformMatrix(element, starts, finals) {\n // Calculate scaling factors based on width and height interpolation\n const scaleX = finals.width / starts.width;\n const scaleY = finals.height / starts.height;\n\n // Calculate the center of the starting and final positions\n const startCenterX = starts.left + starts.width / 2;\n const startCenterY = starts.top + starts.height / 2;\n const finalCenterX = finals.left + finals.width / 2;\n const finalCenterY = finals.top + finals.height / 2;\n\n const translateX = finalCenterX - startCenterX;\n const translateY = finalCenterY - startCenterY;\n\n // Apply the transform with matrix (scale + translate)\n element.style.transform = `matrix(${scaleX}, 0, 0, ${scaleY}, ${translateX}, ${translateY})`;\n }\n\n static resetTransformMatrix(element) {\n element.style.transform = `matrix(1, 0, 0, 1, 0, 0)`;\n }\n}\n"],"names":["$0c04c0cc2b6985d8$var$config","selector","margin","offset","x","y","transitionDuration","imageCursor","$e49d13fc7942bae1$export$2e2bcd8739ae039","overlay","document","createElement","id","classList","add","style","element","body","appendChild","show","remove","hide","$6e8e6c64a3263339$export$2e2bcd8739ae039","calculateFinalState","finals","nw","naturalWidth","nh","naturalHeight","ratio","ww","window","innerWidth","wh","innerHeight","width","height","top","scrollY","left","scrollX","transformMatrix","starts","scaleX","scaleY","startCenterX","startCenterY","finalCenterX","finalCenterY","transform","resetTransformMatrix","$2f427fc7e1c3703f$export$2e2bcd8739ae039","isOpen","image","original","fetchOriginalPosition","create","shadow","src","positionShadow","placeItself","rect","getBoundingClientRect","originalPosition","open","visibility","contains","animate","addEventListener","once","close","setTimeout","destroyItself","removeChild","$e220af4964903f87$export$2e2bcd8739ae039","currentImage","shadows","config","$0c04c0cc2b6985d8$var$deepMerge","target","source","key","Array","isArray","initOverlay","initImages","initControls","closeCurrent","images","querySelectorAll","forEach","tagName","crypto","randomUUID","cursor","e","default"],"version":3,"file":"libra.min.js.map"} \ No newline at end of file