@studiometa/ui 1.7.0 → 1.8.0
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/Data/DataBind.d.ts +1 -1
- package/Fetch/Fetch.d.ts +17 -17
- package/Fetch/Fetch.js.map +2 -2
- package/Fetch/utils.js +1 -4
- package/Fetch/utils.js.map +2 -2
- package/Frame/Frame.d.ts +4 -4
- package/Frame/FrameForm.d.ts +1 -1
- package/Frame/FrameTarget.d.ts +4 -4
- package/Frame/FrameTarget.js.map +2 -2
- package/ScrollAnimation/AbstractScrollAnimation.d.ts +8 -0
- package/ScrollAnimation/AbstractScrollAnimation.js +20 -1
- package/ScrollAnimation/AbstractScrollAnimation.js.map +2 -2
- package/ScrollAnimation/ScrollAnimation.d.ts +6 -0
- package/ScrollAnimation/ScrollAnimation.js +12 -0
- package/ScrollAnimation/ScrollAnimation.js.map +2 -2
- package/ScrollAnimation/ScrollAnimationChild.d.ts +6 -0
- package/ScrollAnimation/ScrollAnimationChild.js +17 -4
- package/ScrollAnimation/ScrollAnimationChild.js.map +2 -2
- package/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +7 -1
- package/ScrollAnimation/ScrollAnimationChildWithEase.js +12 -0
- package/ScrollAnimation/ScrollAnimationChildWithEase.js.map +2 -2
- package/ScrollAnimation/ScrollAnimationParent.d.ts +6 -0
- package/ScrollAnimation/ScrollAnimationParent.js +12 -0
- package/ScrollAnimation/ScrollAnimationParent.js.map +2 -2
- package/ScrollAnimation/ScrollAnimationTarget.d.ts +43 -0
- package/ScrollAnimation/ScrollAnimationTarget.js +68 -0
- package/ScrollAnimation/ScrollAnimationTarget.js.map +7 -0
- package/ScrollAnimation/ScrollAnimationTimeline.d.ts +35 -0
- package/ScrollAnimation/ScrollAnimationTimeline.js +28 -0
- package/ScrollAnimation/ScrollAnimationTimeline.js.map +7 -0
- package/ScrollAnimation/ScrollAnimationWithEase.d.ts +7 -1
- package/ScrollAnimation/ScrollAnimationWithEase.js +12 -0
- package/ScrollAnimation/ScrollAnimationWithEase.js.map +2 -2
- package/ScrollAnimation/animationScrollWithEase.d.ts +2 -0
- package/ScrollAnimation/animationScrollWithEase.js +12 -1
- package/ScrollAnimation/animationScrollWithEase.js.map +2 -2
- package/ScrollAnimation/index.d.ts +3 -0
- package/ScrollAnimation/index.js +3 -0
- package/ScrollAnimation/index.js.map +2 -2
- package/ScrollAnimation/withScrollAnimationDebug.d.ts +28 -0
- package/ScrollAnimation/withScrollAnimationDebug.js +309 -0
- package/ScrollAnimation/withScrollAnimationDebug.js.map +7 -0
- package/package.json +3 -3
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { createElement } from "@studiometa/js-toolkit/utils";
|
|
2
|
+
const debugColors = [
|
|
3
|
+
"#8b5cf6",
|
|
4
|
+
// violet
|
|
5
|
+
"#3b82f6",
|
|
6
|
+
// blue
|
|
7
|
+
"#10b981",
|
|
8
|
+
// emerald
|
|
9
|
+
"#f59e0b",
|
|
10
|
+
// amber
|
|
11
|
+
"#ef4444",
|
|
12
|
+
// red
|
|
13
|
+
"#ec4899",
|
|
14
|
+
// pink
|
|
15
|
+
"#06b6d4",
|
|
16
|
+
// cyan
|
|
17
|
+
"#84cc16"
|
|
18
|
+
// lime
|
|
19
|
+
];
|
|
20
|
+
function getDebugColor(index) {
|
|
21
|
+
return debugColors[(index - 1) % debugColors.length];
|
|
22
|
+
}
|
|
23
|
+
const debugStyles = `
|
|
24
|
+
.scroll-animation-debug {
|
|
25
|
+
--debug-color: #8b5cf6;
|
|
26
|
+
position: fixed;
|
|
27
|
+
right: 0;
|
|
28
|
+
top: 0;
|
|
29
|
+
bottom: 0;
|
|
30
|
+
width: 80px;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
z-index: 99999;
|
|
33
|
+
font-family: ui-monospace, monospace;
|
|
34
|
+
font-size: 10px;
|
|
35
|
+
}
|
|
36
|
+
.scroll-animation-debug__marker {
|
|
37
|
+
position: absolute;
|
|
38
|
+
right: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
gap: 4px;
|
|
42
|
+
padding: 2px 6px;
|
|
43
|
+
color: white;
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
transform: translateY(-50%);
|
|
46
|
+
}
|
|
47
|
+
.scroll-animation-debug__marker::before {
|
|
48
|
+
content: '';
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 50%;
|
|
51
|
+
right: 100%;
|
|
52
|
+
width: 100vw;
|
|
53
|
+
height: 1px;
|
|
54
|
+
background: var(--debug-color);
|
|
55
|
+
}
|
|
56
|
+
.scroll-animation-debug__marker--start {
|
|
57
|
+
background: var(--debug-color);
|
|
58
|
+
}
|
|
59
|
+
.scroll-animation-debug__marker--end {
|
|
60
|
+
background: var(--debug-color);
|
|
61
|
+
opacity: 0.7;
|
|
62
|
+
}
|
|
63
|
+
.scroll-animation-debug__outline {
|
|
64
|
+
position: absolute;
|
|
65
|
+
inset: 0;
|
|
66
|
+
border: 2px dashed var(--debug-color);
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
z-index: 99998;
|
|
69
|
+
}
|
|
70
|
+
.scroll-animation-debug-progress-container {
|
|
71
|
+
position: fixed;
|
|
72
|
+
right: 8px;
|
|
73
|
+
top: 50%;
|
|
74
|
+
transform: translateY(-50%);
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 8px;
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
z-index: 99999;
|
|
81
|
+
font-family: ui-monospace, monospace;
|
|
82
|
+
font-size: 10px;
|
|
83
|
+
}
|
|
84
|
+
.scroll-animation-debug__progress {
|
|
85
|
+
--debug-color: #8b5cf6;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
align-items: center;
|
|
89
|
+
gap: 4px;
|
|
90
|
+
}
|
|
91
|
+
.scroll-animation-debug__progress-bar {
|
|
92
|
+
width: 4px;
|
|
93
|
+
height: 60px;
|
|
94
|
+
background: rgba(139, 92, 246, 0.2);
|
|
95
|
+
border-radius: 2px;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
}
|
|
98
|
+
.scroll-animation-debug__progress-fill {
|
|
99
|
+
width: 100%;
|
|
100
|
+
background: var(--debug-color);
|
|
101
|
+
border-radius: 2px;
|
|
102
|
+
transition: height 0.1s ease-out;
|
|
103
|
+
}
|
|
104
|
+
.scroll-animation-debug__progress-text {
|
|
105
|
+
color: var(--debug-color);
|
|
106
|
+
font-weight: bold;
|
|
107
|
+
width: 3ch;
|
|
108
|
+
text-align: center;
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
let styleElement = null;
|
|
112
|
+
let progressContainer = null;
|
|
113
|
+
let debugInstanceCount = 0;
|
|
114
|
+
let debugIdCounter = 0;
|
|
115
|
+
function injectDebugStyles() {
|
|
116
|
+
if (!styleElement) {
|
|
117
|
+
styleElement = createElement("style", [debugStyles]);
|
|
118
|
+
document.head.appendChild(styleElement);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function removeDebugStyles() {
|
|
122
|
+
if (styleElement && debugInstanceCount === 0) {
|
|
123
|
+
styleElement.remove();
|
|
124
|
+
styleElement = null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getProgressContainer() {
|
|
128
|
+
if (!progressContainer) {
|
|
129
|
+
progressContainer = createElement("div", {
|
|
130
|
+
class: "scroll-animation-debug-progress-container"
|
|
131
|
+
});
|
|
132
|
+
document.body.appendChild(progressContainer);
|
|
133
|
+
}
|
|
134
|
+
return progressContainer;
|
|
135
|
+
}
|
|
136
|
+
function cleanupProgressContainer() {
|
|
137
|
+
if (progressContainer && progressContainer.children.length === 0) {
|
|
138
|
+
progressContainer.remove();
|
|
139
|
+
progressContainer = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const namedOffsets = {
|
|
143
|
+
start: 0,
|
|
144
|
+
center: 0.5,
|
|
145
|
+
end: 1
|
|
146
|
+
};
|
|
147
|
+
function parseOffsetValue(value) {
|
|
148
|
+
if (namedOffsets[value] !== void 0) {
|
|
149
|
+
return namedOffsets[value];
|
|
150
|
+
}
|
|
151
|
+
if (value.endsWith("%")) {
|
|
152
|
+
return Number.parseFloat(value) / 100;
|
|
153
|
+
}
|
|
154
|
+
return Number.parseFloat(value) || 0;
|
|
155
|
+
}
|
|
156
|
+
function parseOffset(offset) {
|
|
157
|
+
const parts = offset.split("/").map((part) => part.trim().split(" "));
|
|
158
|
+
const viewportStart = parseOffsetValue(parts[0]?.[1] || "end");
|
|
159
|
+
const viewportEnd = parseOffsetValue(parts[1]?.[1] || "start");
|
|
160
|
+
return { viewportStart, viewportEnd };
|
|
161
|
+
}
|
|
162
|
+
function createDebugElements(color) {
|
|
163
|
+
const startMarker = createElement(
|
|
164
|
+
"div",
|
|
165
|
+
{ class: "scroll-animation-debug__marker scroll-animation-debug__marker--start" },
|
|
166
|
+
[createElement("span", ["start"])]
|
|
167
|
+
);
|
|
168
|
+
const endMarker = createElement(
|
|
169
|
+
"div",
|
|
170
|
+
{ class: "scroll-animation-debug__marker scroll-animation-debug__marker--end" },
|
|
171
|
+
[createElement("span", ["end"])]
|
|
172
|
+
);
|
|
173
|
+
const wrapper = createElement("div", { class: "scroll-animation-debug" }, [
|
|
174
|
+
startMarker,
|
|
175
|
+
endMarker
|
|
176
|
+
]);
|
|
177
|
+
wrapper.style.setProperty("--debug-color", color);
|
|
178
|
+
const progressBar = createElement("div", { class: "scroll-animation-debug__progress-fill" });
|
|
179
|
+
const progressText = createElement("span", { class: "scroll-animation-debug__progress-text" }, [
|
|
180
|
+
"0%"
|
|
181
|
+
]);
|
|
182
|
+
const progress = createElement("div", { class: "scroll-animation-debug__progress" }, [
|
|
183
|
+
createElement("div", { class: "scroll-animation-debug__progress-bar" }, [progressBar]),
|
|
184
|
+
progressText
|
|
185
|
+
]);
|
|
186
|
+
progress.style.setProperty("--debug-color", color);
|
|
187
|
+
return {
|
|
188
|
+
wrapper,
|
|
189
|
+
startMarker,
|
|
190
|
+
endMarker,
|
|
191
|
+
progress,
|
|
192
|
+
progressBar,
|
|
193
|
+
progressText
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function createOutlineElement(color) {
|
|
197
|
+
const outline = createElement("div", {
|
|
198
|
+
class: "scroll-animation-debug__outline"
|
|
199
|
+
});
|
|
200
|
+
outline.style.setProperty("--debug-color", color);
|
|
201
|
+
return outline;
|
|
202
|
+
}
|
|
203
|
+
function withScrollAnimationDebug(BaseClass) {
|
|
204
|
+
class WithScrollAnimationDebug extends BaseClass {
|
|
205
|
+
static config = {
|
|
206
|
+
...BaseClass.config,
|
|
207
|
+
name: BaseClass.config.name,
|
|
208
|
+
options: {
|
|
209
|
+
...BaseClass.config.options,
|
|
210
|
+
debug: Boolean
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Debug elements.
|
|
215
|
+
*/
|
|
216
|
+
__debugElements = null;
|
|
217
|
+
/**
|
|
218
|
+
* Debug outline element.
|
|
219
|
+
*/
|
|
220
|
+
__debugOutline = null;
|
|
221
|
+
/**
|
|
222
|
+
* Debug ID.
|
|
223
|
+
*/
|
|
224
|
+
__debugId = "";
|
|
225
|
+
/**
|
|
226
|
+
* Mounted hook.
|
|
227
|
+
*/
|
|
228
|
+
mounted() {
|
|
229
|
+
if (super.mounted) super.mounted();
|
|
230
|
+
if (this.$options.debug) {
|
|
231
|
+
this.__initDebug();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Destroyed hook.
|
|
236
|
+
*/
|
|
237
|
+
destroyed() {
|
|
238
|
+
this.__destroyDebug();
|
|
239
|
+
if (super.destroyed) super.destroyed();
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Initialize debug elements.
|
|
243
|
+
*/
|
|
244
|
+
__initDebug() {
|
|
245
|
+
debugIdCounter += 1;
|
|
246
|
+
debugInstanceCount += 1;
|
|
247
|
+
this.__debugId = `timeline-${debugIdCounter}`;
|
|
248
|
+
const color = getDebugColor(debugIdCounter);
|
|
249
|
+
injectDebugStyles();
|
|
250
|
+
this.__debugElements = createDebugElements(color);
|
|
251
|
+
document.body.appendChild(this.__debugElements.wrapper);
|
|
252
|
+
const container = getProgressContainer();
|
|
253
|
+
container.appendChild(this.__debugElements.progress);
|
|
254
|
+
const { viewportStart, viewportEnd } = parseOffset(this.$options.offset);
|
|
255
|
+
const viewportHeight = window.innerHeight;
|
|
256
|
+
this.__debugElements.startMarker.style.top = `${viewportStart * viewportHeight}px`;
|
|
257
|
+
this.__debugElements.endMarker.style.top = `${viewportEnd * viewportHeight}px`;
|
|
258
|
+
this.__debugOutline = createOutlineElement(color);
|
|
259
|
+
const position = getComputedStyle(this.$el).position;
|
|
260
|
+
if (position === "static") {
|
|
261
|
+
this.$el.style.position = "relative";
|
|
262
|
+
}
|
|
263
|
+
this.$el.appendChild(this.__debugOutline);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Destroy debug elements.
|
|
267
|
+
*/
|
|
268
|
+
__destroyDebug() {
|
|
269
|
+
if (this.__debugElements) {
|
|
270
|
+
this.__debugElements.wrapper.remove();
|
|
271
|
+
this.__debugElements.progress.remove();
|
|
272
|
+
this.__debugElements = null;
|
|
273
|
+
}
|
|
274
|
+
if (this.__debugOutline) {
|
|
275
|
+
this.__debugOutline.remove();
|
|
276
|
+
this.__debugOutline = null;
|
|
277
|
+
}
|
|
278
|
+
if (this.$options.debug) {
|
|
279
|
+
debugInstanceCount -= 1;
|
|
280
|
+
cleanupProgressContainer();
|
|
281
|
+
removeDebugStyles();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Update debug progress.
|
|
286
|
+
*/
|
|
287
|
+
__updateDebug(props) {
|
|
288
|
+
if (!this.__debugElements) return;
|
|
289
|
+
const { progressBar, progressText } = this.__debugElements;
|
|
290
|
+
const progress = Math.round(props.dampedProgress.y * 100);
|
|
291
|
+
progressBar.style.height = `${progress}%`;
|
|
292
|
+
progressText.textContent = `${progress}%`;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Scrolled in view hook.
|
|
296
|
+
*/
|
|
297
|
+
scrolledInView(props) {
|
|
298
|
+
if (this.$options.debug) {
|
|
299
|
+
this.__updateDebug(props);
|
|
300
|
+
}
|
|
301
|
+
super.scrolledInView(props);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return WithScrollAnimationDebug;
|
|
305
|
+
}
|
|
306
|
+
export {
|
|
307
|
+
withScrollAnimationDebug
|
|
308
|
+
};
|
|
309
|
+
//# sourceMappingURL=withScrollAnimationDebug.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/ui/ScrollAnimation/withScrollAnimationDebug.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n Base,\n BaseProps,\n BaseConfig,\n BaseInterface,\n BaseDecorator,\n ScrollInViewProps,\n} from '@studiometa/js-toolkit';\nimport { createElement } from '@studiometa/js-toolkit/utils';\n\n/**\n * Debug marker element interface.\n */\ninterface DebugElements {\n wrapper: HTMLElement;\n startMarker: HTMLElement;\n endMarker: HTMLElement;\n progress: HTMLElement;\n progressBar: HTMLElement;\n progressText: HTMLElement;\n}\n\n/**\n * Debug colors for different timelines.\n */\nconst debugColors = [\n '#8b5cf6', // violet\n '#3b82f6', // blue\n '#10b981', // emerald\n '#f59e0b', // amber\n '#ef4444', // red\n '#ec4899', // pink\n '#06b6d4', // cyan\n '#84cc16', // lime\n];\n\n/**\n * Get debug color for a given index.\n */\nfunction getDebugColor(index: number): string {\n return debugColors[(index - 1) % debugColors.length];\n}\n\n/**\n * Debug styles.\n */\nconst debugStyles = `\n .scroll-animation-debug {\n --debug-color: #8b5cf6;\n position: fixed;\n right: 0;\n top: 0;\n bottom: 0;\n width: 80px;\n pointer-events: none;\n z-index: 99999;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n }\n .scroll-animation-debug__marker {\n position: absolute;\n right: 0;\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 2px 6px;\n color: white;\n white-space: nowrap;\n transform: translateY(-50%);\n }\n .scroll-animation-debug__marker::before {\n content: '';\n position: absolute;\n top: 50%;\n right: 100%;\n width: 100vw;\n height: 1px;\n background: var(--debug-color);\n }\n .scroll-animation-debug__marker--start {\n background: var(--debug-color);\n }\n .scroll-animation-debug__marker--end {\n background: var(--debug-color);\n opacity: 0.7;\n }\n .scroll-animation-debug__outline {\n position: absolute;\n inset: 0;\n border: 2px dashed var(--debug-color);\n pointer-events: none;\n z-index: 99998;\n }\n .scroll-animation-debug-progress-container {\n position: fixed;\n right: 8px;\n top: 50%;\n transform: translateY(-50%);\n display: flex;\n flex-direction: row;\n align-items: center;\n gap: 8px;\n pointer-events: none;\n z-index: 99999;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n }\n .scroll-animation-debug__progress {\n --debug-color: #8b5cf6;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n }\n .scroll-animation-debug__progress-bar {\n width: 4px;\n height: 60px;\n background: rgba(139, 92, 246, 0.2);\n border-radius: 2px;\n overflow: hidden;\n }\n .scroll-animation-debug__progress-fill {\n width: 100%;\n background: var(--debug-color);\n border-radius: 2px;\n transition: height 0.1s ease-out;\n }\n .scroll-animation-debug__progress-text {\n color: var(--debug-color);\n font-weight: bold;\n width: 3ch;\n text-align: center;\n }\n`;\n\n/**\n * Shared style element.\n */\nlet styleElement: HTMLStyleElement | null = null;\n\n/**\n * Shared progress container.\n */\nlet progressContainer: HTMLElement | null = null;\n\n/**\n * Debug instance counter.\n */\nlet debugInstanceCount = 0;\n\n/**\n * Debug ID counter.\n */\nlet debugIdCounter = 0;\n\n/**\n * Inject debug styles if not already injected.\n */\nfunction injectDebugStyles() {\n if (!styleElement) {\n styleElement = createElement('style', [debugStyles]) as HTMLStyleElement;\n document.head.appendChild(styleElement);\n }\n}\n\n/**\n * Remove debug styles if no more instances.\n */\nfunction removeDebugStyles() {\n if (styleElement && debugInstanceCount === 0) {\n styleElement.remove();\n styleElement = null;\n }\n}\n\n/**\n * Get or create the shared progress container.\n */\nfunction getProgressContainer(): HTMLElement {\n if (!progressContainer) {\n progressContainer = createElement('div', {\n class: 'scroll-animation-debug-progress-container',\n });\n document.body.appendChild(progressContainer);\n }\n return progressContainer;\n}\n\n/**\n * Remove progress container if empty.\n */\nfunction cleanupProgressContainer() {\n if (progressContainer && progressContainer.children.length === 0) {\n progressContainer.remove();\n progressContainer = null;\n }\n}\n\n/**\n * Named offset values mapping.\n */\nconst namedOffsets: Record<string, number> = {\n start: 0,\n center: 0.5,\n end: 1,\n};\n\n/**\n * Parse an offset value to a ratio (0-1).\n */\nfunction parseOffsetValue(value: string): number {\n if (namedOffsets[value] !== undefined) {\n return namedOffsets[value];\n }\n if (value.endsWith('%')) {\n return Number.parseFloat(value) / 100;\n }\n return Number.parseFloat(value) || 0;\n}\n\n/**\n * Parse the offset option to get viewport positions.\n * Format: \"<targetStart> <viewportStart> / <targetEnd> <viewportEnd>\"\n */\nfunction parseOffset(offset: string): { viewportStart: number; viewportEnd: number } {\n const parts = offset.split('/').map((part) => part.trim().split(' '));\n const viewportStart = parseOffsetValue(parts[0]?.[1] || 'end');\n const viewportEnd = parseOffsetValue(parts[1]?.[1] || 'start');\n return { viewportStart, viewportEnd };\n}\n\n/**\n * Create debug marker elements.\n */\nfunction createDebugElements(color: string): DebugElements {\n const startMarker = createElement(\n 'div',\n { class: 'scroll-animation-debug__marker scroll-animation-debug__marker--start' },\n [createElement('span', ['start'])],\n );\n\n const endMarker = createElement(\n 'div',\n { class: 'scroll-animation-debug__marker scroll-animation-debug__marker--end' },\n [createElement('span', ['end'])],\n );\n\n const wrapper = createElement('div', { class: 'scroll-animation-debug' }, [\n startMarker,\n endMarker,\n ]) as HTMLElement;\n wrapper.style.setProperty('--debug-color', color);\n\n const progressBar = createElement('div', { class: 'scroll-animation-debug__progress-fill' });\n const progressText = createElement('span', { class: 'scroll-animation-debug__progress-text' }, [\n '0%',\n ]);\n\n const progress = createElement('div', { class: 'scroll-animation-debug__progress' }, [\n createElement('div', { class: 'scroll-animation-debug__progress-bar' }, [progressBar]),\n progressText,\n ]) as HTMLElement;\n progress.style.setProperty('--debug-color', color);\n\n return {\n wrapper,\n startMarker,\n endMarker,\n progress,\n progressBar,\n progressText,\n };\n}\n\n/**\n * Create outline element for the timeline.\n */\nfunction createOutlineElement(color: string): HTMLElement {\n const outline = createElement('div', {\n class: 'scroll-animation-debug__outline',\n }) as HTMLElement;\n outline.style.setProperty('--debug-color', color);\n return outline;\n}\n\nexport interface WithScrollAnimationDebugProps extends BaseProps {\n $options: {\n debug: boolean;\n offset: string;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface WithScrollAnimationDebugInterface extends BaseInterface {}\n\n/**\n * Add debug capabilities to a ScrollAnimationTimeline component.\n *\n * @example\n * ```js\n * import { ScrollAnimationTimeline } from '@studiometa/ui';\n * import { withScrollAnimationDebug } from '@studiometa/ui/ScrollAnimation/withScrollAnimationDebug';\n *\n * class App extends Base {\n * static config = {\n * name: 'App',\n * components: {\n * ScrollAnimationTimeline: withScrollAnimationDebug(ScrollAnimationTimeline),\n * },\n * };\n * }\n * ```\n */\nexport function withScrollAnimationDebug<S extends Base>(\n BaseClass: typeof Base,\n): BaseDecorator<WithScrollAnimationDebugInterface, S, WithScrollAnimationDebugProps> {\n /**\n * Class.\n */\n class WithScrollAnimationDebug<T extends BaseProps = BaseProps> extends BaseClass<\n T & WithScrollAnimationDebugProps\n > {\n static config: BaseConfig = {\n ...BaseClass.config,\n name: BaseClass.config.name,\n options: {\n ...BaseClass.config.options,\n debug: Boolean,\n },\n };\n\n /**\n * Debug elements.\n */\n private __debugElements: DebugElements | null = null;\n\n /**\n * Debug outline element.\n */\n private __debugOutline: HTMLElement | null = null;\n\n /**\n * Debug ID.\n */\n private __debugId: string = '';\n\n /**\n * Mounted hook.\n */\n mounted() {\n // @ts-expect-error - Calling parent method\n if (super.mounted) super.mounted();\n if (this.$options.debug) {\n this.__initDebug();\n }\n }\n\n /**\n * Destroyed hook.\n */\n destroyed() {\n this.__destroyDebug();\n // @ts-expect-error - Calling parent method\n if (super.destroyed) super.destroyed();\n }\n\n /**\n * Initialize debug elements.\n */\n __initDebug() {\n debugIdCounter += 1;\n debugInstanceCount += 1;\n this.__debugId = `timeline-${debugIdCounter}`;\n\n const color = getDebugColor(debugIdCounter);\n\n // Inject styles\n injectDebugStyles();\n\n // Create and append debug markers\n this.__debugElements = createDebugElements(color);\n document.body.appendChild(this.__debugElements.wrapper);\n\n // Append progress to shared container\n const container = getProgressContainer();\n container.appendChild(this.__debugElements.progress);\n\n // Position markers based on offset option\n const { viewportStart, viewportEnd } = parseOffset(this.$options.offset);\n const viewportHeight = window.innerHeight;\n\n this.__debugElements.startMarker.style.top = `${viewportStart * viewportHeight}px`;\n this.__debugElements.endMarker.style.top = `${viewportEnd * viewportHeight}px`;\n\n // Create and append outline\n this.__debugOutline = createOutlineElement(color);\n const position = getComputedStyle(this.$el).position;\n if (position === 'static') {\n (this.$el as HTMLElement).style.position = 'relative';\n }\n this.$el.appendChild(this.__debugOutline);\n }\n\n /**\n * Destroy debug elements.\n */\n __destroyDebug() {\n if (this.__debugElements) {\n this.__debugElements.wrapper.remove();\n this.__debugElements.progress.remove();\n this.__debugElements = null;\n }\n\n if (this.__debugOutline) {\n this.__debugOutline.remove();\n this.__debugOutline = null;\n }\n\n if (this.$options.debug) {\n debugInstanceCount -= 1;\n cleanupProgressContainer();\n removeDebugStyles();\n }\n }\n\n /**\n * Update debug progress.\n */\n __updateDebug(props: ScrollInViewProps) {\n if (!this.__debugElements) return;\n\n const { progressBar, progressText } = this.__debugElements;\n\n // Update progress\n const progress = Math.round(props.dampedProgress.y * 100);\n progressBar.style.height = `${progress}%`;\n progressText.textContent = `${progress}%`;\n }\n\n /**\n * Scrolled in view hook.\n */\n scrolledInView(props: ScrollInViewProps) {\n if (this.$options.debug) {\n this.__updateDebug(props);\n }\n\n // @ts-expect-error - Calling parent method\n super.scrolledInView(props);\n }\n }\n\n // @ts-ignore\n return WithScrollAnimationDebug;\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,qBAAqB;AAiB9B,MAAM,cAAc;AAAA,EAClB;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAKA,SAAS,cAAc,OAAuB;AAC5C,SAAO,aAAa,QAAQ,KAAK,YAAY,MAAM;AACrD;AAKA,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4FpB,IAAI,eAAwC;AAK5C,IAAI,oBAAwC;AAK5C,IAAI,qBAAqB;AAKzB,IAAI,iBAAiB;AAKrB,SAAS,oBAAoB;AAC3B,MAAI,CAAC,cAAc;AACjB,mBAAe,cAAc,SAAS,CAAC,WAAW,CAAC;AACnD,aAAS,KAAK,YAAY,YAAY;AAAA,EACxC;AACF;AAKA,S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3B,YAAM,EAAE,aAAa,aAAa,IAAI,KAAK;AAG3C,YAAM,WAAW,KAAK,MAAM,MAAM,eAAe,IAAI,GAAG;AACxD,kBAAY,MAAM,SAAS,GAAG,QAAQ;AACtC,mBAAa,cAAc,GAAG,QAAQ;AAAA,IACxC;AAAA;AAAA;AAAA;AAAA,IAKA,eAAe,OAA0B;AACvC,UAAI,KAAK,SAAS,OAAO;AACvB,aAAK,cAAc,KAAK;AAAA,MAC1B;AAGA,YAAM,eAAe,KAAK;AAAA,IAC5B;AAAA,EACF;AAGA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "A set of opiniated, unstyled and accessible components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"homepage": "https://github.com/studiometa/ui#readme",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"deepmerge": "^4.3.1",
|
|
33
|
-
"morphdom": "^2.7.
|
|
33
|
+
"morphdom": "^2.7.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@studiometa/js-toolkit": "3.4.
|
|
36
|
+
"@studiometa/js-toolkit": "3.4.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@studiometa/js-toolkit": "^3.4.0"
|