@expressivecss/expressive 0.9.1 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +184 -1
- package/README.md +178 -25
- package/dist/css/expressive.css +428 -1222
- package/dist/css/expressive.css.map +1 -1
- package/dist/css/expressive.min.css +1 -1
- package/dist/css/expressive.min.css.map +1 -1
- package/dist/fonts/material-symbols-outlined.woff2 +0 -0
- package/dist/fonts/material-symbols-rounded.woff2 +0 -0
- package/dist/fonts/material-symbols-sharp.woff2 +0 -0
- package/dist/js/chunks/chunk-7MM4VJJO.mjs +509 -0
- package/dist/js/chunks/chunk-7MM4VJJO.mjs.map +7 -0
- package/dist/js/chunks/chunk-7UXHSYIA.mjs +183 -0
- package/dist/js/chunks/chunk-7UXHSYIA.mjs.map +7 -0
- package/dist/js/chunks/chunk-A3BJA7V4.mjs +28 -0
- package/dist/js/chunks/chunk-A3BJA7V4.mjs.map +7 -0
- package/dist/js/chunks/chunk-AOGFNMXS.mjs +691 -0
- package/dist/js/chunks/chunk-AOGFNMXS.mjs.map +7 -0
- package/dist/js/chunks/chunk-D4UZ4HFN.mjs +560 -0
- package/dist/js/chunks/chunk-D4UZ4HFN.mjs.map +7 -0
- package/dist/js/chunks/chunk-EP3CVKB5.mjs +88 -0
- package/dist/js/chunks/chunk-EP3CVKB5.mjs.map +7 -0
- package/dist/js/chunks/chunk-G576EP5O.mjs +459 -0
- package/dist/js/chunks/chunk-G576EP5O.mjs.map +7 -0
- package/dist/js/chunks/chunk-GY2Z5CJ2.mjs +320 -0
- package/dist/js/chunks/chunk-GY2Z5CJ2.mjs.map +7 -0
- package/dist/js/chunks/chunk-JKNPQQWY.mjs +191 -0
- package/dist/js/chunks/chunk-JKNPQQWY.mjs.map +7 -0
- package/dist/js/chunks/chunk-JNPIWFJT.mjs +365 -0
- package/dist/js/chunks/chunk-JNPIWFJT.mjs.map +7 -0
- package/dist/js/chunks/chunk-JODJAGFS.mjs +267 -0
- package/dist/js/chunks/chunk-JODJAGFS.mjs.map +7 -0
- package/dist/js/chunks/chunk-JR24UB4X.mjs +100 -0
- package/dist/js/chunks/chunk-JR24UB4X.mjs.map +7 -0
- package/dist/js/chunks/chunk-KR44BSYQ.mjs +55 -0
- package/dist/js/chunks/chunk-KR44BSYQ.mjs.map +7 -0
- package/dist/js/chunks/chunk-LZVBJ33S.mjs +102 -0
- package/dist/js/chunks/chunk-LZVBJ33S.mjs.map +7 -0
- package/dist/js/chunks/chunk-MISGHDUU.mjs +326 -0
- package/dist/js/chunks/chunk-MISGHDUU.mjs.map +7 -0
- package/dist/js/chunks/chunk-N3UHGN3N.mjs +175 -0
- package/dist/js/chunks/chunk-N3UHGN3N.mjs.map +7 -0
- package/dist/js/chunks/chunk-PIIAEYAJ.mjs +85 -0
- package/dist/js/chunks/chunk-PIIAEYAJ.mjs.map +7 -0
- package/dist/js/chunks/chunk-QSQ24FYT.mjs +59 -0
- package/dist/js/chunks/chunk-QSQ24FYT.mjs.map +7 -0
- package/dist/js/chunks/chunk-QYCYP443.mjs +1111 -0
- package/dist/js/chunks/chunk-QYCYP443.mjs.map +7 -0
- package/dist/js/chunks/chunk-SLFNPY5M.mjs +78 -0
- package/dist/js/chunks/chunk-SLFNPY5M.mjs.map +7 -0
- package/dist/js/chunks/chunk-TK6PX2GC.mjs +663 -0
- package/dist/js/chunks/chunk-TK6PX2GC.mjs.map +7 -0
- package/dist/js/chunks/chunk-TYM6U5DY.mjs +76 -0
- package/dist/js/chunks/chunk-TYM6U5DY.mjs.map +7 -0
- package/dist/js/chunks/chunk-TZZ24ZQS.mjs +154 -0
- package/dist/js/chunks/chunk-TZZ24ZQS.mjs.map +7 -0
- package/dist/js/chunks/chunk-VAS6JQ6P.mjs +94 -0
- package/dist/js/chunks/chunk-VAS6JQ6P.mjs.map +7 -0
- package/dist/js/chunks/chunk-WWPAPHMA.mjs +1 -0
- package/dist/js/chunks/chunk-WWPAPHMA.mjs.map +7 -0
- package/dist/js/chunks/chunk-XDB3G6RL.mjs +114 -0
- package/dist/js/chunks/chunk-XDB3G6RL.mjs.map +7 -0
- package/dist/js/chunks/chunk-XO5WX3TK.mjs +226 -0
- package/dist/js/chunks/chunk-XO5WX3TK.mjs.map +7 -0
- package/dist/js/chunks/chunk-YFXEJ7GR.mjs +286 -0
- package/dist/js/chunks/chunk-YFXEJ7GR.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZAOYQ6SY.mjs +7 -0
- package/dist/js/chunks/chunk-ZAOYQ6SY.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZIZVUWRL.mjs +120 -0
- package/dist/js/chunks/chunk-ZIZVUWRL.mjs.map +7 -0
- package/dist/js/chunks/chunk-ZZBZI2XN.mjs +338 -0
- package/dist/js/chunks/chunk-ZZBZI2XN.mjs.map +7 -0
- package/dist/js/expressive.cjs +747 -754
- package/dist/js/expressive.cjs.map +4 -4
- package/dist/js/expressive.js +747 -754
- package/dist/js/expressive.js.map +4 -4
- package/dist/js/expressive.min.js +11 -15
- package/dist/js/expressive.min.js.map +4 -4
- package/dist/js/expressive.mjs +83 -7490
- package/dist/js/expressive.mjs.map +4 -4
- package/dist/js/internal/behaviors/bottomSheets.mjs +9 -0
- package/dist/js/internal/behaviors/bottomSheets.mjs.map +7 -0
- package/dist/js/internal/behaviors/dialogs.mjs +8 -0
- package/dist/js/internal/behaviors/dialogs.mjs.map +7 -0
- package/dist/js/internal/behaviors/forms.mjs +8 -0
- package/dist/js/internal/behaviors/forms.mjs.map +7 -0
- package/dist/js/internal/behaviors/sheetDrag.mjs +8 -0
- package/dist/js/internal/behaviors/sheetDrag.mjs.map +7 -0
- package/dist/js/internal/behaviors/sideSheets.mjs +9 -0
- package/dist/js/internal/behaviors/sideSheets.mjs.map +7 -0
- package/dist/js/internal/components/appBar.mjs +8 -0
- package/dist/js/internal/components/appBar.mjs.map +7 -0
- package/dist/js/internal/components/autocomplete.mjs +10 -0
- package/dist/js/internal/components/autocomplete.mjs.map +7 -0
- package/dist/js/internal/components/buttonGroup.mjs +8 -0
- package/dist/js/internal/components/buttonGroup.mjs.map +7 -0
- package/dist/js/internal/components/buttons.mjs +9 -0
- package/dist/js/internal/components/buttons.mjs.map +7 -0
- package/dist/js/internal/components/cards.mjs +13 -0
- package/dist/js/internal/components/cards.mjs.map +7 -0
- package/dist/js/internal/components/carousel.mjs +9 -0
- package/dist/js/internal/components/carousel.mjs.map +7 -0
- package/dist/js/internal/components/characterCounter.mjs +8 -0
- package/dist/js/internal/components/characterCounter.mjs.map +7 -0
- package/dist/js/internal/components/chips.mjs +11 -0
- package/dist/js/internal/components/chips.mjs.map +7 -0
- package/dist/js/internal/components/datepicker.mjs +12 -0
- package/dist/js/internal/components/datepicker.mjs.map +7 -0
- package/dist/js/internal/components/expandingCard.mjs +11 -0
- package/dist/js/internal/components/expandingCard.mjs.map +7 -0
- package/dist/js/internal/components/index.mjs +88 -0
- package/dist/js/internal/components/index.mjs.map +7 -0
- package/dist/js/internal/components/lightbox.mjs +9 -0
- package/dist/js/internal/components/lightbox.mjs.map +7 -0
- package/dist/js/internal/components/menu.mjs +9 -0
- package/dist/js/internal/components/menu.mjs.map +7 -0
- package/dist/js/internal/components/navigationRail.mjs +8 -0
- package/dist/js/internal/components/navigationRail.mjs.map +7 -0
- package/dist/js/internal/components/registry.mjs +33 -0
- package/dist/js/internal/components/registry.mjs.map +7 -0
- package/dist/js/internal/components/scrollspy.mjs +8 -0
- package/dist/js/internal/components/scrollspy.mjs.map +7 -0
- package/dist/js/internal/components/select.mjs +10 -0
- package/dist/js/internal/components/select.mjs.map +7 -0
- package/dist/js/internal/components/slider.mjs +9 -0
- package/dist/js/internal/components/slider.mjs.map +7 -0
- package/dist/js/internal/components/snackbar.mjs +8 -0
- package/dist/js/internal/components/snackbar.mjs.map +7 -0
- package/dist/js/internal/components/tabs.mjs +10 -0
- package/dist/js/internal/components/tabs.mjs.map +7 -0
- package/dist/js/internal/components/timepicker.mjs +10 -0
- package/dist/js/internal/components/timepicker.mjs.map +7 -0
- package/dist/js/internal/components/tooltip.mjs +9 -0
- package/dist/js/internal/components/tooltip.mjs.map +7 -0
- package/dist/js/internal/core/component.mjs +7 -0
- package/dist/js/internal/core/component.mjs.map +7 -0
- package/dist/js/internal/core/utils.mjs +7 -0
- package/dist/js/internal/core/utils.mjs.map +7 -0
- package/dist/js/internal/plugins/dockedDisplayPlugin.mjs +8 -0
- package/dist/js/internal/plugins/dockedDisplayPlugin.mjs.map +7 -0
- package/dist/js/modular.mjs +113 -0
- package/dist/js/modular.mjs.map +7 -0
- package/dist/types/behaviors/sheetDrag.d.ts +1 -1
- package/dist/types/components/appBar.d.ts +1 -1
- package/dist/types/components/autocomplete.d.ts +9 -0
- package/dist/types/components/buttons.d.ts +4 -39
- package/dist/types/components/carousel.d.ts +10 -1
- package/dist/types/components/chips.d.ts +1 -0
- package/dist/types/components/datepicker.d.ts +7 -0
- package/dist/types/components/index.d.ts +0 -2
- package/dist/types/components/lightbox.d.ts +12 -0
- package/dist/types/components/menu.d.ts +3 -0
- package/dist/types/components/registry.d.ts +0 -4
- package/dist/types/components/select.d.ts +4 -0
- package/dist/types/components/slider.d.ts +2 -1
- package/dist/types/components/snackbar.d.ts +4 -2
- package/dist/types/components/tabs.d.ts +2 -1
- package/dist/types/components/timepicker.d.ts +5 -3
- package/dist/types/components/tooltip.d.ts +5 -3
- package/dist/types/index.d.ts +1 -8
- package/dist/types/modular.d.ts +28 -0
- package/package.json +16 -4
- package/src/sass/README.md +8 -0
- package/src/sass/components/_badges.scss +1 -6
- package/src/sass/components/_button-groups.scss +5 -1
- package/src/sass/components/_buttons.scss +8 -287
- package/src/sass/components/_chips.scss +17 -2
- package/src/sass/components/_dialog.scss +9 -4
- package/src/sass/components/_fab-menu.scss +11 -9
- package/src/sass/components/_icon-buttons.scss +0 -5
- package/src/sass/components/_index.scss +0 -5
- package/src/sass/components/_menu.scss +2 -2
- package/src/sass/components/_navigation-rail.scss +1 -1
- package/src/sass/components/_panes.scss +50 -78
- package/src/sass/components/_progress.scss +73 -13
- package/src/sass/components/_scrim.scss +4 -4
- package/src/sass/components/_side-sheet.scss +22 -12
- package/src/sass/components/_toolbar.scss +1 -4
- package/src/sass/components/_tooltip.scss +20 -2
- package/src/sass/components/forms/_input-fields.scss +5 -1
- package/src/sass/components/forms/_select.scss +1 -0
- package/src/sass/components/forms/_slider.scss +81 -25
- package/src/sass/custom.scss +38 -0
- package/src/sass/utilities/_helpers.scss +18 -0
- package/src/sass/utilities/_spacing.scss +8 -1
- package/dist/types/components/navigationDrawer.d.ts +0 -110
- package/src/sass/components/_banners.scss +0 -298
- package/src/sass/components/_bottom-app-bar.scss +0 -180
- package/src/sass/components/_floating-sheet.scss +0 -86
- package/src/sass/components/_navigation-drawer.scss +0 -476
- package/src/sass/components/_segmented-buttons.scss +0 -188
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Utils
|
|
3
|
+
} from "./chunk-MISGHDUU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Component
|
|
6
|
+
} from "./chunk-QSQ24FYT.mjs";
|
|
7
|
+
|
|
8
|
+
// src/ts/components/lightbox.ts
|
|
9
|
+
var _defaults = {
|
|
10
|
+
inDuration: 275,
|
|
11
|
+
outDuration: 200,
|
|
12
|
+
onOpenStart: null,
|
|
13
|
+
onOpenEnd: null,
|
|
14
|
+
onCloseStart: null,
|
|
15
|
+
onCloseEnd: null
|
|
16
|
+
};
|
|
17
|
+
var _Lightbox = class _Lightbox extends Component {
|
|
18
|
+
constructor(el, options) {
|
|
19
|
+
super(el, options, _Lightbox);
|
|
20
|
+
/** Ancestors forced to `overflow: visible`, with the inline value to put back. */
|
|
21
|
+
this._changedAncestorList = [];
|
|
22
|
+
this._timers = /* @__PURE__ */ new Map();
|
|
23
|
+
this._motion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
24
|
+
this._isOpen = false;
|
|
25
|
+
this._destroyed = false;
|
|
26
|
+
this._revision = 0;
|
|
27
|
+
this._handleMotionChange = () => {
|
|
28
|
+
if (!this._motion.matches) return;
|
|
29
|
+
const callbacks = [...this._timers.values()];
|
|
30
|
+
const revision = this._cancel();
|
|
31
|
+
for (const callback of callbacks) {
|
|
32
|
+
if (revision !== this._revision) break;
|
|
33
|
+
callback();
|
|
34
|
+
}
|
|
35
|
+
if (this.overlayActive) {
|
|
36
|
+
for (const el of [this.el, this._overlay, this._photoCaption]) if (el) el.style.transition = "none";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
this._handleLightboxClick = () => {
|
|
40
|
+
this._handleLightboxToggle();
|
|
41
|
+
};
|
|
42
|
+
this._handleLightboxKeypress = (e) => {
|
|
43
|
+
if (this._trigger === this.el && (e.key === Utils.keys.ENTER || e.key === " ")) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
this._handleLightboxToggle();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this._handleLightboxToggle = () => {
|
|
49
|
+
if (this._isOpen) this.close();
|
|
50
|
+
else this.open();
|
|
51
|
+
};
|
|
52
|
+
this._handleWindowScroll = () => {
|
|
53
|
+
if (this.overlayActive) this.close();
|
|
54
|
+
};
|
|
55
|
+
this._handleWindowResize = () => {
|
|
56
|
+
if (this.overlayActive) this.close();
|
|
57
|
+
};
|
|
58
|
+
this._handleWindowEscape = (e) => {
|
|
59
|
+
if (e.key === Utils.keys.ESC) this.close();
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Open lightbox.
|
|
63
|
+
*/
|
|
64
|
+
this.open = () => {
|
|
65
|
+
if (this._destroyed || this._isOpen) return;
|
|
66
|
+
const revision = this._cancel();
|
|
67
|
+
if (this.overlayActive) this._reset();
|
|
68
|
+
this._isOpen = true;
|
|
69
|
+
this._updateVars();
|
|
70
|
+
const originRect = this.el.getBoundingClientRect();
|
|
71
|
+
const placeholderRect = this.placeholder.getBoundingClientRect();
|
|
72
|
+
this.originalWidth = originRect.width;
|
|
73
|
+
this.originalHeight = originRect.height;
|
|
74
|
+
this.doneAnimating = false;
|
|
75
|
+
this.el.classList.add("active");
|
|
76
|
+
this.overlayActive = true;
|
|
77
|
+
if (typeof this.options.onOpenStart === "function")
|
|
78
|
+
this.options.onOpenStart.call(this, this.el);
|
|
79
|
+
if (revision !== this._revision) return;
|
|
80
|
+
this.placeholder.style.width = placeholderRect.width + "px";
|
|
81
|
+
this.placeholder.style.height = placeholderRect.height + "px";
|
|
82
|
+
this.placeholder.style.position = "relative";
|
|
83
|
+
this.placeholder.style.top = "0";
|
|
84
|
+
this.placeholder.style.left = "0";
|
|
85
|
+
this._makeAncestorsOverflowVisible();
|
|
86
|
+
this.el.style.position = "absolute";
|
|
87
|
+
this.el.style.zIndex = "1000";
|
|
88
|
+
this.el.style.willChange = "left, top, width, height";
|
|
89
|
+
this.attrWidth = this.el.getAttribute("width");
|
|
90
|
+
this.attrHeight = this.el.getAttribute("height");
|
|
91
|
+
if (this.attrWidth) {
|
|
92
|
+
this.el.style.width = this.attrWidth + "px";
|
|
93
|
+
this.el.removeAttribute("width");
|
|
94
|
+
}
|
|
95
|
+
if (this.attrHeight) {
|
|
96
|
+
this.el.style.height = this.attrHeight + "px";
|
|
97
|
+
this.el.removeAttribute("height");
|
|
98
|
+
}
|
|
99
|
+
this._addOverlay();
|
|
100
|
+
if (this.caption !== "") this._addCaption();
|
|
101
|
+
const widthPercent = this.originalWidth / this.windowWidth;
|
|
102
|
+
const heightPercent = this.originalHeight / this.windowHeight;
|
|
103
|
+
this.newWidth = 0;
|
|
104
|
+
this.newHeight = 0;
|
|
105
|
+
if (widthPercent > heightPercent) {
|
|
106
|
+
const ratio = this.originalHeight / this.originalWidth;
|
|
107
|
+
this.newWidth = this.windowWidth * 0.9;
|
|
108
|
+
this.newHeight = this.windowWidth * 0.9 * ratio;
|
|
109
|
+
} else {
|
|
110
|
+
const ratio = this.originalWidth / this.originalHeight;
|
|
111
|
+
this.newWidth = this.windowHeight * 0.9 * ratio;
|
|
112
|
+
this.newHeight = this.windowHeight * 0.9;
|
|
113
|
+
}
|
|
114
|
+
window.addEventListener("scroll", this._handleWindowScroll, { passive: true });
|
|
115
|
+
window.addEventListener("resize", this._handleWindowResize, { passive: true });
|
|
116
|
+
window.addEventListener("keyup", this._handleWindowEscape);
|
|
117
|
+
this._animateImageIn();
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Close lightbox.
|
|
121
|
+
*/
|
|
122
|
+
this.close = () => {
|
|
123
|
+
if (this._destroyed || !this._isOpen) return;
|
|
124
|
+
const revision = this._cancel();
|
|
125
|
+
this._isOpen = false;
|
|
126
|
+
this.doneAnimating = false;
|
|
127
|
+
if (typeof this.options.onCloseStart === "function")
|
|
128
|
+
this.options.onCloseStart.call(this, this.el);
|
|
129
|
+
if (revision !== this._revision) return;
|
|
130
|
+
window.removeEventListener("scroll", this._handleWindowScroll);
|
|
131
|
+
window.removeEventListener("resize", this._handleWindowResize);
|
|
132
|
+
window.removeEventListener("keyup", this._handleWindowEscape);
|
|
133
|
+
if (this._overlay) this._removeOverlay();
|
|
134
|
+
if (this._photoCaption) this._removeCaption();
|
|
135
|
+
this._animateImageOut();
|
|
136
|
+
};
|
|
137
|
+
this.el["Expressive_Lightbox"] = this;
|
|
138
|
+
this.options = {
|
|
139
|
+
..._Lightbox.defaults,
|
|
140
|
+
...options
|
|
141
|
+
};
|
|
142
|
+
this.overlayActive = false;
|
|
143
|
+
this.doneAnimating = true;
|
|
144
|
+
this.placeholder = document.createElement("div");
|
|
145
|
+
this.placeholder.classList.add("material-placeholder");
|
|
146
|
+
this.originalWidth = 0;
|
|
147
|
+
this.originalHeight = 0;
|
|
148
|
+
this.originInlineStyles = this.el.getAttribute("style");
|
|
149
|
+
this.caption = this.el.getAttribute("data-caption") || "";
|
|
150
|
+
this._tabindex = this.el.getAttribute("tabindex");
|
|
151
|
+
this._trigger = this.el.closest("button") ?? this.el;
|
|
152
|
+
this.el.tabIndex = this._trigger === this.el ? 0 : -1;
|
|
153
|
+
this.el.before(this.placeholder);
|
|
154
|
+
this.placeholder.append(this.el);
|
|
155
|
+
this._setupEventHandlers();
|
|
156
|
+
}
|
|
157
|
+
static get defaults() {
|
|
158
|
+
return _defaults;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Initializes instances of Lightbox.
|
|
162
|
+
* @param els HTML elements.
|
|
163
|
+
* @param options Component options.
|
|
164
|
+
*/
|
|
165
|
+
static init(els, options = {}) {
|
|
166
|
+
return super.init(els, options, _Lightbox);
|
|
167
|
+
}
|
|
168
|
+
static getInstance(el) {
|
|
169
|
+
return el["Expressive_Lightbox"];
|
|
170
|
+
}
|
|
171
|
+
destroy() {
|
|
172
|
+
if (this._destroyed) return;
|
|
173
|
+
this._destroyed = true;
|
|
174
|
+
const root = this.el.getRootNode();
|
|
175
|
+
const focused = root.activeElement === this.el;
|
|
176
|
+
this._removeEventHandlers();
|
|
177
|
+
this._cancel();
|
|
178
|
+
this._reset();
|
|
179
|
+
this.placeholder.replaceWith(this.el);
|
|
180
|
+
let active = document.activeElement;
|
|
181
|
+
while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
|
|
182
|
+
if (focused && (active === document.body || active === root.host)) this._trigger.focus();
|
|
183
|
+
if (this._tabindex === null) this.el.removeAttribute("tabindex");
|
|
184
|
+
else this.el.setAttribute("tabindex", this._tabindex);
|
|
185
|
+
this.el["Expressive_Lightbox"] = void 0;
|
|
186
|
+
}
|
|
187
|
+
_reset() {
|
|
188
|
+
window.removeEventListener("scroll", this._handleWindowScroll);
|
|
189
|
+
window.removeEventListener("resize", this._handleWindowResize);
|
|
190
|
+
window.removeEventListener("keyup", this._handleWindowEscape);
|
|
191
|
+
this._overlay?.remove();
|
|
192
|
+
this._photoCaption?.remove();
|
|
193
|
+
for (const ancestor of this._changedAncestorList) {
|
|
194
|
+
const saved = _Lightbox._overflow.get(ancestor);
|
|
195
|
+
if (--saved.count === 0) {
|
|
196
|
+
ancestor.style.setProperty("overflow", saved.value, saved.priority);
|
|
197
|
+
_Lightbox._overflow.delete(ancestor);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
this._changedAncestorList = [];
|
|
201
|
+
if (this.attrWidth !== null && this.attrWidth !== void 0) this.el.setAttribute("width", this.attrWidth);
|
|
202
|
+
if (this.attrHeight !== null && this.attrHeight !== void 0) this.el.setAttribute("height", this.attrHeight);
|
|
203
|
+
this.el.classList.remove("active");
|
|
204
|
+
this.placeholder.removeAttribute("style");
|
|
205
|
+
if (this.originInlineStyles === null) this.el.removeAttribute("style");
|
|
206
|
+
else this.el.setAttribute("style", this.originInlineStyles);
|
|
207
|
+
this.overlayActive = false;
|
|
208
|
+
this._isOpen = false;
|
|
209
|
+
this.doneAnimating = true;
|
|
210
|
+
}
|
|
211
|
+
_cancel() {
|
|
212
|
+
for (const timer of this._timers.keys()) clearTimeout(timer);
|
|
213
|
+
this._timers.clear();
|
|
214
|
+
return ++this._revision;
|
|
215
|
+
}
|
|
216
|
+
_schedule(callback, delay) {
|
|
217
|
+
if (this._motion.matches) {
|
|
218
|
+
callback();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const timer = setTimeout(() => {
|
|
222
|
+
this._timers.delete(timer);
|
|
223
|
+
callback();
|
|
224
|
+
}, delay);
|
|
225
|
+
this._timers.set(timer, callback);
|
|
226
|
+
}
|
|
227
|
+
_setupEventHandlers() {
|
|
228
|
+
this._motion.addEventListener("change", this._handleMotionChange);
|
|
229
|
+
this._trigger.addEventListener("click", this._handleLightboxClick);
|
|
230
|
+
this.el.addEventListener("keydown", this._handleLightboxKeypress);
|
|
231
|
+
}
|
|
232
|
+
_removeEventHandlers() {
|
|
233
|
+
this._motion.removeEventListener("change", this._handleMotionChange);
|
|
234
|
+
this._trigger.removeEventListener("click", this._handleLightboxClick);
|
|
235
|
+
this.el.removeEventListener("keydown", this._handleLightboxKeypress);
|
|
236
|
+
}
|
|
237
|
+
_makeAncestorsOverflowVisible() {
|
|
238
|
+
this._changedAncestorList = [];
|
|
239
|
+
let ancestor = this.placeholder.parentNode;
|
|
240
|
+
while (ancestor !== null && ancestor !== void 0 && ancestor !== document) {
|
|
241
|
+
const curr = ancestor;
|
|
242
|
+
if (curr.style && (curr.style.overflow !== "visible" || _Lightbox._overflow.has(curr))) {
|
|
243
|
+
const saved = _Lightbox._overflow.get(curr) ?? { count: 0, value: curr.style.overflow, priority: curr.style.getPropertyPriority("overflow") };
|
|
244
|
+
saved.count++;
|
|
245
|
+
_Lightbox._overflow.set(curr, saved);
|
|
246
|
+
this._changedAncestorList.push(curr);
|
|
247
|
+
curr.style.overflow = "visible";
|
|
248
|
+
}
|
|
249
|
+
ancestor = ancestor.parentNode ?? ancestor.host;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
_offset(el) {
|
|
253
|
+
const box = el.getBoundingClientRect();
|
|
254
|
+
const docElem = document.documentElement;
|
|
255
|
+
return {
|
|
256
|
+
top: box.top + window.scrollY - docElem.clientTop,
|
|
257
|
+
left: box.left + window.scrollX - docElem.clientLeft
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
_updateVars() {
|
|
261
|
+
this.windowWidth = window.innerWidth;
|
|
262
|
+
this.windowHeight = window.innerHeight;
|
|
263
|
+
this.caption = this.el.getAttribute("data-caption") || "";
|
|
264
|
+
}
|
|
265
|
+
// Image
|
|
266
|
+
_animateImageIn() {
|
|
267
|
+
this.el.style.maxHeight = this.newHeight.toString() + "px";
|
|
268
|
+
this.el.style.maxWidth = this.newWidth.toString() + "px";
|
|
269
|
+
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
270
|
+
this.el.style.transition = "none";
|
|
271
|
+
this.el.style.height = this.originalHeight + "px";
|
|
272
|
+
this.el.style.width = this.originalWidth + "px";
|
|
273
|
+
this._schedule(() => {
|
|
274
|
+
const placeholderOffset = this._offset(this.placeholder);
|
|
275
|
+
this.el.style.transition = `height ${duration}ms ease,
|
|
276
|
+
width ${duration}ms ease,
|
|
277
|
+
left ${duration}ms ease,
|
|
278
|
+
top ${duration}ms ease
|
|
279
|
+
`;
|
|
280
|
+
this.el.style.height = this.newHeight + "px";
|
|
281
|
+
this.el.style.width = this.newWidth + "px";
|
|
282
|
+
this.el.style.left = Utils.getDocumentScrollLeft() + this.windowWidth / 2 - placeholderOffset.left - this.newWidth / 2 + "px";
|
|
283
|
+
this.el.style.top = Utils.getDocumentScrollTop() + this.windowHeight / 2 - placeholderOffset.top - this.newHeight / 2 + "px";
|
|
284
|
+
}, 1);
|
|
285
|
+
this._schedule(() => {
|
|
286
|
+
this.doneAnimating = true;
|
|
287
|
+
if (typeof this.options.onOpenEnd === "function") this.options.onOpenEnd.call(this, this.el);
|
|
288
|
+
}, duration);
|
|
289
|
+
}
|
|
290
|
+
_animateImageOut() {
|
|
291
|
+
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
292
|
+
this.el.style.transition = `height ${duration}ms ease,
|
|
293
|
+
width ${duration}ms ease,
|
|
294
|
+
left ${duration}ms ease,
|
|
295
|
+
top ${duration}ms ease
|
|
296
|
+
`;
|
|
297
|
+
this.el.style.height = this.originalHeight + "px";
|
|
298
|
+
this.el.style.width = this.originalWidth + "px";
|
|
299
|
+
this.el.style.left = "0";
|
|
300
|
+
this.el.style.top = "0";
|
|
301
|
+
this._schedule(() => {
|
|
302
|
+
this._reset();
|
|
303
|
+
if (typeof this.options.onCloseEnd === "function")
|
|
304
|
+
this.options.onCloseEnd.call(this, this.el);
|
|
305
|
+
}, duration);
|
|
306
|
+
}
|
|
307
|
+
// Caption
|
|
308
|
+
_addCaption() {
|
|
309
|
+
this._photoCaption = document.createElement("div");
|
|
310
|
+
this._photoCaption.classList.add("lightbox-caption");
|
|
311
|
+
this._photoCaption.innerText = this.caption;
|
|
312
|
+
Utils.portalRoot(this.el).append(this._photoCaption);
|
|
313
|
+
this._photoCaption.style.display = "inline";
|
|
314
|
+
this._photoCaption.style.transition = "none";
|
|
315
|
+
this._photoCaption.style.opacity = "0";
|
|
316
|
+
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
317
|
+
this._schedule(() => {
|
|
318
|
+
this._photoCaption.style.transition = `opacity ${duration}ms ease`;
|
|
319
|
+
this._photoCaption.style.opacity = "1";
|
|
320
|
+
}, 1);
|
|
321
|
+
}
|
|
322
|
+
_removeCaption() {
|
|
323
|
+
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
324
|
+
this._photoCaption.style.transition = `opacity ${duration}ms ease`;
|
|
325
|
+
this._photoCaption.style.opacity = "0";
|
|
326
|
+
}
|
|
327
|
+
// Overlay
|
|
328
|
+
_addOverlay() {
|
|
329
|
+
this._overlay = document.createElement("div");
|
|
330
|
+
this._overlay.id = "lightbox-overlay";
|
|
331
|
+
this._overlay.addEventListener(
|
|
332
|
+
"click",
|
|
333
|
+
(event) => {
|
|
334
|
+
event.stopPropagation();
|
|
335
|
+
this.close();
|
|
336
|
+
},
|
|
337
|
+
{ once: true }
|
|
338
|
+
);
|
|
339
|
+
this.el.before(this._overlay);
|
|
340
|
+
const overlayOffset = this._overlay.getBoundingClientRect();
|
|
341
|
+
this._overlay.style.width = this.windowWidth + "px";
|
|
342
|
+
this._overlay.style.height = this.windowHeight + "px";
|
|
343
|
+
this._overlay.style.left = -1 * overlayOffset.left + "px";
|
|
344
|
+
this._overlay.style.top = -1 * overlayOffset.top + "px";
|
|
345
|
+
this._overlay.style.transition = "none";
|
|
346
|
+
this._overlay.style.opacity = "0";
|
|
347
|
+
const duration = this._motion.matches ? 0 : this.options.inDuration;
|
|
348
|
+
this._schedule(() => {
|
|
349
|
+
this._overlay.style.transition = `opacity ${duration}ms ease`;
|
|
350
|
+
this._overlay.style.opacity = "1";
|
|
351
|
+
}, 1);
|
|
352
|
+
}
|
|
353
|
+
_removeOverlay() {
|
|
354
|
+
const duration = this._motion.matches ? 0 : this.options.outDuration;
|
|
355
|
+
this._overlay.style.transition = `opacity ${duration}ms ease`;
|
|
356
|
+
this._overlay.style.opacity = "0";
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
_Lightbox._overflow = /* @__PURE__ */ new WeakMap();
|
|
360
|
+
var Lightbox = _Lightbox;
|
|
361
|
+
|
|
362
|
+
export {
|
|
363
|
+
Lightbox
|
|
364
|
+
};
|
|
365
|
+
//# sourceMappingURL=chunk-JNPIWFJT.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/ts/components/lightbox.ts"],
|
|
4
|
+
"sourcesContent": ["import { Utils } from '../core/utils';\nimport { BaseOptions, Component, InitElements, InitElement } from '../core/component';\n\nexport interface LightboxOptions extends BaseOptions {\n /**\n * Transition in duration in milliseconds.\n * @default 275\n */\n inDuration: number;\n /**\n * Transition out duration in milliseconds.\n * @default 200\n */\n outDuration: number;\n /**\n * Callback function called before lightbox is opened.\n * @default null\n */\n onOpenStart: (el: Element) => void;\n /**\n * Callback function called after lightbox is opened.\n * @default null\n */\n onOpenEnd: (el: Element) => void;\n /**\n * Callback function called before lightbox is closed.\n * @default null\n */\n onCloseStart: (el: Element) => void;\n /**\n * Callback function called after lightbox is closed.\n * @default null\n */\n onCloseEnd: (el: Element) => void;\n}\n\nconst _defaults: LightboxOptions = {\n inDuration: 275,\n outDuration: 200,\n onOpenStart: null,\n onOpenEnd: null,\n onCloseStart: null,\n onCloseEnd: null\n};\n\nexport class Lightbox extends Component<LightboxOptions> {\n /** If the lightbox overlay is showing. */\n overlayActive: boolean;\n /** If the lightbox is no longer being animated. */\n doneAnimating: boolean;\n /** Caption, if specified. */\n caption: string;\n /** Original width of image. */\n originalWidth: number;\n /** Original height of image. */\n originalHeight: number;\n private originInlineStyles: string;\n private placeholder: HTMLElement;\n /** Ancestors forced to `overflow: visible`, with the inline value to put back. */\n private _changedAncestorList: HTMLElement[] = [];\n private static _overflow = new WeakMap<HTMLElement, { count: number; value: string; priority: string }>();\n private newHeight: number;\n private newWidth: number;\n private windowWidth: number;\n private windowHeight: number;\n private attrWidth: string;\n private attrHeight: string;\n private _overlay: HTMLElement;\n private _photoCaption: HTMLElement;\n private _trigger: HTMLElement;\n private _tabindex: string | null;\n private _timers = new Map<ReturnType<typeof setTimeout>, () => void>();\n private _motion = window.matchMedia('(prefers-reduced-motion: reduce)');\n private _isOpen = false;\n private _destroyed = false;\n private _revision = 0;\n\n constructor(el: HTMLElement, options: Partial<LightboxOptions>) {\n super(el, options, Lightbox);\n this.el['Expressive_Lightbox'] = this;\n\n this.options = {\n ...Lightbox.defaults,\n ...options\n };\n\n this.overlayActive = false;\n this.doneAnimating = true;\n this.placeholder = document.createElement('div');\n this.placeholder.classList.add('material-placeholder');\n this.originalWidth = 0;\n this.originalHeight = 0;\n this.originInlineStyles = this.el.getAttribute('style');\n this.caption = this.el.getAttribute('data-caption') || '';\n this._tabindex = this.el.getAttribute('tabindex');\n this._trigger = this.el.closest('button') ?? this.el;\n this.el.tabIndex = this._trigger === this.el ? 0 : -1;\n // Wrap\n this.el.before(this.placeholder);\n this.placeholder.append(this.el);\n this._setupEventHandlers();\n }\n\n static get defaults(): LightboxOptions {\n return _defaults;\n }\n\n /**\n * Initializes instance of Lightbox.\n * @param el HTML element.\n * @param options Component options.\n */\n static init(el: HTMLElement, options?: Partial<LightboxOptions>): Lightbox;\n /**\n * Initializes instances of Lightbox.\n * @param els HTML elements.\n * @param options Component options.\n */\n static init(els: InitElements<InitElement>, options?: Partial<LightboxOptions>): Lightbox[];\n /**\n * Initializes instances of Lightbox.\n * @param els HTML elements.\n * @param options Component options.\n */\n static init(\n els: HTMLElement | InitElements<InitElement>,\n options: Partial<LightboxOptions> = {}\n ): Lightbox | Lightbox[] {\n return super.init(els, options, Lightbox);\n }\n\n static getInstance(el: HTMLElement): Lightbox {\n return el['Expressive_Lightbox'];\n }\n\n destroy() {\n if (this._destroyed) return;\n this._destroyed = true;\n const root = this.el.getRootNode() as Document | ShadowRoot;\n const focused = root.activeElement === this.el;\n this._removeEventHandlers();\n this._cancel();\n this._reset();\n this.placeholder.replaceWith(this.el);\n let active = document.activeElement;\n while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;\n if (focused && (active === document.body || active === (root as ShadowRoot).host)) this._trigger.focus();\n if (this._tabindex === null) this.el.removeAttribute('tabindex');\n else this.el.setAttribute('tabindex', this._tabindex);\n this.el['Expressive_Lightbox'] = undefined;\n }\n\n private _reset() {\n window.removeEventListener('scroll', this._handleWindowScroll);\n window.removeEventListener('resize', this._handleWindowResize);\n window.removeEventListener('keyup', this._handleWindowEscape);\n this._overlay?.remove();\n this._photoCaption?.remove();\n for (const ancestor of this._changedAncestorList) {\n const saved = Lightbox._overflow.get(ancestor);\n if (--saved.count === 0) {\n ancestor.style.setProperty('overflow', saved.value, saved.priority);\n Lightbox._overflow.delete(ancestor);\n }\n }\n this._changedAncestorList = [];\n if (this.attrWidth !== null && this.attrWidth !== undefined) this.el.setAttribute('width', this.attrWidth);\n if (this.attrHeight !== null && this.attrHeight !== undefined) this.el.setAttribute('height', this.attrHeight);\n this.el.classList.remove('active');\n this.placeholder.removeAttribute('style');\n if (this.originInlineStyles === null) this.el.removeAttribute('style');\n else this.el.setAttribute('style', this.originInlineStyles);\n this.overlayActive = false;\n this._isOpen = false;\n this.doneAnimating = true;\n }\n\n private _cancel() {\n for (const timer of this._timers.keys()) clearTimeout(timer);\n this._timers.clear();\n return ++this._revision;\n }\n\n private _schedule(callback: () => void, delay: number) {\n if (this._motion.matches) { callback(); return; }\n const timer = setTimeout(() => { this._timers.delete(timer); callback(); }, delay);\n this._timers.set(timer, callback);\n }\n\n private _handleMotionChange = () => {\n if (!this._motion.matches) return;\n const callbacks = [...this._timers.values()];\n const revision = this._cancel();\n for (const callback of callbacks) {\n if (revision !== this._revision) break;\n callback();\n }\n if (this.overlayActive) {\n for (const el of [this.el, this._overlay, this._photoCaption]) if (el) el.style.transition = 'none';\n }\n };\n\n private _setupEventHandlers() {\n this._motion.addEventListener('change', this._handleMotionChange);\n this._trigger.addEventListener('click', this._handleLightboxClick);\n this.el.addEventListener('keydown', this._handleLightboxKeypress);\n }\n\n private _removeEventHandlers() {\n this._motion.removeEventListener('change', this._handleMotionChange);\n this._trigger.removeEventListener('click', this._handleLightboxClick);\n this.el.removeEventListener('keydown', this._handleLightboxKeypress);\n }\n\n private _handleLightboxClick = () => {\n this._handleLightboxToggle();\n };\n\n private _handleLightboxKeypress = (e: KeyboardEvent) => {\n if (this._trigger === this.el && (e.key === Utils.keys.ENTER || e.key === ' ')) {\n e.preventDefault();\n this._handleLightboxToggle();\n }\n };\n\n private _handleLightboxToggle = () => {\n // If already modal, return to original\n if (this._isOpen) this.close();\n else this.open();\n };\n\n private _handleWindowScroll = () => {\n if (this.overlayActive) this.close();\n };\n\n private _handleWindowResize = () => {\n if (this.overlayActive) this.close();\n };\n\n private _handleWindowEscape = (e: KeyboardEvent) => {\n if (e.key === Utils.keys.ESC) this.close();\n };\n\n private _makeAncestorsOverflowVisible() {\n this._changedAncestorList = [];\n let ancestor: Node = this.placeholder.parentNode;\n while (ancestor !== null && ancestor !== undefined && ancestor !== document) {\n const curr = <HTMLElement>ancestor;\n // A shadow root has no style; the clipping ancestors are above its host.\n if (curr.style && (curr.style.overflow !== 'visible' || Lightbox._overflow.has(curr))) {\n // Read before the write: an author's inline `overflow` has to come\n // back on close, and restoring '' would silently discard it.\n const saved = Lightbox._overflow.get(curr) ?? { count: 0, value: curr.style.overflow, priority: curr.style.getPropertyPriority('overflow') };\n saved.count++;\n Lightbox._overflow.set(curr, saved);\n this._changedAncestorList.push(curr);\n curr.style.overflow = 'visible';\n }\n ancestor = ancestor.parentNode ?? (<ShadowRoot>ancestor).host;\n }\n }\n\n private _offset(el: HTMLElement) {\n const box = el.getBoundingClientRect();\n const docElem = document.documentElement;\n return {\n top: box.top + window.scrollY - docElem.clientTop,\n left: box.left + window.scrollX - docElem.clientLeft\n };\n }\n private _updateVars(): void {\n this.windowWidth = window.innerWidth;\n this.windowHeight = window.innerHeight;\n this.caption = this.el.getAttribute('data-caption') || '';\n }\n\n // Image\n private _animateImageIn(): void {\n this.el.style.maxHeight = this.newHeight.toString() + 'px';\n this.el.style.maxWidth = this.newWidth.toString() + 'px';\n const duration = this._motion.matches ? 0 : this.options.inDuration;\n // from\n this.el.style.transition = 'none';\n this.el.style.height = this.originalHeight + 'px';\n this.el.style.width = this.originalWidth + 'px';\n this._schedule(() => {\n // One offset for both axes, read before any of the writes below.\n const placeholderOffset = this._offset(this.placeholder);\n // easeOutQuad\n this.el.style.transition = `height ${duration}ms ease,\n width ${duration}ms ease,\n left ${duration}ms ease,\n top ${duration}ms ease\n `;\n // to\n this.el.style.height = this.newHeight + 'px';\n this.el.style.width = this.newWidth + 'px';\n this.el.style.left =\n Utils.getDocumentScrollLeft() +\n this.windowWidth / 2 -\n placeholderOffset.left -\n this.newWidth / 2 +\n 'px';\n\n this.el.style.top =\n Utils.getDocumentScrollTop() +\n this.windowHeight / 2 -\n placeholderOffset.top -\n this.newHeight / 2 +\n 'px';\n }, 1);\n\n this._schedule(() => {\n this.doneAnimating = true;\n if (typeof this.options.onOpenEnd === 'function') this.options.onOpenEnd.call(this, this.el);\n }, duration);\n\n }\n private _animateImageOut(): void {\n const duration = this._motion.matches ? 0 : this.options.outDuration;\n // easeOutQuad\n this.el.style.transition = `height ${duration}ms ease,\n width ${duration}ms ease,\n left ${duration}ms ease,\n top ${duration}ms ease\n `;\n // to\n this.el.style.height = this.originalHeight + 'px'; // was originalWidth\n this.el.style.width = this.originalWidth + 'px';\n this.el.style.left = '0';\n this.el.style.top = '0';\n this._schedule(() => {\n this._reset();\n // onCloseEnd callback\n if (typeof this.options.onCloseEnd === 'function')\n this.options.onCloseEnd.call(this, this.el);\n }, duration);\n }\n\n // Caption\n private _addCaption(): void {\n this._photoCaption = document.createElement('div');\n this._photoCaption.classList.add('lightbox-caption');\n this._photoCaption.innerText = this.caption;\n Utils.portalRoot(this.el).append(this._photoCaption);\n this._photoCaption.style.display = 'inline';\n // Animate\n this._photoCaption.style.transition = 'none';\n this._photoCaption.style.opacity = '0';\n const duration = this._motion.matches ? 0 : this.options.inDuration;\n this._schedule(() => {\n this._photoCaption.style.transition = `opacity ${duration}ms ease`;\n this._photoCaption.style.opacity = '1';\n }, 1);\n }\n private _removeCaption(): void {\n const duration = this._motion.matches ? 0 : this.options.outDuration;\n this._photoCaption.style.transition = `opacity ${duration}ms ease`;\n this._photoCaption.style.opacity = '0';\n }\n\n // Overlay\n private _addOverlay(): void {\n this._overlay = document.createElement('div');\n this._overlay.id = 'lightbox-overlay';\n this._overlay.addEventListener(\n 'click',\n (event) => {\n event.stopPropagation();\n this.close();\n },\n { once: true }\n );\n\n // Put before in origin image to preserve z-index layering.\n this.el.before(this._overlay);\n\n // Set dimensions if needed\n const overlayOffset = this._overlay.getBoundingClientRect();\n this._overlay.style.width = this.windowWidth + 'px';\n this._overlay.style.height = this.windowHeight + 'px';\n this._overlay.style.left = -1 * overlayOffset.left + 'px';\n this._overlay.style.top = -1 * overlayOffset.top + 'px';\n\n // Animate\n this._overlay.style.transition = 'none';\n this._overlay.style.opacity = '0';\n const duration = this._motion.matches ? 0 : this.options.inDuration;\n this._schedule(() => {\n this._overlay.style.transition = `opacity ${duration}ms ease`;\n this._overlay.style.opacity = '1';\n }, 1);\n }\n private _removeOverlay(): void {\n const duration = this._motion.matches ? 0 : this.options.outDuration;\n this._overlay.style.transition = `opacity ${duration}ms ease`;\n this._overlay.style.opacity = '0';\n }\n\n /**\n * Open lightbox.\n */\n open = () => {\n if (this._destroyed || this._isOpen) return;\n const revision = this._cancel();\n if (this.overlayActive) this._reset();\n this._isOpen = true;\n this._updateVars();\n // Both rects are read up front: measuring the placeholder after writing\n // its width forced a second layout for the height.\n const originRect = this.el.getBoundingClientRect();\n const placeholderRect = this.placeholder.getBoundingClientRect();\n this.originalWidth = originRect.width;\n this.originalHeight = originRect.height;\n // Set states\n this.doneAnimating = false;\n this.el.classList.add('active');\n this.overlayActive = true;\n // onOpenStart callback\n if (typeof this.options.onOpenStart === 'function')\n this.options.onOpenStart.call(this, this.el);\n if (revision !== this._revision) return;\n // Set positioning for placeholder\n this.placeholder.style.width = placeholderRect.width + 'px';\n this.placeholder.style.height = placeholderRect.height + 'px';\n this.placeholder.style.position = 'relative';\n this.placeholder.style.top = '0';\n this.placeholder.style.left = '0';\n this._makeAncestorsOverflowVisible();\n // Set css on origin\n this.el.style.position = 'absolute';\n this.el.style.zIndex = '1000';\n this.el.style.willChange = 'left, top, width, height';\n // Change from width or height attribute to css\n this.attrWidth = this.el.getAttribute('width');\n this.attrHeight = this.el.getAttribute('height');\n if (this.attrWidth) {\n this.el.style.width = this.attrWidth + 'px';\n this.el.removeAttribute('width');\n }\n if (this.attrHeight) {\n this.el.style.height = this.attrHeight + 'px'; // was width, from the height attribute\n this.el.removeAttribute('height');\n }\n this._addOverlay();\n // Add and animate caption if it exists\n if (this.caption !== '') this._addCaption();\n // Resize Image\n const widthPercent = this.originalWidth / this.windowWidth;\n const heightPercent = this.originalHeight / this.windowHeight;\n this.newWidth = 0;\n this.newHeight = 0;\n if (widthPercent > heightPercent) {\n // Width first\n const ratio = this.originalHeight / this.originalWidth;\n this.newWidth = this.windowWidth * 0.9;\n this.newHeight = this.windowWidth * 0.9 * ratio;\n } else {\n // Height first\n const ratio = this.originalWidth / this.originalHeight;\n this.newWidth = this.windowHeight * 0.9 * ratio;\n this.newHeight = this.windowHeight * 0.9;\n }\n // Handle Exit triggers\n window.addEventListener('scroll', this._handleWindowScroll, { passive: true });\n window.addEventListener('resize', this._handleWindowResize, { passive: true });\n window.addEventListener('keyup', this._handleWindowEscape);\n this._animateImageIn();\n };\n\n /**\n * Close lightbox.\n */\n close = () => {\n if (this._destroyed || !this._isOpen) return;\n const revision = this._cancel();\n this._isOpen = false;\n this.doneAnimating = false;\n // onCloseStart callback\n if (typeof this.options.onCloseStart === 'function')\n this.options.onCloseStart.call(this, this.el);\n if (revision !== this._revision) return;\n // disable exit handlers\n window.removeEventListener('scroll', this._handleWindowScroll);\n window.removeEventListener('resize', this._handleWindowResize);\n window.removeEventListener('keyup', this._handleWindowEscape);\n if (this._overlay) this._removeOverlay();\n if (this._photoCaption) this._removeCaption();\n this._animateImageOut();\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAoCA,IAAM,YAA6B;AAAA,EACjC,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AAAA,EACb,WAAW;AAAA,EACX,cAAc;AAAA,EACd,YAAY;AACd;AAEO,IAAM,YAAN,MAAM,kBAAiB,UAA2B;AAAA,EAgCvD,YAAY,IAAiB,SAAmC;AAC9D,UAAM,IAAI,SAAS,SAAQ;AAnB7B;AAAA,SAAQ,uBAAsC,CAAC;AAY/C,SAAQ,UAAU,oBAAI,IAA+C;AACrE,SAAQ,UAAU,OAAO,WAAW,kCAAkC;AACtE,SAAQ,UAAU;AAClB,SAAQ,aAAa;AACrB,SAAQ,YAAY;AAkHpB,SAAQ,sBAAsB,MAAM;AAClC,UAAI,CAAC,KAAK,QAAQ,QAAS;AAC3B,YAAM,YAAY,CAAC,GAAG,KAAK,QAAQ,OAAO,CAAC;AAC3C,YAAM,WAAW,KAAK,QAAQ;AAC9B,iBAAW,YAAY,WAAW;AAChC,YAAI,aAAa,KAAK,UAAW;AACjC,iBAAS;AAAA,MACX;AACA,UAAI,KAAK,eAAe;AACtB,mBAAW,MAAM,CAAC,KAAK,IAAI,KAAK,UAAU,KAAK,aAAa,EAAG,KAAI,GAAI,IAAG,MAAM,aAAa;AAAA,MAC/F;AAAA,IACF;AAcA,SAAQ,uBAAuB,MAAM;AACnC,WAAK,sBAAsB;AAAA,IAC7B;AAEA,SAAQ,0BAA0B,CAAC,MAAqB;AACtD,UAAI,KAAK,aAAa,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAK,SAAS,EAAE,QAAQ,MAAM;AAC9E,UAAE,eAAe;AACjB,aAAK,sBAAsB;AAAA,MAC7B;AAAA,IACF;AAEA,SAAQ,wBAAwB,MAAM;AAEpC,UAAI,KAAK,QAAS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