@brytdesigns/web-component-parallax 1.2.20 → 3.1.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/dist/main/components/index.js +3 -8
- package/dist/main/components/parallax-animation/index.js +188 -199
- package/dist/main/components/parallax-animation/index.js.map +1 -1
- package/dist/main/components/parallax-container/index.js +11 -17
- package/dist/main/components/parallax-container/index.js.map +1 -1
- package/dist/main/components/parallax-sticky-layer/index.js +13 -24
- package/dist/main/components/parallax-sticky-layer/index.js.map +1 -1
- package/dist/main/hooks/index.js +3 -4
- package/dist/main/hooks/useParallax.js +59 -76
- package/dist/main/hooks/useParallax.js.map +1 -1
- package/dist/main/hooks/useParallaxStickyLayer.js +103 -116
- package/dist/main/hooks/useParallaxStickyLayer.js.map +1 -1
- package/dist/main/index.d.ts +27 -22
- package/dist/main/index.js +17 -24
- package/dist/main/index.js.map +1 -1
- package/dist/main/utils.js +11 -37
- package/dist/main/utils.js.map +1 -1
- package/package.json +8 -9
- package/dist/esm/index.js +0 -507
- package/dist/esm/index.js.map +0 -1
- package/dist/main/components/index.js.map +0 -1
- package/dist/main/hooks/index.js.map +0 -1
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
export { index_js$2 as ParallaxStickyLayer };
|
|
5
|
-
import * as index_js from './parallax-animation/index.js';
|
|
6
|
-
export { index_js as ParallaxAnimation };
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./parallax-animation/index.js";
|
|
2
|
+
import "./parallax-container/index.js";
|
|
3
|
+
import "./parallax-sticky-layer/index.js";
|
|
@@ -1,206 +1,195 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
borderRadius: null
|
|
1
|
+
import { getActiveBreakpoints, getLastTruthyIndex } from "../../utils.js";
|
|
2
|
+
import { useParallaxStickyLayer } from "../../hooks/useParallaxStickyLayer.js";
|
|
3
|
+
import "../../hooks/index.js";
|
|
4
|
+
import { createGuardedEffect } from "@brytdesigns/web-component-core/utils";
|
|
5
|
+
import { shouldReduceMotion } from "@brytdesigns/web-component-core/animation";
|
|
6
|
+
import { frame, motionValue, styleEffect, transform, transformValue } from "motion";
|
|
7
|
+
import { createMemo, createStore, merge, omit } from "solid-js";
|
|
8
|
+
//#region src/components/parallax-animation/index.ts
|
|
9
|
+
var Name = `parallax-animation`;
|
|
10
|
+
var PROPS = {
|
|
11
|
+
breakpoints: [""],
|
|
12
|
+
range: [0, 1],
|
|
13
|
+
y: null,
|
|
14
|
+
x: null,
|
|
15
|
+
scale: null,
|
|
16
|
+
rotate: null,
|
|
17
|
+
opacity: null,
|
|
18
|
+
color: null,
|
|
19
|
+
backgroundColor: null,
|
|
20
|
+
borderRadius: null
|
|
22
21
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
var PROP_DEFAULTS = {
|
|
23
|
+
y: "0%",
|
|
24
|
+
x: "0%",
|
|
25
|
+
scale: 1,
|
|
26
|
+
rotate: 0,
|
|
27
|
+
opacity: null,
|
|
28
|
+
color: null,
|
|
29
|
+
backgroundColor: null,
|
|
30
|
+
borderRadius: null
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
var KEYS = Object.keys(PROPS);
|
|
33
|
+
/**
|
|
34
|
+
* Solid 2 defines an element's props as own accessors that are **not
|
|
35
|
+
* enumerable**, so `Object.keys(props)` and `Object.entries(props)` both come
|
|
36
|
+
* back empty — and `merge()` returns a proxy reporting no own keys at all,
|
|
37
|
+
* even to `Reflect.ownKeys`. Reading a property works on both. Nothing throws
|
|
38
|
+
* and nothing warns; the loops simply do not run.
|
|
39
|
+
*
|
|
40
|
+
* So every key list below comes from the declared prop names. Enumerating a
|
|
41
|
+
* props object here silently validated nothing and produced an `activeProps`
|
|
42
|
+
* with no `range`, which threw inside the animation effect and halted the
|
|
43
|
+
* whole reactive system for the page.
|
|
44
|
+
*/
|
|
45
|
+
var CONFIG_KEYS = ["breakpoints", "range"];
|
|
46
|
+
var ANIMATABLE_KEYS = KEYS.filter((key) => !CONFIG_KEYS.includes(key));
|
|
47
|
+
var ACTIVE_KEYS = KEYS.filter((key) => key !== "breakpoints");
|
|
48
|
+
var isNestedAnimatableArray = (values) => {
|
|
49
|
+
return Array.isArray(values) && (Array.isArray(values[0]) || values[0] === null);
|
|
36
50
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return value;
|
|
51
|
+
var flattenAnimatableArray = (value, index = 0) => {
|
|
52
|
+
if (isNestedAnimatableArray(value)) return value[index];
|
|
53
|
+
return value;
|
|
42
54
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
Reflect.set(obj, key, animated[key]);
|
|
180
|
-
return obj;
|
|
181
|
-
}, {});
|
|
182
|
-
const unstyle = styleEffect(element, {
|
|
183
|
-
transform: transform$1,
|
|
184
|
-
...styledValues
|
|
185
|
-
});
|
|
186
|
-
return onCleanup(() => {
|
|
187
|
-
disposed = true;
|
|
188
|
-
unstyle();
|
|
189
|
-
unsub();
|
|
190
|
-
valueSubscribers.forEach((unsub2) => {
|
|
191
|
-
unsub2();
|
|
192
|
-
});
|
|
193
|
-
Object.values(animated).forEach((value) => {
|
|
194
|
-
value.destroy();
|
|
195
|
-
});
|
|
196
|
-
Object.values(progressValue).forEach((value) => {
|
|
197
|
-
value?.destroy?.();
|
|
198
|
-
});
|
|
199
|
-
transform$1.destroy();
|
|
200
|
-
});
|
|
201
|
-
});
|
|
55
|
+
var Component = (props, { element }) => {
|
|
56
|
+
if (!Array.isArray(props.range) || !ANIMATABLE_KEYS.some((key) => Array.isArray(Reflect.get(props, key)))) return console.warn(`parallax-animation: needs an array \`range\` and at least one of ${ANIMATABLE_KEYS.join(",")} as an array of values!`, element);
|
|
57
|
+
const messages = ANIMATABLE_KEYS.reduce((messages, key) => {
|
|
58
|
+
const value = Reflect.get(props, key);
|
|
59
|
+
if (value && value.length !== props.range.length) return messages.concat(`${key} attribute must have the same length as range attribute!`);
|
|
60
|
+
return messages;
|
|
61
|
+
}, []);
|
|
62
|
+
if (messages.length) return console.warn(element, `\nparallax-animate: Please fix the following issues:\n${messages.join("\n")}`);
|
|
63
|
+
const [progress, { animate }] = useParallaxStickyLayer(element);
|
|
64
|
+
const [activeBreakpoints, setActiveBreakpoints] = createStore(getActiveBreakpoints(props.breakpoints));
|
|
65
|
+
const activeBreakpointIndex = createMemo(() => getLastTruthyIndex(activeBreakpoints));
|
|
66
|
+
const importantProps = omit(props, "breakpoints");
|
|
67
|
+
const animateableProps = merge(importantProps, {});
|
|
68
|
+
const activeProps = createMemo(() => {
|
|
69
|
+
const index = activeBreakpointIndex();
|
|
70
|
+
if (index === -1) {
|
|
71
|
+
const { breakpoints, ...active } = PROPS;
|
|
72
|
+
return active;
|
|
73
|
+
}
|
|
74
|
+
return ACTIVE_KEYS.reduce((active, key) => {
|
|
75
|
+
const value = animateableProps[key];
|
|
76
|
+
if (isNestedAnimatableArray(value)) {
|
|
77
|
+
const flattenedValue = flattenAnimatableArray(value, index);
|
|
78
|
+
return {
|
|
79
|
+
...active,
|
|
80
|
+
[key]: flattenedValue
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
...active,
|
|
85
|
+
[key]: value
|
|
86
|
+
};
|
|
87
|
+
}, {});
|
|
88
|
+
});
|
|
89
|
+
createGuardedEffect(() => props.breakpoints, (breakpoints) => {
|
|
90
|
+
const controller = new AbortController();
|
|
91
|
+
for (let i = 0; i < breakpoints.length; i++) {
|
|
92
|
+
const query = breakpoints[i];
|
|
93
|
+
if (!query) continue;
|
|
94
|
+
window.matchMedia(query).addEventListener("change", (e) => setActiveBreakpoints((draft) => {
|
|
95
|
+
draft[i] = e.matches;
|
|
96
|
+
}), { signal: controller.signal });
|
|
97
|
+
}
|
|
98
|
+
return () => {
|
|
99
|
+
controller.abort();
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
element.style.willChange = "transform";
|
|
103
|
+
if (window.getComputedStyle(element).getPropertyValue("display") === "inline") element.style.display = "block";
|
|
104
|
+
createGuardedEffect(activeProps, (active) => {
|
|
105
|
+
const { range, ...props } = active;
|
|
106
|
+
/**
|
|
107
|
+
* WCAG 2.3.3: scroll-driven parallax is motion from interaction, so a
|
|
108
|
+
* reduced-motion preference has to be able to turn it off.
|
|
109
|
+
*
|
|
110
|
+
* The values freeze at the *end* of their range rather than the start.
|
|
111
|
+
* A fade authored as `opacity="[0,1]"` frozen at the start would hide
|
|
112
|
+
* the content outright, which is worse than the motion it replaces —
|
|
113
|
+
* the end is the state the author meant the reader to arrive at.
|
|
114
|
+
*/
|
|
115
|
+
const reduceMotion = shouldReduceMotion();
|
|
116
|
+
const valueSubscribers = [];
|
|
117
|
+
let disposed = false;
|
|
118
|
+
const progressValue = Object.keys(PROP_DEFAULTS).reduce((values, key) => {
|
|
119
|
+
const fallback = Reflect.get(PROP_DEFAULTS, key);
|
|
120
|
+
const valueRange = Reflect.get(props, key);
|
|
121
|
+
if (valueRange?.length === range.length) {
|
|
122
|
+
const transform$1 = transform(range, valueRange);
|
|
123
|
+
if (reduceMotion) {
|
|
124
|
+
values[key] = motionValue(transform$1(range[range.length - 1] ?? 1));
|
|
125
|
+
return values;
|
|
126
|
+
}
|
|
127
|
+
const value = motionValue(transform$1(progress.get()));
|
|
128
|
+
const unsub = progress.on("change", (latest) => {
|
|
129
|
+
value.set(transform$1(latest));
|
|
130
|
+
});
|
|
131
|
+
valueSubscribers.push(unsub);
|
|
132
|
+
values[key] = value;
|
|
133
|
+
} else values[key] = fallback;
|
|
134
|
+
return values;
|
|
135
|
+
}, {});
|
|
136
|
+
const animated = Object.keys(progressValue).reduce((obj, key) => {
|
|
137
|
+
const v = progressValue[key];
|
|
138
|
+
Reflect.set(obj, key, motionValue(typeof v === "object" && v !== null ? v.get() : v));
|
|
139
|
+
return obj;
|
|
140
|
+
}, {});
|
|
141
|
+
const transform$2 = transformValue(() => `translate(${animated.x?.get()}, ${animated.y?.get()}) scale(${animated.scale?.get()}) rotate(${animated.rotate?.get()}deg)`);
|
|
142
|
+
function animateValues() {
|
|
143
|
+
if (disposed) return;
|
|
144
|
+
const sequence = Object.keys(animated).map((key) => {
|
|
145
|
+
const subject = animated[key];
|
|
146
|
+
const v = progressValue[key]?.get?.();
|
|
147
|
+
if (!subject) return null;
|
|
148
|
+
if (typeof v === "undefined" || v === null) return null;
|
|
149
|
+
if (typeof v !== "string" && typeof v !== "number") return null;
|
|
150
|
+
return [
|
|
151
|
+
animated[key],
|
|
152
|
+
v,
|
|
153
|
+
{ at: "<" }
|
|
154
|
+
];
|
|
155
|
+
}).filter((v) => v !== null);
|
|
156
|
+
if (sequence.length === 0) return;
|
|
157
|
+
animate(sequence);
|
|
158
|
+
}
|
|
159
|
+
function scheduleAnimation() {
|
|
160
|
+
frame.update(animateValues);
|
|
161
|
+
}
|
|
162
|
+
let unsub = () => {};
|
|
163
|
+
if (reduceMotion) scheduleAnimation();
|
|
164
|
+
else unsub = progress.on("change", (_) => {
|
|
165
|
+
scheduleAnimation();
|
|
166
|
+
});
|
|
167
|
+
const styledValues = Object.keys(animated).filter((key) => key !== "y" && key !== "x" && key !== "rotate" && key !== "scale").reduce((obj, key) => {
|
|
168
|
+
Reflect.set(obj, key, animated[key]);
|
|
169
|
+
return obj;
|
|
170
|
+
}, {});
|
|
171
|
+
const unstyle = styleEffect(element, {
|
|
172
|
+
transform: transform$2,
|
|
173
|
+
...styledValues
|
|
174
|
+
});
|
|
175
|
+
return () => {
|
|
176
|
+
disposed = true;
|
|
177
|
+
unstyle();
|
|
178
|
+
unsub();
|
|
179
|
+
valueSubscribers.forEach((unsub) => {
|
|
180
|
+
unsub();
|
|
181
|
+
});
|
|
182
|
+
Object.values(animated).forEach((value) => {
|
|
183
|
+
value.destroy();
|
|
184
|
+
});
|
|
185
|
+
Object.values(progressValue).forEach((value) => {
|
|
186
|
+
value?.destroy?.();
|
|
187
|
+
});
|
|
188
|
+
transform$2.destroy();
|
|
189
|
+
};
|
|
190
|
+
});
|
|
202
191
|
};
|
|
203
|
-
|
|
192
|
+
//#endregion
|
|
204
193
|
export { Component, Name, PROPS };
|
|
205
|
-
|
|
194
|
+
|
|
206
195
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/parallax-animation/index.ts"],"names":["messages","active","props","transform","mTransform","unsub","_"],"mappings":";;;;;;AA8CA,SAAS,eAAiC,MAAwB,EAAA;AACjE,EAAO,OAAA,MAAA,CAAO,KAAK,MAAM,CAAA;AAC1B;AAEO,MAAM,IAAO,GAAA,CAAA,kBAAA;AAEb,MAAM,KAAQ,GAAA;AAAA,EACpB,WAAA,EAAa,CAAC,EAAE,CAAA;A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B,MAAW,QAAA,GAAA,IAAA;AACX,MAAQ,OAAA,EAAA;AACR,MAAM,KAAA,EAAA;AACN,MAAiB,gBAAA,CAAA,OAAA,CAAQ,CAACE,MAAU,KAAA;AACnC,QAAAA,MAAM,EAAA;AAAA,OACN,CAAA;AACD,MAAA,MAAA,CAAO,MAAO,CAAA,QAAQ,CAAE,CAAA,OAAA,CAAQ,CAAC,KAAU,KAAA;AAC1C,QAAA,KAAA,CAAM,OAAQ,EAAA;AAAA,OACd,CAAA;AACD,MAAA,MAAA,CAAO,MAAO,CAAA,aAAa,CAAE,CAAA,OAAA,CAAQ,CAAC,KAAU,KAAA;AAC/C,QAAA,KAAA,EAAO,OAAU,IAAA;AAAA,OACjB,CAAA;AACD,MAAAF,WAAA,CAAU,OAAQ,EAAA;AAAA,KAClB,CAAA;AAAA,GACD,CAAA;AACF","file":"index.js","sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\nimport {\n\tframe,\n\ttype MotionValue,\n\tmotionValue,\n\ttransform as mTransform,\n\tstyleEffect,\n\ttransformValue,\n} from \"motion\";\nimport {\n\tcreateEffect,\n\tcreateMemo,\n\tmergeProps,\n\tonCleanup,\n\tsplitProps,\n} from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\n\nimport { useParallaxStickyLayer } from \"../../hooks/index.js\";\nimport { getActiveBreakpoints, getLastTruthyIndex } from \"../../utils.js\";\n\ntype AnimatableArray = Array<string | number> | null;\n\nexport type Props = {\n\tbreakpoints: string[];\n\trange: number[] | number[][];\n\ty: AnimatableArray | AnimatableArray[];\n\tx: AnimatableArray | AnimatableArray[];\n\tscale: AnimatableArray | AnimatableArray[];\n\trotate: AnimatableArray | AnimatableArray[];\n\topacity: AnimatableArray | AnimatableArray[];\n\tbackgroundColor: AnimatableArray | AnimatableArray[];\n\tborderRadius: AnimatableArray | AnimatableArray[];\n};\n\ntype ActiveProps = {\n\trange: number[];\n\ty: AnimatableArray;\n\tx: AnimatableArray;\n\tscale: AnimatableArray;\n\trotate: AnimatableArray;\n\topacity: AnimatableArray;\n\tbackgroundColor: AnimatableArray;\n\tborderRadius: AnimatableArray;\n};\n\nfunction keysFromObject<T extends object>(object: T): (keyof T)[] {\n\treturn Object.keys(object) as (keyof T)[];\n}\n\nexport const Name = `parallax-animation`;\n\nexport const PROPS = {\n\tbreakpoints: [\"\"],\n\trange: [0, 1],\n\ty: null,\n\tx: null,\n\tscale: null,\n\trotate: null,\n\topacity: null,\n\tcolor: null,\n\tbackgroundColor: null,\n\tborderRadius: null,\n};\n\nconst PROP_DEFAULTS = {\n\ty: \"0%\",\n\tx: \"0%\",\n\tscale: 1,\n\trotate: 0,\n\topacity: null,\n\tcolor: null,\n\tbackgroundColor: null,\n\tborderRadius: null,\n};\n\nconst KEYS = Object.keys(PROPS);\n\nconst isNestedAnimatableArray = (\n\tvalues: AnimatableArray | AnimatableArray[],\n): values is AnimatableArray[] => {\n\treturn (\n\t\tArray.isArray(values) && (Array.isArray(values[0]) || values[0] === null)\n\t);\n};\n\nconst flattenAnimatableArray = (\n\tvalue: AnimatableArray | AnimatableArray[],\n\tindex: number = 0,\n) => {\n\tif (isNestedAnimatableArray(value)) {\n\t\treturn value[index]!;\n\t}\n\treturn value;\n};\n\nexport const Component: CorrectComponentType<Props> = (props, { element }) => {\n\tif (\n\t\tObject.keys(props).some(\n\t\t\t(key) => KEYS.includes(key) && !Array.isArray(Reflect.get(props, key)),\n\t\t)\n\t)\n\t\treturn console.warn(\n\t\t\t`parallax-animate: At least one of ${KEYS.join(\",\")} properties is required and must be an array of values!`,\n\t\t\telement,\n\t\t);\n\n\tconst messages = Object.entries(props).reduce((messages, [key, value]) => {\n\t\tif (!KEYS.includes(key)) return messages;\n\t\tif (value && value.length !== props.range.length) {\n\t\t\treturn messages.concat(\n\t\t\t\t`${key} attribute must have the same length as range attribute!`,\n\t\t\t);\n\t\t}\n\t\treturn messages;\n\t}, [] as string[]);\n\n\tif (messages.length)\n\t\treturn console.warn(\n\t\t\telement,\n\t\t\t`\\nparallax-animate: Please fix the following issues:\\n${messages.join(\"\\n\")}`,\n\t\t);\n\n\tconst [progress, { animate }] = useParallaxStickyLayer(element);\n\n\tconst [activeBreakpoints, setActiveBreakpoints] = createStore<boolean[]>(\n\t\tgetActiveBreakpoints(props.breakpoints),\n\t);\n\tconst activeBreakpointIndex = createMemo(() =>\n\t\tgetLastTruthyIndex(activeBreakpoints),\n\t);\n\n\tconst [_, importantProps] = splitProps(props, [\"breakpoints\"]);\n\tconst animateableProps = mergeProps(importantProps, {});\n\n\tconst activeProps = createMemo<ActiveProps>(() => {\n\t\tconst index = activeBreakpointIndex();\n\n\t\tif (index === -1) {\n\t\t\tconst { breakpoints, ...active } = PROPS;\n\t\t\treturn active;\n\t\t}\n\n\t\tconst keys = keysFromObject(animateableProps);\n\n\t\tconst active = keys.reduce((active, key) => {\n\t\t\tconst value = animateableProps[key];\n\t\t\tif (isNestedAnimatableArray(value)) {\n\t\t\t\tconst flattenedValue = flattenAnimatableArray(value, index);\n\t\t\t\treturn {\n\t\t\t\t\t...active,\n\t\t\t\t\t[key]: flattenedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...active,\n\t\t\t\t[key]: value,\n\t\t\t};\n\t\t}, {} as ActiveProps);\n\n\t\treturn active;\n\t});\n\n\tcreateEffect(() => {\n\t\tconst breakpoints = props.breakpoints;\n\t\tconst controller = new AbortController();\n\n\t\tfor (let i = 0; i < breakpoints.length; i++) {\n\t\t\tconst query = breakpoints[i];\n\t\t\tif (!query) continue;\n\t\t\tconst mediaQuery = window.matchMedia(query);\n\t\t\tmediaQuery.addEventListener(\n\t\t\t\t\"change\",\n\t\t\t\t(e) => setActiveBreakpoints(i, e.matches),\n\t\t\t\t{ signal: controller.signal },\n\t\t\t);\n\t\t}\n\n\t\treturn onCleanup(() => {\n\t\t\tcontroller.abort();\n\t\t});\n\t});\n\n\telement.style.willChange = \"transform\";\n\tif (\n\t\twindow.getComputedStyle(element).getPropertyValue(\"display\") === \"inline\"\n\t) {\n\t\telement.style.display = \"block\";\n\t}\n\n\tcreateEffect(() => {\n\t\tconst active = activeProps();\n\t\tconst { range, ...props } = active;\n\t\tconst valueSubscribers: VoidFunction[] = [];\n\t\tlet disposed = false;\n\n\t\tconst progressValue = Object.keys(PROP_DEFAULTS).reduce(\n\t\t\t(values, key) => {\n\t\t\t\tconst fallback = Reflect.get(PROP_DEFAULTS, key);\n\t\t\t\tconst valueRange = Reflect.get(props, key);\n\t\t\t\tif (valueRange?.length === range.length) {\n\t\t\t\t\tconst transform = mTransform(range, valueRange);\n\t\t\t\t\tconst value = motionValue(transform(progress.get()));\n\t\t\t\t\tconst unsub = progress.on(\"change\", (latest) => {\n\t\t\t\t\t\tvalue.set(transform(latest));\n\t\t\t\t\t});\n\t\t\t\t\tvalueSubscribers.push(unsub);\n\t\t\t\t\tvalues[key] = value;\n\t\t\t\t} else values[key] = fallback;\n\t\t\t\treturn values;\n\t\t\t},\n\t\t\t{} as Record<string, any>,\n\t\t);\n\n\t\tconst animated = Object.keys(progressValue).reduce(\n\t\t\t(obj, key) => {\n\t\t\t\tconst v = progressValue[key];\n\t\t\t\tReflect.set(\n\t\t\t\t\tobj,\n\t\t\t\t\tkey,\n\t\t\t\t\tmotionValue(typeof v === \"object\" && v !== null ? v.get() : v),\n\t\t\t\t);\n\t\t\t\treturn obj;\n\t\t\t},\n\t\t\t{} as Record<string, MotionValue>,\n\t\t);\n\n\t\tconst transform = transformValue(\n\t\t\t() =>\n\t\t\t\t`translate(${animated.x?.get()}, ${animated.y?.get()}) scale(${animated.scale?.get()}) rotate(${animated.rotate?.get()}deg)`,\n\t\t);\n\n\t\tfunction animateValues() {\n\t\t\tif (disposed) return;\n\n\t\t\tconst sequence = Object.keys(animated)\n\t\t\t\t.map((key) => {\n\t\t\t\t\tconst subject = animated[key];\n\t\t\t\t\tconst v = progressValue[key]?.get?.();\n\t\t\t\t\tif (!subject) return null;\n\t\t\t\t\tif (typeof v === \"undefined\" || v === null) return null;\n\t\t\t\t\tif (typeof v !== \"string\" && typeof v !== \"number\") return null;\n\t\t\t\t\treturn [animated[key], v, { at: \"<\" }];\n\t\t\t\t})\n\t\t\t\t.filter((v) => v !== null);\n\n\t\t\tif (sequence.length === 0) return;\n\t\t\t//@ts-expect-error\n\t\t\tanimate(sequence);\n\t\t}\n\n\t\tfunction scheduleAnimation() {\n\t\t\tframe.update(animateValues);\n\t\t}\n\n\t\tconst unsub = progress.on(\"change\", (_) => {\n\t\t\tscheduleAnimation();\n\t\t});\n\n\t\tconst styledValues = Object.keys(animated)\n\t\t\t.filter(\n\t\t\t\t(key) =>\n\t\t\t\t\tkey !== \"y\" && key !== \"x\" && key !== \"rotate\" && key !== \"scale\",\n\t\t\t)\n\t\t\t.reduce((obj, key) => {\n\t\t\t\tReflect.set(obj, key, animated[key]);\n\t\t\t\treturn obj;\n\t\t\t}, {});\n\n\t\tconst unstyle = styleEffect(element, {\n\t\t\ttransform,\n\t\t\t...styledValues,\n\t\t});\n\n\t\treturn onCleanup(() => {\n\t\t\tdisposed = true;\n\t\t\tunstyle();\n\t\t\tunsub();\n\t\t\tvalueSubscribers.forEach((unsub) => {\n\t\t\t\tunsub();\n\t\t\t});\n\t\t\tObject.values(animated).forEach((value) => {\n\t\t\t\tvalue.destroy();\n\t\t\t});\n\t\t\tObject.values(progressValue).forEach((value) => {\n\t\t\t\tvalue?.destroy?.();\n\t\t\t});\n\t\t\ttransform.destroy();\n\t\t});\n\t});\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/parallax-animation/index.ts"],"sourcesContent":["import { shouldReduceMotion } from \"@brytdesigns/web-component-core/animation\";\nimport type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\nimport { createGuardedEffect } from \"@brytdesigns/web-component-core/utils\";\nimport {\n\tframe,\n\ttype MotionValue,\n\tmotionValue,\n\ttransform as mTransform,\n\tstyleEffect,\n\ttransformValue,\n} from \"motion\";\nimport { createMemo, createStore, merge, omit } from \"solid-js\";\n\nimport { useParallaxStickyLayer } from \"../../hooks/index.js\";\nimport { getActiveBreakpoints, getLastTruthyIndex } from \"../../utils.js\";\n\ntype AnimatableArray = Array<string | number> | null;\n\nexport type Props = {\n\tbreakpoints: string[];\n\trange: number[] | number[][];\n\ty: AnimatableArray | AnimatableArray[];\n\tx: AnimatableArray | AnimatableArray[];\n\tscale: AnimatableArray | AnimatableArray[];\n\trotate: AnimatableArray | AnimatableArray[];\n\topacity: AnimatableArray | AnimatableArray[];\n\tbackgroundColor: AnimatableArray | AnimatableArray[];\n\tborderRadius: AnimatableArray | AnimatableArray[];\n};\n\ntype ActiveProps = {\n\trange: number[];\n\ty: AnimatableArray;\n\tx: AnimatableArray;\n\tscale: AnimatableArray;\n\trotate: AnimatableArray;\n\topacity: AnimatableArray;\n\tbackgroundColor: AnimatableArray;\n\tborderRadius: AnimatableArray;\n};\n\nexport const Name = `parallax-animation`;\n\nexport const PROPS = {\n\tbreakpoints: [\"\"],\n\trange: [0, 1],\n\ty: null,\n\tx: null,\n\tscale: null,\n\trotate: null,\n\topacity: null,\n\tcolor: null,\n\tbackgroundColor: null,\n\tborderRadius: null,\n};\n\nconst PROP_DEFAULTS = {\n\ty: \"0%\",\n\tx: \"0%\",\n\tscale: 1,\n\trotate: 0,\n\topacity: null,\n\tcolor: null,\n\tbackgroundColor: null,\n\tborderRadius: null,\n};\n\nconst KEYS = Object.keys(PROPS);\n\n/**\n * Solid 2 defines an element's props as own accessors that are **not\n * enumerable**, so `Object.keys(props)` and `Object.entries(props)` both come\n * back empty — and `merge()` returns a proxy reporting no own keys at all,\n * even to `Reflect.ownKeys`. Reading a property works on both. Nothing throws\n * and nothing warns; the loops simply do not run.\n *\n * So every key list below comes from the declared prop names. Enumerating a\n * props object here silently validated nothing and produced an `activeProps`\n * with no `range`, which threw inside the animation effect and halted the\n * whole reactive system for the page.\n */\nconst CONFIG_KEYS: readonly string[] = [\"breakpoints\", \"range\"];\nconst ANIMATABLE_KEYS = KEYS.filter((key) => !CONFIG_KEYS.includes(key));\nconst ACTIVE_KEYS = KEYS.filter((key) => key !== \"breakpoints\");\n\nconst isNestedAnimatableArray = (\n\tvalues: AnimatableArray | AnimatableArray[],\n): values is AnimatableArray[] => {\n\treturn (\n\t\tArray.isArray(values) && (Array.isArray(values[0]) || values[0] === null)\n\t);\n};\n\nconst flattenAnimatableArray = (\n\tvalue: AnimatableArray | AnimatableArray[],\n\tindex: number = 0,\n) => {\n\tif (isNestedAnimatableArray(value)) {\n\t\treturn value[index]!;\n\t}\n\treturn value;\n};\n\nexport const Component: CorrectComponentType<Props> = (props, { element }) => {\n\tif (\n\t\t!Array.isArray(props.range) ||\n\t\t!ANIMATABLE_KEYS.some((key) => Array.isArray(Reflect.get(props, key)))\n\t)\n\t\treturn console.warn(\n\t\t\t`parallax-animation: needs an array ${\"`range`\"} and at least one of ${ANIMATABLE_KEYS.join(\",\")} as an array of values!`,\n\t\t\telement,\n\t\t);\n\n\tconst messages = ANIMATABLE_KEYS.reduce((messages, key) => {\n\t\tconst value = Reflect.get(props, key) as\n\t\t\t| AnimatableArray\n\t\t\t| AnimatableArray[]\n\t\t\t| undefined;\n\t\tif (value && value.length !== props.range.length) {\n\t\t\treturn messages.concat(\n\t\t\t\t`${key} attribute must have the same length as range attribute!`,\n\t\t\t);\n\t\t}\n\t\treturn messages;\n\t}, [] as string[]);\n\n\tif (messages.length)\n\t\treturn console.warn(\n\t\t\telement,\n\t\t\t`\\nparallax-animate: Please fix the following issues:\\n${messages.join(\"\\n\")}`,\n\t\t);\n\n\tconst [progress, { animate }] = useParallaxStickyLayer(element);\n\n\tconst [activeBreakpoints, setActiveBreakpoints] = createStore<boolean[]>(\n\t\tgetActiveBreakpoints(props.breakpoints),\n\t);\n\tconst activeBreakpointIndex = createMemo(() =>\n\t\tgetLastTruthyIndex(activeBreakpoints),\n\t);\n\n\t// `omit` returns the rest, which is exactly what this discarded the\n\t// picked half to get.\n\tconst importantProps = omit(props, \"breakpoints\");\n\tconst animateableProps = merge(importantProps, {});\n\n\tconst activeProps = createMemo<ActiveProps>(() => {\n\t\tconst index = activeBreakpointIndex();\n\n\t\tif (index === -1) {\n\t\t\tconst { breakpoints, ...active } = PROPS;\n\t\t\treturn active;\n\t\t}\n\n\t\tconst keys = ACTIVE_KEYS as (keyof ActiveProps)[];\n\n\t\tconst active = keys.reduce((active, key) => {\n\t\t\tconst value = animateableProps[key];\n\t\t\tif (isNestedAnimatableArray(value)) {\n\t\t\t\tconst flattenedValue = flattenAnimatableArray(value, index);\n\t\t\t\treturn {\n\t\t\t\t\t...active,\n\t\t\t\t\t[key]: flattenedValue,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...active,\n\t\t\t\t[key]: value,\n\t\t\t};\n\t\t}, {} as ActiveProps);\n\n\t\treturn active;\n\t});\n\n\tcreateGuardedEffect(\n\t\t() => props.breakpoints,\n\t\t(breakpoints) => {\n\t\t\tconst controller = new AbortController();\n\n\t\t\tfor (let i = 0; i < breakpoints.length; i++) {\n\t\t\t\tconst query = breakpoints[i];\n\t\t\t\tif (!query) continue;\n\t\t\t\tconst mediaQuery = window.matchMedia(query);\n\t\t\t\tmediaQuery.addEventListener(\n\t\t\t\t\t\"change\",\n\t\t\t\t\t// v2 store setters are draft-first: no path arguments.\n\t\t\t\t\t(e) =>\n\t\t\t\t\t\tsetActiveBreakpoints((draft) => {\n\t\t\t\t\t\t\tdraft[i] = e.matches;\n\t\t\t\t\t\t}),\n\t\t\t\t\t{ signal: controller.signal },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\tcontroller.abort();\n\t\t\t};\n\t\t},\n\t);\n\n\telement.style.willChange = \"transform\";\n\tif (\n\t\twindow.getComputedStyle(element).getPropertyValue(\"display\") === \"inline\"\n\t) {\n\t\telement.style.display = \"block\";\n\t}\n\n\tcreateGuardedEffect(activeProps, (active) => {\n\t\tconst { range, ...props } = active;\n\n\t\t/**\n\t\t * WCAG 2.3.3: scroll-driven parallax is motion from interaction, so a\n\t\t * reduced-motion preference has to be able to turn it off.\n\t\t *\n\t\t * The values freeze at the *end* of their range rather than the start.\n\t\t * A fade authored as `opacity=\"[0,1]\"` frozen at the start would hide\n\t\t * the content outright, which is worse than the motion it replaces —\n\t\t * the end is the state the author meant the reader to arrive at.\n\t\t */\n\t\tconst reduceMotion = shouldReduceMotion();\n\t\tconst valueSubscribers: VoidFunction[] = [];\n\t\tlet disposed = false;\n\n\t\tconst progressValue = Object.keys(PROP_DEFAULTS).reduce(\n\t\t\t(values, key) => {\n\t\t\t\tconst fallback = Reflect.get(PROP_DEFAULTS, key);\n\t\t\t\tconst valueRange = Reflect.get(props, key);\n\t\t\t\tif (valueRange?.length === range.length) {\n\t\t\t\t\tconst transform = mTransform(range, valueRange);\n\t\t\t\t\tif (reduceMotion) {\n\t\t\t\t\t\tvalues[key] = motionValue(transform(range[range.length - 1] ?? 1));\n\t\t\t\t\t\treturn values;\n\t\t\t\t\t}\n\t\t\t\t\tconst value = motionValue(transform(progress.get()));\n\t\t\t\t\tconst unsub = progress.on(\"change\", (latest) => {\n\t\t\t\t\t\tvalue.set(transform(latest));\n\t\t\t\t\t});\n\t\t\t\t\tvalueSubscribers.push(unsub);\n\t\t\t\t\tvalues[key] = value;\n\t\t\t\t} else values[key] = fallback;\n\t\t\t\treturn values;\n\t\t\t},\n\t\t\t{} as Record<string, any>,\n\t\t);\n\n\t\tconst animated = Object.keys(progressValue).reduce(\n\t\t\t(obj, key) => {\n\t\t\t\tconst v = progressValue[key];\n\t\t\t\tReflect.set(\n\t\t\t\t\tobj,\n\t\t\t\t\tkey,\n\t\t\t\t\tmotionValue(typeof v === \"object\" && v !== null ? v.get() : v),\n\t\t\t\t);\n\t\t\t\treturn obj;\n\t\t\t},\n\t\t\t{} as Record<string, MotionValue>,\n\t\t);\n\n\t\tconst transform = transformValue(\n\t\t\t() =>\n\t\t\t\t`translate(${animated.x?.get()}, ${animated.y?.get()}) scale(${animated.scale?.get()}) rotate(${animated.rotate?.get()}deg)`,\n\t\t);\n\n\t\tfunction animateValues() {\n\t\t\tif (disposed) return;\n\n\t\t\tconst sequence = Object.keys(animated)\n\t\t\t\t.map((key) => {\n\t\t\t\t\tconst subject = animated[key];\n\t\t\t\t\tconst v = progressValue[key]?.get?.();\n\t\t\t\t\tif (!subject) return null;\n\t\t\t\t\tif (typeof v === \"undefined\" || v === null) return null;\n\t\t\t\t\tif (typeof v !== \"string\" && typeof v !== \"number\") return null;\n\t\t\t\t\treturn [animated[key], v, { at: \"<\" }];\n\t\t\t\t})\n\t\t\t\t.filter((v) => v !== null);\n\n\t\t\tif (sequence.length === 0) return;\n\t\t\t//@ts-expect-error\n\t\t\tanimate(sequence);\n\t\t}\n\n\t\tfunction scheduleAnimation() {\n\t\t\tframe.update(animateValues);\n\t\t}\n\n\t\tlet unsub: VoidFunction = () => {};\n\t\tif (reduceMotion) {\n\t\t\t// Applied once, then nothing tracks the scroll at all.\n\t\t\tscheduleAnimation();\n\t\t} else {\n\t\t\tunsub = progress.on(\"change\", (_) => {\n\t\t\t\tscheduleAnimation();\n\t\t\t});\n\t\t}\n\n\t\tconst styledValues = Object.keys(animated)\n\t\t\t.filter(\n\t\t\t\t(key) =>\n\t\t\t\t\tkey !== \"y\" && key !== \"x\" && key !== \"rotate\" && key !== \"scale\",\n\t\t\t)\n\t\t\t.reduce((obj, key) => {\n\t\t\t\tReflect.set(obj, key, animated[key]);\n\t\t\t\treturn obj;\n\t\t\t}, {});\n\n\t\tconst unstyle = styleEffect(element, {\n\t\t\ttransform,\n\t\t\t...styledValues,\n\t\t});\n\n\t\treturn () => {\n\t\t\tdisposed = true;\n\t\t\tunstyle();\n\t\t\tunsub();\n\t\t\tvalueSubscribers.forEach((unsub) => {\n\t\t\t\tunsub();\n\t\t\t});\n\t\t\tObject.values(animated).forEach((value) => {\n\t\t\t\tvalue.destroy();\n\t\t\t});\n\t\t\tObject.values(progressValue).forEach((value) => {\n\t\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8
|
-
|
|
9
|
-
|
|
10
|
-
if (props.maxPages < 1)
|
|
11
|
-
return console.warn(
|
|
12
|
-
`${Name}: max-pages must be greater than or equal to 1!`,
|
|
13
|
-
element
|
|
14
|
-
);
|
|
15
|
-
provideParallaxContext(props, element);
|
|
1
|
+
import { provideParallaxContext } from "../../hooks/useParallax.js";
|
|
2
|
+
import "../../hooks/index.js";
|
|
3
|
+
import { untrack } from "solid-js";
|
|
4
|
+
//#region src/components/parallax-container/index.ts
|
|
5
|
+
var Name = `parallax-container`;
|
|
6
|
+
var Component = (props, { element }) => {
|
|
7
|
+
if (untrack(() => !props.maxPages)) return console.warn(`${Name}: requires max-pages attribute to be set!`, element);
|
|
8
|
+
if (props.maxPages < 1) return console.warn(`${Name}: max-pages must be greater than or equal to 1!`, element);
|
|
9
|
+
provideParallaxContext(props, element);
|
|
16
10
|
};
|
|
17
|
-
|
|
11
|
+
//#endregion
|
|
18
12
|
export { Component, Name };
|
|
19
|
-
|
|
13
|
+
|
|
20
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/parallax-container/index.ts"],"sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\nimport { untrack } from \"solid-js\";\nimport { provideParallaxContext } from \"../../hooks/index.js\";\n\nexport type Props = {\n\tmaxPages: number;\n};\n\nexport const Name = `parallax-container`;\n\nexport const Component: CorrectComponentType<Props> = (props, { element }) => {\n\tif (untrack(() => !props.maxPages))\n\t\treturn console.warn(\n\t\t\t`${Name}: requires max-pages attribute to be set!`,\n\t\t\telement,\n\t\t);\n\tif (props.maxPages < 1)\n\t\treturn console.warn(\n\t\t\t`${Name}: max-pages must be greater than or equal to 1!`,\n\t\t\telement,\n\t\t);\n\tprovideParallaxContext(props, element);\n};\n"],"mappings":";;;;AAQA,IAAa,OAAO;AAEpB,IAAa,aAA0C,OAAO,EAAE,cAAc;CAC7E,IAAI,cAAc,CAAC,MAAM,QAAQ,GAChC,OAAO,QAAQ,KACd,GAAG,KAAK,4CACR,OACD;CACD,IAAI,MAAM,WAAW,GACpB,OAAO,QAAQ,KACd,GAAG,KAAK,kDACR,OACD;CACD,uBAAuB,OAAO,OAAO;AACtC"}
|
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import { provideParallaxStickyLayerContext } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (props.end <= props.start)
|
|
13
|
-
return console.warn(
|
|
14
|
-
`${Name}: the start attribute must be less than the end attribute!`,
|
|
15
|
-
element
|
|
16
|
-
);
|
|
17
|
-
if (props.start < 1 || props.end < 1)
|
|
18
|
-
return console.warn(
|
|
19
|
-
`${Name}: The start and end attributes must be greater than or equal to 1!`,
|
|
20
|
-
element
|
|
21
|
-
);
|
|
22
|
-
provideParallaxStickyLayerContext(props, element);
|
|
1
|
+
import { provideParallaxStickyLayerContext } from "../../hooks/useParallaxStickyLayer.js";
|
|
2
|
+
import "../../hooks/index.js";
|
|
3
|
+
import { untrack } from "solid-js";
|
|
4
|
+
//#region src/components/parallax-sticky-layer/index.ts
|
|
5
|
+
var Name = `parallax-sticky-layer`;
|
|
6
|
+
var Component = (props, { element }) => {
|
|
7
|
+
if (untrack(() => !props.start)) return console.warn(`${Name}: requires start attribute to be set!`, element);
|
|
8
|
+
if (untrack(() => !props.end)) return console.warn(`${Name}: requires end attribute to be set!`, element);
|
|
9
|
+
if (props.end <= props.start) return console.warn(`${Name}: the start attribute must be less than the end attribute!`, element);
|
|
10
|
+
if (props.start < 1 || props.end < 1) return console.warn(`${Name}: The start and end attributes must be greater than or equal to 1!`, element);
|
|
11
|
+
provideParallaxStickyLayerContext(props, element);
|
|
23
12
|
};
|
|
24
|
-
|
|
13
|
+
//#endregion
|
|
25
14
|
export { Component, Name };
|
|
26
|
-
|
|
15
|
+
|
|
27
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/parallax-sticky-layer/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/parallax-sticky-layer/index.ts"],"sourcesContent":["import type { CorrectComponentType } from \"@brytdesigns/web-component-core/utils\";\nimport { untrack } from \"solid-js\";\nimport { provideParallaxStickyLayerContext } from \"../../hooks/index.js\";\n\nexport type Props = {\n\tstart: number;\n\tend: number;\n};\n\nexport const Name = `parallax-sticky-layer`;\n\nexport const Component: CorrectComponentType<Props> = (props, { element }) => {\n\tif (untrack(() => !props.start))\n\t\treturn console.warn(\n\t\t\t`${Name}: requires start attribute to be set!`,\n\t\t\telement,\n\t\t);\n\tif (untrack(() => !props.end))\n\t\treturn console.warn(`${Name}: requires end attribute to be set!`, element);\n\tif (props.end <= props.start)\n\t\treturn console.warn(\n\t\t\t`${Name}: the start attribute must be less than the end attribute!`,\n\t\t\telement,\n\t\t);\n\tif (props.start < 1 || props.end < 1)\n\t\treturn console.warn(\n\t\t\t`${Name}: The start and end attributes must be greater than or equal to 1!`,\n\t\t\telement,\n\t\t);\n\tprovideParallaxStickyLayerContext(props, element);\n};\n"],"mappings":";;;;AASA,IAAa,OAAO;AAEpB,IAAa,aAA0C,OAAO,EAAE,cAAc;CAC7E,IAAI,cAAc,CAAC,MAAM,KAAK,GAC7B,OAAO,QAAQ,KACd,GAAG,KAAK,wCACR,OACD;CACD,IAAI,cAAc,CAAC,MAAM,GAAG,GAC3B,OAAO,QAAQ,KAAK,GAAG,KAAK,sCAAsC,OAAO;CAC1E,IAAI,MAAM,OAAO,MAAM,OACtB,OAAO,QAAQ,KACd,GAAG,KAAK,6DACR,OACD;CACD,IAAI,MAAM,QAAQ,KAAK,MAAM,MAAM,GAClC,OAAO,QAAQ,KACd,GAAG,KAAK,qEACR,OACD;CACD,kCAAkC,OAAO,OAAO;AACjD"}
|
package/dist/main/hooks/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { getParallaxContext, provideParallaxContext, useParallax, useParallaxAt, useParallaxContext } from "./useParallax.js";
|
|
2
|
+
import { getParallaxStickyLayerContext, provideParallaxStickyLayerContext, useParallaxStickyLayer, useParallaxStickyLayerAt, useParallaxStickyLayerContext } from "./useParallaxStickyLayer.js";
|
|
3
|
+
export { getParallaxContext, getParallaxStickyLayerContext, provideParallaxContext, provideParallaxStickyLayerContext, useParallax, useParallaxAt, useParallaxContext, useParallaxStickyLayer, useParallaxStickyLayerAt, useParallaxStickyLayerContext };
|