@studiometa/ui 1.6.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/Accordion/Accordion.d.ts +1 -1
- package/Accordion/Accordion.js.map +1 -1
- package/Action/Action.d.ts +1 -1
- package/Action/Action.js.map +1 -1
- package/AnchorNav/AnchorNav.d.ts +1 -1
- package/AnchorNav/AnchorNav.js.map +1 -1
- package/AnchorScrollTo/AnchorScrollTo.d.ts +1 -1
- package/AnchorScrollTo/AnchorScrollTo.js.map +1 -1
- package/CircularMarquee/CircularMarquee.d.ts +1 -1
- package/CircularMarquee/CircularMarquee.js.map +1 -1
- package/Cursor/Cursor.d.ts +1 -1
- package/Cursor/Cursor.js.map +1 -1
- package/Data/DataBind.d.ts +2 -2
- package/Data/DataBind.js.map +1 -1
- package/Draggable/Draggable.d.ts +1 -1
- package/Draggable/Draggable.js.map +1 -1
- package/Fetch/Fetch.d.ts +18 -18
- package/Fetch/Fetch.js.map +2 -2
- package/Fetch/utils.js +1 -4
- package/Fetch/utils.js.map +2 -2
- package/Figure/Figure.d.ts +1 -1
- package/Figure/Figure.js.map +1 -1
- package/Figure/FigureShopify.d.ts +1 -1
- package/Figure/FigureShopify.js.map +1 -1
- package/Figure/FigureTwicpics.d.ts +1 -1
- package/Figure/FigureTwicpics.js.map +1 -1
- package/FigureVideo/FigureVideo.d.ts +1 -1
- package/FigureVideo/FigureVideo.js.map +1 -1
- package/FigureVideo/FigureVideoTwicpics.d.ts +1 -1
- package/FigureVideo/FigureVideoTwicpics.js.map +1 -1
- package/Frame/Frame.d.ts +5 -5
- package/Frame/Frame.js.map +1 -1
- package/Frame/FrameForm.d.ts +1 -1
- package/Frame/FrameTarget.d.ts +4 -4
- package/Frame/FrameTarget.js.map +2 -2
- package/Hoverable/Hoverable.d.ts +1 -1
- package/Hoverable/Hoverable.js.map +1 -1
- package/LargeText/LargeText.d.ts +1 -1
- package/LargeText/LargeText.js.map +1 -1
- package/LazyInclude/LazyInclude.d.ts +1 -1
- package/LazyInclude/LazyInclude.js.map +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/Menu/Menu.js.map +1 -1
- package/Menu/MenuList.js +1 -0
- package/Menu/MenuList.js.map +2 -2
- package/Modal/Modal.d.ts +1 -1
- package/Modal/Modal.js.map +1 -1
- package/Panel/Panel.d.ts +1 -1
- package/Panel/Panel.js.map +1 -1
- package/Prefetch/AbstractPrefetch.d.ts +1 -1
- package/Prefetch/AbstractPrefetch.js.map +1 -1
- package/Prefetch/PrefetchWhenOver.d.ts +1 -1
- package/Prefetch/PrefetchWhenOver.js.map +1 -1
- package/Prefetch/PrefetchWhenVisible.d.ts +1 -1
- package/Prefetch/PrefetchWhenVisible.js.map +1 -1
- package/README.md +1 -1
- 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 +7 -1
- 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/ScrollReveal/ScrollReveal.d.ts +1 -1
- package/ScrollReveal/ScrollReveal.js.map +1 -1
- package/Sentinel/Sentinel.d.ts +1 -1
- package/Sentinel/Sentinel.js.map +1 -1
- package/Slider/Slider.d.ts +1 -1
- package/Slider/Slider.js.map +1 -1
- package/Sticky/Sticky.d.ts +1 -1
- package/Sticky/Sticky.js.map +1 -1
- package/Tabs/Tabs.d.ts +1 -1
- package/Tabs/Tabs.js.map +1 -1
- package/Transition/Transition.d.ts +23 -1
- package/Transition/Transition.js.map +2 -2
- package/decorators/withTransition.d.ts +11 -0
- package/decorators/withTransition.js +49 -0
- package/decorators/withTransition.js.map +2 -2
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Base, withFreezedOptions } from "@studiometa/js-toolkit";
|
|
2
|
-
import { map, clamp01, animate } from "@studiometa/js-toolkit/utils";
|
|
2
|
+
import { map, clamp01, animate, nextTick } from "@studiometa/js-toolkit/utils";
|
|
3
3
|
class AbstractScrollAnimation extends withFreezedOptions(Base) {
|
|
4
4
|
/**
|
|
5
5
|
* Config.
|
|
@@ -28,6 +28,24 @@ class AbstractScrollAnimation extends withFreezedOptions(Base) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Current animation progress (0 to 1).
|
|
33
|
+
*/
|
|
34
|
+
progress = 0;
|
|
35
|
+
/**
|
|
36
|
+
* Constructor.
|
|
37
|
+
*/
|
|
38
|
+
constructor(element) {
|
|
39
|
+
super(element);
|
|
40
|
+
this.$on("mounted", () => {
|
|
41
|
+
this.render(this.progress);
|
|
42
|
+
});
|
|
43
|
+
this.$on("destroyed", () => {
|
|
44
|
+
nextTick(() => {
|
|
45
|
+
this.render(Math.round(this.progress));
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
31
49
|
/**
|
|
32
50
|
* Get the target element for the animation.
|
|
33
51
|
*/
|
|
@@ -73,6 +91,7 @@ class AbstractScrollAnimation extends withFreezedOptions(Base) {
|
|
|
73
91
|
* Render the animation for the given progress.
|
|
74
92
|
*/
|
|
75
93
|
render(progress) {
|
|
94
|
+
this.progress = progress;
|
|
76
95
|
this.animation.progress(progress);
|
|
77
96
|
}
|
|
78
97
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/ScrollAnimation/AbstractScrollAnimation.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base, withFreezedOptions } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, ScrollInViewProps } from '@studiometa/js-toolkit';\nimport { map, clamp01, animate } from '@studiometa/js-toolkit/utils';\nimport type { Keyframe } from '@studiometa/js-toolkit/utils';\n\nexport interface AbstractScrollAnimationProps extends BaseProps {\n $options: {\n playRange: [number, number] | [number, number, number];\n from: Keyframe;\n to: Keyframe;\n keyframes: Keyframe[];\n easing: [number, number, number, number];\n };\n}\n\n/**\n * AbstractScrollAnimation class.\n */\nexport class AbstractScrollAnimation<\n T extends BaseProps = BaseProps,\n> extends withFreezedOptions<Base>(Base)<T & AbstractScrollAnimationProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AbstractScrollAnimation',\n options: {\n playRange: {\n type: Array,\n default: () => [0, 1],\n },\n from: {\n type: Object,\n default: () => ({}),\n },\n to: {\n type: Object,\n default: () => ({}),\n },\n keyframes: {\n type: Array,\n },\n easing: {\n type: Array,\n default: () => [0, 0, 1, 1],\n },\n },\n };\n\n /**\n * Get the target element for the animation.\n */\n get target() {\n return this.$el as HTMLElement;\n }\n\n /**\n * Lazily get animation.\n */\n get animation(): ReturnType<typeof animate> {\n let { keyframes } = this.$options;\n const { from, to } = this.$options;\n\n if (keyframes.length <= 0 && from && to) {\n keyframes = [from, to];\n }\n\n const animation = animate(this.target, keyframes, { easing: this.$options.easing });\n\n Object.defineProperty(this, 'animation', {\n value: animation,\n configurable: true,\n });\n\n return animation;\n }\n\n get playRange(): [number, number] {\n const { playRange } = this.$options;\n\n let start = 0;\n let end = 1;\n\n if (playRange.length === 3) {\n const [index, length, step] = playRange;\n const clampedStep = clamp01(step);\n const duration = Math.max(0, 1 - clampedStep * (length - 1));\n start = clampedStep * index;\n end = Math.min(1, start + duration);\n } else if (playRange.length === 2) {\n [start, end] = playRange;\n }\n\n return [start, end];\n }\n\n scrolledInView({ dampedProgress }: ScrollInViewProps) {\n const [start, end] = this.playRange;\n this.render(clamp01(map(dampedProgress.y, start, end, 0, 1)));\n }\n\n /**\n * Render the animation for the given progress.\n */\n render(progress: number) {\n this.animation.progress(progress);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,MAAM,0BAA0B;AAEzC,SAAS,KAAK,SAAS,
|
|
4
|
+
"sourcesContent": ["import { Base, withFreezedOptions } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, ScrollInViewProps } from '@studiometa/js-toolkit';\nimport { map, clamp01, animate, nextTick } from '@studiometa/js-toolkit/utils';\nimport type { Keyframe } from '@studiometa/js-toolkit/utils';\n\nexport interface AbstractScrollAnimationProps extends BaseProps {\n $options: {\n playRange: [number, number] | [number, number, number];\n from: Keyframe;\n to: Keyframe;\n keyframes: Keyframe[];\n easing: [number, number, number, number];\n };\n}\n\n/**\n * AbstractScrollAnimation class.\n */\nexport class AbstractScrollAnimation<\n T extends BaseProps = BaseProps,\n> extends withFreezedOptions<Base>(Base)<T & AbstractScrollAnimationProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AbstractScrollAnimation',\n options: {\n playRange: {\n type: Array,\n default: () => [0, 1],\n },\n from: {\n type: Object,\n default: () => ({}),\n },\n to: {\n type: Object,\n default: () => ({}),\n },\n keyframes: {\n type: Array,\n },\n easing: {\n type: Array,\n default: () => [0, 0, 1, 1],\n },\n },\n };\n\n /**\n * Current animation progress (0 to 1).\n */\n progress = 0;\n\n /**\n * Constructor.\n */\n constructor(element: HTMLElement) {\n super(element);\n\n // Restore animation state on mount\n this.$on('mounted', () => {\n this.render(this.progress);\n });\n\n // Complete animation to nearest boundary on destroy\n this.$on('destroyed', () => {\n nextTick(() => {\n this.render(Math.round(this.progress));\n });\n });\n }\n\n /**\n * Get the target element for the animation.\n */\n get target() {\n return this.$el as HTMLElement;\n }\n\n /**\n * Lazily get animation.\n */\n get animation(): ReturnType<typeof animate> {\n let { keyframes } = this.$options;\n const { from, to } = this.$options;\n\n if (keyframes.length <= 0 && from && to) {\n keyframes = [from, to];\n }\n\n const animation = animate(this.target, keyframes, { easing: this.$options.easing });\n\n Object.defineProperty(this, 'animation', {\n value: animation,\n configurable: true,\n });\n\n return animation;\n }\n\n get playRange(): [number, number] {\n const { playRange } = this.$options;\n\n let start = 0;\n let end = 1;\n\n if (playRange.length === 3) {\n const [index, length, step] = playRange;\n const clampedStep = clamp01(step);\n const duration = Math.max(0, 1 - clampedStep * (length - 1));\n start = clampedStep * index;\n end = Math.min(1, start + duration);\n } else if (playRange.length === 2) {\n [start, end] = playRange;\n }\n\n return [start, end];\n }\n\n scrolledInView({ dampedProgress }: ScrollInViewProps) {\n const [start, end] = this.playRange;\n this.render(clamp01(map(dampedProgress.y, start, end, 0, 1)));\n }\n\n /**\n * Render the animation for the given progress.\n */\n render(progress: number) {\n this.progress = progress;\n this.animation.progress(progress);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,MAAM,0BAA0B;AAEzC,SAAS,KAAK,SAAS,SAAS,gBAAgB;AAgBzC,MAAM,gCAEH,mBAAyB,IAAI,EAAoC;AAAA;AAAA;AAAA;AAAA,EAIzE,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,WAAW;AAAA,QACT,MAAM;AAAA,QACN,SAAS,MAAM,CAAC,GAAG,CAAC;AAAA,MACtB;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,SAAS,OAAO,CAAC;AAAA,MACnB;AAAA,MACA,IAAI;AAAA,QACF,MAAM;AAAA,QACN,SAAS,OAAO,CAAC;AAAA,MACnB;AAAA,MACA,WAAW;AAAA,QACT,MAAM;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,SAAS,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AAAA;AAAA;AAAA;AAAA,EAKX,YAAY,SAAsB;AAChC,UAAM,OAAO;AAGb,SAAK,IAAI,WAAW,MAAM;AACxB,WAAK,OAAO,KAAK,QAAQ;AAAA,IAC3B,CAAC;AAGD,SAAK,IAAI,aAAa,MAAM;AAC1B,eAAS,MAAM;AACb,aAAK,OAAO,KAAK,MAAM,KAAK,QAAQ,CAAC;AAAA,MACvC,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAwC;AAC1C,QAAI,EAAE,UAAU,IAAI,KAAK;AACzB,UAAM,EAAE,MAAM,GAAG,IAAI,KAAK;AAE1B,QAAI,UAAU,UAAU,KAAK,QAAQ,IAAI;AACvC,kBAAY,CAAC,MAAM,EAAE;AAAA,IACvB;AAEA,UAAM,YAAY,QAAQ,KAAK,QAAQ,WAAW,EAAE,QAAQ,KAAK,SAAS,OAAO,CAAC;AAElF,WAAO,eAAe,MAAM,aAAa;AAAA,MACvC,OAAO;AAAA,MACP,cAAc;AAAA,IAChB,CAAC;AAED,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,YAA8B;AAChC,UAAM,EAAE,UAAU,IAAI,KAAK;AAE3B,QAAI,QAAQ;AACZ,QAAI,MAAM;AAEV,QAAI,UAAU,WAAW,GAAG;AAC1B,YAAM,CAAC,OAAO,QAAQ,IAAI,IAAI;AAC9B,YAAM,cAAc,QAAQ,IAAI;AAChC,YAAM,WAAW,KAAK,IAAI,GAAG,IAAI,eAAe,SAAS,EAAE;AAC3D,cAAQ,cAAc;AACtB,YAAM,KAAK,IAAI,GAAG,QAAQ,QAAQ;AAAA,IACpC,WAAW,UAAU,WAAW,GAAG;AACjC,OAAC,OAAO,GAAG,IAAI;AAAA,IACjB;AAEA,WAAO,CAAC,OAAO,GAAG;AAAA,EACpB;AAAA,EAEA,eAAe,EAAE,eAAe,GAAsB;AACpD,UAAM,CAAC,OAAO,GAAG,IAAI,KAAK;AAC1B,SAAK,OAAO,QAAQ,IAAI,eAAe,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,UAAkB;AACvB,SAAK,WAAW;AAChB,SAAK,UAAU,SAAS,QAAQ;AAAA,EAClC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,9 @@ export interface ScrollAnimationProps extends BaseProps {
|
|
|
8
8
|
declare const ScrollAnimation_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithScrolledInViewInterface, AbstractScrollAnimation<BaseProps>, import("@studiometa/js-toolkit").WithScrolledInViewProps>;
|
|
9
9
|
/**
|
|
10
10
|
* ScrollAnimation class.
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
|
+
* @deprecated Use `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead.
|
|
13
|
+
* @link https://ui.studiometa.dev/components/ScrollAnimation/
|
|
12
14
|
*/
|
|
13
15
|
export declare class ScrollAnimation<T extends BaseProps = BaseProps> extends ScrollAnimation_base<T & ScrollAnimationProps> {
|
|
14
16
|
/**
|
|
@@ -19,5 +21,9 @@ export declare class ScrollAnimation<T extends BaseProps = BaseProps> extends Sc
|
|
|
19
21
|
* Use the `target` ref as animation target.
|
|
20
22
|
*/
|
|
21
23
|
get target(): HTMLElement;
|
|
24
|
+
/**
|
|
25
|
+
* Display deprecation warning.
|
|
26
|
+
*/
|
|
27
|
+
mounted(): void;
|
|
22
28
|
}
|
|
23
29
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { withScrolledInView } from "@studiometa/js-toolkit";
|
|
2
|
+
import { isDev } from "@studiometa/js-toolkit/utils";
|
|
2
3
|
import { AbstractScrollAnimation } from "./AbstractScrollAnimation.js";
|
|
3
4
|
class ScrollAnimation extends withScrolledInView(AbstractScrollAnimation, {}) {
|
|
4
5
|
/**
|
|
@@ -15,6 +16,17 @@ class ScrollAnimation extends withScrolledInView(AbstractScrollAnimation, {}) {
|
|
|
15
16
|
get target() {
|
|
16
17
|
return this.$refs.target;
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Display deprecation warning.
|
|
21
|
+
*/
|
|
22
|
+
mounted() {
|
|
23
|
+
if (isDev) {
|
|
24
|
+
console.warn(
|
|
25
|
+
`The ${this.$options.name} component is deprecated.`,
|
|
26
|
+
"\nUse `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead."
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
export {
|
|
20
32
|
ScrollAnimation
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimation.ts"],
|
|
4
|
-
"sourcesContent": ["import { withScrolledInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { AbstractScrollAnimation } from './AbstractScrollAnimation.js';\n\nexport interface ScrollAnimationProps extends BaseProps {\n $refs: {\n target: HTMLElement;\n };\n}\n\n/**\n * ScrollAnimation class.\n * @link https://ui.studiometa.dev
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,SAAS,+BAA+B;
|
|
4
|
+
"sourcesContent": ["import { withScrolledInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { isDev } from '@studiometa/js-toolkit/utils';\nimport { AbstractScrollAnimation } from './AbstractScrollAnimation.js';\n\nexport interface ScrollAnimationProps extends BaseProps {\n $refs: {\n target: HTMLElement;\n };\n}\n\n/**\n * ScrollAnimation class.\n *\n * @deprecated Use `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead.\n * @link https://ui.studiometa.dev/components/ScrollAnimation/\n */\nexport class ScrollAnimation<\n T extends BaseProps = BaseProps,\n> extends withScrolledInView<AbstractScrollAnimation>(AbstractScrollAnimation, {})<\n T & ScrollAnimationProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractScrollAnimation.config,\n name: 'ScrollAnimation',\n refs: ['target'],\n };\n\n /**\n * Use the `target` ref as animation target.\n */\n get target(): HTMLElement {\n return this.$refs.target;\n }\n\n /**\n * Display deprecation warning.\n */\n mounted() {\n if (isDev) {\n console.warn(\n `The ${this.$options.name} component is deprecated.`,\n '\\nUse `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead.',\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,SAAS,aAAa;AACtB,SAAS,+BAA+B;AAcjC,MAAM,wBAEH,mBAA4C,yBAAyB,CAAC,CAAC,EAE/E;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,wBAAwB;AAAA,IAC3B,MAAM;AAAA,IACN,MAAM,CAAC,QAAQ;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAsB;AACxB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,QAAI,OAAO;AACT,cAAQ;AAAA,QACN,OAAO,KAAK,SAAS,IAAI;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,6 +5,8 @@ export interface ScrollAnimationChildProps extends BaseProps {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* ScrollAnimationChild class.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Use `ScrollAnimationTarget` instead.
|
|
8
10
|
*/
|
|
9
11
|
export declare class ScrollAnimationChild<T extends BaseProps = BaseProps> extends AbstractScrollAnimation<T & ScrollAnimationChildProps> {
|
|
10
12
|
/**
|
|
@@ -19,6 +21,10 @@ export declare class ScrollAnimationChild<T extends BaseProps = BaseProps> exten
|
|
|
19
21
|
* Local damped progress.
|
|
20
22
|
*/
|
|
21
23
|
dampedProgress: ScrollInViewProps['dampedCurrent'];
|
|
24
|
+
/**
|
|
25
|
+
* Display deprecation warning.
|
|
26
|
+
*/
|
|
27
|
+
mounted(): void;
|
|
22
28
|
/**
|
|
23
29
|
* Compute local damped progress.
|
|
24
30
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { damp, clamp01, domScheduler } from "@studiometa/js-toolkit/utils";
|
|
1
|
+
import { damp, clamp01, domScheduler, isDev } from "@studiometa/js-toolkit/utils";
|
|
2
2
|
import { AbstractScrollAnimation } from "./AbstractScrollAnimation.js";
|
|
3
3
|
function updateProps(that, props, dampFactor, dampPrecision, axis = "x") {
|
|
4
4
|
that.dampedCurrent[axis] = damp(
|
|
@@ -44,6 +44,17 @@ class ScrollAnimationChild extends AbstractScrollAnimation {
|
|
|
44
44
|
x: 0,
|
|
45
45
|
y: 0
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Display deprecation warning.
|
|
49
|
+
*/
|
|
50
|
+
mounted() {
|
|
51
|
+
if (isDev) {
|
|
52
|
+
console.warn(
|
|
53
|
+
`The ${this.$options.name} component is deprecated.`,
|
|
54
|
+
"\nUse `ScrollAnimationTarget` instead."
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
/**
|
|
48
59
|
* Compute local damped progress.
|
|
49
60
|
*/
|
|
@@ -52,11 +63,13 @@ class ScrollAnimationChild extends AbstractScrollAnimation {
|
|
|
52
63
|
const { dampFactor, dampPrecision } = this.$options;
|
|
53
64
|
updateProps(this, props, dampFactor, dampPrecision, "x");
|
|
54
65
|
updateProps(this, props, dampFactor, dampPrecision, "y");
|
|
55
|
-
props.dampedCurrent = this.dampedCurrent;
|
|
56
|
-
props.dampedProgress = this.dampedProgress;
|
|
57
66
|
});
|
|
58
67
|
domScheduler.write(() => {
|
|
59
|
-
super.scrolledInView(
|
|
68
|
+
super.scrolledInView({
|
|
69
|
+
...props,
|
|
70
|
+
dampedCurrent: this.dampedCurrent,
|
|
71
|
+
dampedProgress: this.dampedProgress
|
|
72
|
+
});
|
|
60
73
|
});
|
|
61
74
|
}
|
|
62
75
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimationChild.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n BaseConfig,\n BaseProps,\n ScrollInViewProps,\n WithScrolledInViewProps,\n} from '@studiometa/js-toolkit';\nimport { damp, clamp01, domScheduler } from '@studiometa/js-toolkit/utils';\nimport { AbstractScrollAnimation } from './AbstractScrollAnimation.js';\n\nexport interface ScrollAnimationChildProps extends BaseProps {\n $options: WithScrolledInViewProps['$options'];\n}\n\nfunction updateProps(\n // eslint-disable-next-line no-use-before-define\n that: ScrollAnimationChild,\n props: ScrollInViewProps,\n dampFactor: number,\n dampPrecision: number,\n axis: 'x' | 'y' = 'x',\n) {\n that.dampedCurrent[axis] = damp(\n props.current[axis],\n that.dampedCurrent[axis],\n dampFactor,\n dampPrecision,\n );\n that.dampedProgress[axis] = clamp01(\n (that.dampedCurrent[axis] - props.start[axis]) / (props.end[axis] - props.start[axis]),\n );\n}\n\n/**\n * ScrollAnimationChild class.\n */\nexport class ScrollAnimationChild<T extends BaseProps = BaseProps> extends AbstractScrollAnimation<\n T & ScrollAnimationChildProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'ScrollAnimationChild',\n ...AbstractScrollAnimation.config,\n options: {\n ...AbstractScrollAnimation.config.options,\n dampFactor: {\n type: Number,\n default: 0.1,\n },\n dampPrecision: {\n type: Number,\n default: 0.001,\n },\n },\n };\n\n /**\n * Local damped current values.\n */\n dampedCurrent: ScrollInViewProps['dampedCurrent'] = {\n x: 0,\n y: 0,\n };\n\n /**\n * Local damped progress.\n */\n dampedProgress: ScrollInViewProps['dampedCurrent'] = {\n x: 0,\n y: 0,\n };\n\n /**\n * Compute local damped progress.\n */\n scrolledInView(props: ScrollInViewProps) {\n domScheduler.read(() => {\n const { dampFactor, dampPrecision } = this.$options;\n updateProps(this, props, dampFactor, dampPrecision, 'x');\n updateProps(this, props, dampFactor, dampPrecision, 'y');\n
|
|
5
|
-
"mappings": "AAMA,SAAS,MAAM,SAAS,
|
|
4
|
+
"sourcesContent": ["import type {\n BaseConfig,\n BaseProps,\n ScrollInViewProps,\n WithScrolledInViewProps,\n} from '@studiometa/js-toolkit';\nimport { damp, clamp01, domScheduler, isDev } from '@studiometa/js-toolkit/utils';\nimport { AbstractScrollAnimation } from './AbstractScrollAnimation.js';\n\nexport interface ScrollAnimationChildProps extends BaseProps {\n $options: WithScrolledInViewProps['$options'];\n}\n\nfunction updateProps(\n // eslint-disable-next-line no-use-before-define\n that: ScrollAnimationChild,\n props: ScrollInViewProps,\n dampFactor: number,\n dampPrecision: number,\n axis: 'x' | 'y' = 'x',\n) {\n that.dampedCurrent[axis] = damp(\n props.current[axis],\n that.dampedCurrent[axis],\n dampFactor,\n dampPrecision,\n );\n that.dampedProgress[axis] = clamp01(\n (that.dampedCurrent[axis] - props.start[axis]) / (props.end[axis] - props.start[axis]),\n );\n}\n\n/**\n * ScrollAnimationChild class.\n *\n * @deprecated Use `ScrollAnimationTarget` instead.\n */\nexport class ScrollAnimationChild<T extends BaseProps = BaseProps> extends AbstractScrollAnimation<\n T & ScrollAnimationChildProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'ScrollAnimationChild',\n ...AbstractScrollAnimation.config,\n options: {\n ...AbstractScrollAnimation.config.options,\n dampFactor: {\n type: Number,\n default: 0.1,\n },\n dampPrecision: {\n type: Number,\n default: 0.001,\n },\n },\n };\n\n /**\n * Local damped current values.\n */\n dampedCurrent: ScrollInViewProps['dampedCurrent'] = {\n x: 0,\n y: 0,\n };\n\n /**\n * Local damped progress.\n */\n dampedProgress: ScrollInViewProps['dampedCurrent'] = {\n x: 0,\n y: 0,\n };\n\n /**\n * Display deprecation warning.\n */\n mounted() {\n if (isDev) {\n console.warn(\n `The ${this.$options.name} component is deprecated.`,\n '\\nUse `ScrollAnimationTarget` instead.',\n );\n }\n }\n\n /**\n * Compute local damped progress.\n */\n scrolledInView(props: ScrollInViewProps) {\n domScheduler.read(() => {\n const { dampFactor, dampPrecision } = this.$options;\n updateProps(this, props, dampFactor, dampPrecision, 'x');\n updateProps(this, props, dampFactor, dampPrecision, 'y');\n });\n\n domScheduler.write(() => {\n super.scrolledInView({\n ...props,\n dampedCurrent: this.dampedCurrent,\n dampedProgress: this.dampedProgress,\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,MAAM,SAAS,cAAc,aAAa;AACnD,SAAS,+BAA+B;AAMxC,SAAS,YAEP,MACA,OACA,YACA,eACA,OAAkB,KAClB;AACA,OAAK,cAAc,IAAI,IAAI;AAAA,IACzB,MAAM,QAAQ,IAAI;AAAA,IAClB,KAAK,cAAc,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,OAAK,eAAe,IAAI,IAAI;AAAA,KACzB,KAAK,cAAc,IAAI,IAAI,MAAM,MAAM,IAAI,MAAM,MAAM,IAAI,IAAI,IAAI,MAAM,MAAM,IAAI;AAAA,EACtF;AACF;AAOO,MAAM,6BAA8D,wBAEzE;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,GAAG,wBAAwB;AAAA,IAC3B,SAAS;AAAA,MACP,GAAG,wBAAwB,OAAO;AAAA,MAClC,YAAY;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,eAAe;AAAA,QACb,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAoD;AAAA,IAClD,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAqD;AAAA,IACnD,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,QAAI,OAAO;AACT,cAAQ;AAAA,QACN,OAAO,KAAK,SAAS,IAAI;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,OAA0B;AACvC,iBAAa,KAAK,MAAM;AACtB,YAAM,EAAE,YAAY,cAAc,IAAI,KAAK;AAC3C,kBAAY,MAAM,OAAO,YAAY,eAAe,GAAG;AACvD,kBAAY,MAAM,OAAO,YAAY,eAAe,GAAG;AAAA,IACzD,CAAC;AAED,iBAAa,MAAM,MAAM;AACvB,YAAM,eAAe;AAAA,QACnB,GAAG;AAAA,QACH,eAAe,KAAK;AAAA,QACpB,gBAAgB,KAAK;AAAA,MACvB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { BaseConfig } from '@studiometa/js-toolkit';
|
|
2
2
|
declare const ScrollAnimationChildWithEase_base: import("@studiometa/js-toolkit").BaseDecorator<import("#private/index.js").AnimationScrollWithEaseInterface, import("#private/index.js").AbstractScrollAnimation<import("@studiometa/js-toolkit").BaseProps>, import("#private/index.js").AnimationScrollWithEaseProps>;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* ScrollAnimationChildWithEase class.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated Use `ScrollAnimationTarget` instead.
|
|
5
7
|
*/
|
|
6
8
|
export declare class ScrollAnimationChildWithEase extends ScrollAnimationChildWithEase_base {
|
|
7
9
|
/**
|
|
8
10
|
* Config.
|
|
9
11
|
*/
|
|
10
12
|
static config: BaseConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Display deprecation warning.
|
|
15
|
+
*/
|
|
16
|
+
mounted(): void;
|
|
11
17
|
}
|
|
12
18
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDev } from "@studiometa/js-toolkit/utils";
|
|
1
2
|
import { ScrollAnimationChild } from "./ScrollAnimationChild.js";
|
|
2
3
|
import { animationScrollWithEase } from "./animationScrollWithEase.js";
|
|
3
4
|
class ScrollAnimationChildWithEase extends animationScrollWithEase(ScrollAnimationChild) {
|
|
@@ -8,6 +9,17 @@ class ScrollAnimationChildWithEase extends animationScrollWithEase(ScrollAnimati
|
|
|
8
9
|
...ScrollAnimationChild.config,
|
|
9
10
|
name: "ScrollAnimationChildWithEase"
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Display deprecation warning.
|
|
14
|
+
*/
|
|
15
|
+
mounted() {
|
|
16
|
+
if (isDev) {
|
|
17
|
+
console.warn(
|
|
18
|
+
`The ${this.$options.name} component is deprecated.`,
|
|
19
|
+
"\nUse `ScrollAnimationTarget` instead."
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
}
|
|
12
24
|
export {
|
|
13
25
|
ScrollAnimationChildWithEase
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimationChildWithEase.ts"],
|
|
4
|
-
"sourcesContent": ["import type { BaseConfig } from '@studiometa/js-toolkit';\nimport { ScrollAnimationChild } from './ScrollAnimationChild.js';\nimport { animationScrollWithEase } from './animationScrollWithEase.js';\n\n/**\n *
|
|
5
|
-
"mappings": "AACA,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;
|
|
4
|
+
"sourcesContent": ["import type { BaseConfig } from '@studiometa/js-toolkit';\nimport { isDev } from '@studiometa/js-toolkit/utils';\nimport { ScrollAnimationChild } from './ScrollAnimationChild.js';\nimport { animationScrollWithEase } from './animationScrollWithEase.js';\n\n/**\n * ScrollAnimationChildWithEase class.\n *\n * @deprecated Use `ScrollAnimationTarget` instead.\n */\nexport class ScrollAnimationChildWithEase extends animationScrollWithEase(ScrollAnimationChild) {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...ScrollAnimationChild.config,\n name: 'ScrollAnimationChildWithEase',\n };\n\n /**\n * Display deprecation warning.\n */\n mounted() {\n if (isDev) {\n console.warn(\n `The ${this.$options.name} component is deprecated.`,\n '\\nUse `ScrollAnimationTarget` instead.',\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,aAAa;AACtB,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAOjC,MAAM,qCAAqC,wBAAwB,oBAAoB,EAAE;AAAA;AAAA;AAAA;AAAA,EAI9F,OAAO,SAAqB;AAAA,IAC1B,GAAG,qBAAqB;AAAA,IACxB,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,QAAI,OAAO;AACT,cAAQ;AAAA,QACN,OAAO,KAAK,SAAS,IAAI;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,12 +9,18 @@ export interface ScrollAnimationParentProps extends BaseProps {
|
|
|
9
9
|
declare const ScrollAnimationParent_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithScrolledInViewInterface, Base<BaseProps>, import("@studiometa/js-toolkit").WithScrolledInViewProps>;
|
|
10
10
|
/**
|
|
11
11
|
* ScrollAnimationParent class.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Use `ScrollAnimationTimeline` instead.
|
|
12
14
|
*/
|
|
13
15
|
export declare class ScrollAnimationParent<T extends BaseProps = BaseProps> extends ScrollAnimationParent_base<T & ScrollAnimationParentProps> {
|
|
14
16
|
/**
|
|
15
17
|
* Config.
|
|
16
18
|
*/
|
|
17
19
|
static config: BaseConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Display deprecation warning.
|
|
22
|
+
*/
|
|
23
|
+
mounted(): void;
|
|
18
24
|
/**
|
|
19
25
|
* Scrolled in view hook.
|
|
20
26
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Base, withScrolledInView } from "@studiometa/js-toolkit";
|
|
2
|
+
import { isDev } from "@studiometa/js-toolkit/utils";
|
|
2
3
|
import { ScrollAnimationChild } from "./ScrollAnimationChild.js";
|
|
3
4
|
class ScrollAnimationParent extends withScrolledInView(
|
|
4
5
|
Base,
|
|
@@ -13,6 +14,17 @@ class ScrollAnimationParent extends withScrolledInView(
|
|
|
13
14
|
ScrollAnimationChild
|
|
14
15
|
}
|
|
15
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Display deprecation warning.
|
|
19
|
+
*/
|
|
20
|
+
mounted() {
|
|
21
|
+
if (isDev) {
|
|
22
|
+
console.warn(
|
|
23
|
+
`The ${this.$options.name} component is deprecated.`,
|
|
24
|
+
"\nUse `ScrollAnimationTimeline` instead."
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
16
28
|
/**
|
|
17
29
|
* Scrolled in view hook.
|
|
18
30
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimationParent.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base, ScrollInViewProps, withScrolledInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { ScrollAnimationChild } from './ScrollAnimationChild.js';\n\nexport interface ScrollAnimationParentProps extends BaseProps {\n $children: {\n ScrollAnimationChild: ScrollAnimationChild[];\n };\n}\n\n/**\n * ScrollAnimationParent class.\n */\nexport class ScrollAnimationParent<T extends BaseProps = BaseProps> extends withScrolledInView(\n Base,\n {},\n)<T & ScrollAnimationParentProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'ScrollAnimationParent',\n components: {\n ScrollAnimationChild,\n },\n };\n\n /**\n * Scrolled in view hook.\n */\n scrolledInView(props: ScrollInViewProps) {\n for (const child of this.$children.ScrollAnimationChild) {\n child.scrolledInView(props);\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,MAAyB,0BAA0B;AAE5D,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["import { Base, ScrollInViewProps, withScrolledInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { isDev } from '@studiometa/js-toolkit/utils';\nimport { ScrollAnimationChild } from './ScrollAnimationChild.js';\n\nexport interface ScrollAnimationParentProps extends BaseProps {\n $children: {\n ScrollAnimationChild: ScrollAnimationChild[];\n };\n}\n\n/**\n * ScrollAnimationParent class.\n *\n * @deprecated Use `ScrollAnimationTimeline` instead.\n */\nexport class ScrollAnimationParent<T extends BaseProps = BaseProps> extends withScrolledInView(\n Base,\n {},\n)<T & ScrollAnimationParentProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'ScrollAnimationParent',\n components: {\n ScrollAnimationChild,\n },\n };\n\n /**\n * Display deprecation warning.\n */\n mounted() {\n if (isDev) {\n console.warn(\n `The ${this.$options.name} component is deprecated.`,\n '\\nUse `ScrollAnimationTimeline` instead.',\n );\n }\n }\n\n /**\n * Scrolled in view hook.\n */\n scrolledInView(props: ScrollInViewProps) {\n for (const child of this.$children.ScrollAnimationChild) {\n child.scrolledInView(props);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,MAAyB,0BAA0B;AAE5D,SAAS,aAAa;AACtB,SAAS,4BAA4B;AAa9B,MAAM,8BAA+D;AAAA,EAC1E;AAAA,EACA,CAAC;AACH,EAAkC;AAAA;AAAA;AAAA;AAAA,EAIhC,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,YAAY;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,QAAI,OAAO;AACT,cAAQ;AAAA,QACN,OAAO,KAAK,SAAS,IAAI;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,OAA0B;AACvC,eAAW,SAAS,KAAK,UAAU,sBAAsB;AACvD,YAAM,eAAe,KAAK;AAAA,IAC5B;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { BaseConfig, BaseProps, ScrollInViewProps, WithScrolledInViewProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import { AbstractScrollAnimation } from './AbstractScrollAnimation.js';
|
|
3
|
+
export interface ScrollAnimationTargetProps extends BaseProps {
|
|
4
|
+
$options: WithScrolledInViewProps['$options'];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* ScrollAnimationTarget class.
|
|
8
|
+
*
|
|
9
|
+
* A component that animates based on scroll progress from a parent `ScrollAnimationTimeline`.
|
|
10
|
+
* Each target can have its own animation keyframes and play range.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```html
|
|
14
|
+
* <div data-component="ScrollAnimationTimeline">
|
|
15
|
+
* <div
|
|
16
|
+
* data-component="ScrollAnimationTarget"
|
|
17
|
+
* data-option-from='{"opacity": 0, "transform": "translateY(20px)"}'
|
|
18
|
+
* data-option-to='{"opacity": 1, "transform": "translateY(0)"}'
|
|
19
|
+
* data-option-play-range='[0, 0.5]'
|
|
20
|
+
* >
|
|
21
|
+
* Animated content
|
|
22
|
+
* </div>
|
|
23
|
+
* </div>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class ScrollAnimationTarget<T extends BaseProps = BaseProps> extends AbstractScrollAnimation<T & ScrollAnimationTargetProps> {
|
|
27
|
+
/**
|
|
28
|
+
* Config.
|
|
29
|
+
*/
|
|
30
|
+
static config: BaseConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Local damped current values.
|
|
33
|
+
*/
|
|
34
|
+
dampedCurrent: ScrollInViewProps['dampedCurrent'];
|
|
35
|
+
/**
|
|
36
|
+
* Local damped progress.
|
|
37
|
+
*/
|
|
38
|
+
dampedProgress: ScrollInViewProps['dampedCurrent'];
|
|
39
|
+
/**
|
|
40
|
+
* Compute local damped progress.
|
|
41
|
+
*/
|
|
42
|
+
scrolledInView(props: ScrollInViewProps): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { damp, clamp01, domScheduler } from "@studiometa/js-toolkit/utils";
|
|
2
|
+
import { AbstractScrollAnimation } from "./AbstractScrollAnimation.js";
|
|
3
|
+
function updateProps(that, props, dampFactor, dampPrecision, axis = "x") {
|
|
4
|
+
that.dampedCurrent[axis] = damp(
|
|
5
|
+
props.current[axis],
|
|
6
|
+
that.dampedCurrent[axis],
|
|
7
|
+
dampFactor,
|
|
8
|
+
dampPrecision
|
|
9
|
+
);
|
|
10
|
+
that.dampedProgress[axis] = clamp01(
|
|
11
|
+
(that.dampedCurrent[axis] - props.start[axis]) / (props.end[axis] - props.start[axis])
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
class ScrollAnimationTarget extends AbstractScrollAnimation {
|
|
15
|
+
/**
|
|
16
|
+
* Config.
|
|
17
|
+
*/
|
|
18
|
+
static config = {
|
|
19
|
+
...AbstractScrollAnimation.config,
|
|
20
|
+
name: "ScrollAnimationTarget",
|
|
21
|
+
options: {
|
|
22
|
+
...AbstractScrollAnimation.config.options,
|
|
23
|
+
dampFactor: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 0.1
|
|
26
|
+
},
|
|
27
|
+
dampPrecision: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 1e-3
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Local damped current values.
|
|
35
|
+
*/
|
|
36
|
+
dampedCurrent = {
|
|
37
|
+
x: 0,
|
|
38
|
+
y: 0
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Local damped progress.
|
|
42
|
+
*/
|
|
43
|
+
dampedProgress = {
|
|
44
|
+
x: 0,
|
|
45
|
+
y: 0
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Compute local damped progress.
|
|
49
|
+
*/
|
|
50
|
+
scrolledInView(props) {
|
|
51
|
+
domScheduler.read(() => {
|
|
52
|
+
const { dampFactor, dampPrecision } = this.$options;
|
|
53
|
+
updateProps(this, props, dampFactor, dampPrecision, "x");
|
|
54
|
+
updateProps(this, props, dampFactor, dampPrecision, "y");
|
|
55
|
+
});
|
|
56
|
+
domScheduler.write(() => {
|
|
57
|
+
super.scrolledInView({
|
|
58
|
+
...props,
|
|
59
|
+
dampedCurrent: this.dampedCurrent,
|
|
60
|
+
dampedProgress: this.dampedProgress
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
ScrollAnimationTarget
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=ScrollAnimationTarget.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimationTarget.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n BaseConfig,\n BaseProps,\n ScrollInViewProps,\n WithScrolledInViewProps,\n} from '@studiometa/js-toolkit';\nimport { damp, clamp01, domScheduler } from '@studiometa/js-toolkit/utils';\nimport { AbstractScrollAnimation } from './AbstractScrollAnimation.js';\n\nexport interface ScrollAnimationTargetProps extends BaseProps {\n $options: WithScrolledInViewProps['$options'];\n}\n\nfunction updateProps(\n // eslint-disable-next-line no-use-before-define\n that: ScrollAnimationTarget,\n props: ScrollInViewProps,\n dampFactor: number,\n dampPrecision: number,\n axis: 'x' | 'y' = 'x',\n) {\n that.dampedCurrent[axis] = damp(\n props.current[axis],\n that.dampedCurrent[axis],\n dampFactor,\n dampPrecision,\n );\n that.dampedProgress[axis] = clamp01(\n (that.dampedCurrent[axis] - props.start[axis]) / (props.end[axis] - props.start[axis]),\n );\n}\n\n/**\n * ScrollAnimationTarget class.\n *\n * A component that animates based on scroll progress from a parent `ScrollAnimationTimeline`.\n * Each target can have its own animation keyframes and play range.\n *\n * @example\n * ```html\n * <div data-component=\"ScrollAnimationTimeline\">\n * <div\n * data-component=\"ScrollAnimationTarget\"\n * data-option-from='{\"opacity\": 0, \"transform\": \"translateY(20px)\"}'\n * data-option-to='{\"opacity\": 1, \"transform\": \"translateY(0)\"}'\n * data-option-play-range='[0, 0.5]'\n * >\n * Animated content\n * </div>\n * </div>\n * ```\n */\nexport class ScrollAnimationTarget<T extends BaseProps = BaseProps> extends AbstractScrollAnimation<\n T & ScrollAnimationTargetProps\n> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...AbstractScrollAnimation.config,\n name: 'ScrollAnimationTarget',\n options: {\n ...AbstractScrollAnimation.config.options,\n dampFactor: {\n type: Number,\n default: 0.1,\n },\n dampPrecision: {\n type: Number,\n default: 0.001,\n },\n },\n };\n\n /**\n * Local damped current values.\n */\n dampedCurrent: ScrollInViewProps['dampedCurrent'] = {\n x: 0,\n y: 0,\n };\n\n /**\n * Local damped progress.\n */\n dampedProgress: ScrollInViewProps['dampedCurrent'] = {\n x: 0,\n y: 0,\n };\n\n /**\n * Compute local damped progress.\n */\n scrolledInView(props: ScrollInViewProps) {\n domScheduler.read(() => {\n const { dampFactor, dampPrecision } = this.$options;\n updateProps(this, props, dampFactor, dampPrecision, 'x');\n updateProps(this, props, dampFactor, dampPrecision, 'y');\n });\n\n domScheduler.write(() => {\n super.scrolledInView({\n ...props,\n dampedCurrent: this.dampedCurrent,\n dampedProgress: this.dampedProgress,\n });\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,MAAM,SAAS,oBAAoB;AAC5C,SAAS,+BAA+B;AAMxC,SAAS,YAEP,MACA,OACA,YACA,eACA,OAAkB,KAClB;AACA,OAAK,cAAc,IAAI,IAAI;AAAA,IACzB,MAAM,QAAQ,IAAI;AAAA,IAClB,KAAK,cAAc,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACA,OAAK,eAAe,IAAI,IAAI;AAAA,KACzB,KAAK,cAAc,IAAI,IAAI,MAAM,MAAM,IAAI,MAAM,MAAM,IAAI,IAAI,IAAI,MAAM,MAAM,IAAI;AAAA,EACtF;AACF;AAsBO,MAAM,8BAA+D,wBAE1E;AAAA;AAAA;AAAA;AAAA,EAIA,OAAO,SAAqB;AAAA,IAC1B,GAAG,wBAAwB;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,wBAAwB,OAAO;AAAA,MAClC,YAAY;AAAA,QACV,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,eAAe;AAAA,QACb,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAoD;AAAA,IAClD,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAqD;AAAA,IACnD,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,OAA0B;AACvC,iBAAa,KAAK,MAAM;AACtB,YAAM,EAAE,YAAY,cAAc,IAAI,KAAK;AAC3C,kBAAY,MAAM,OAAO,YAAY,eAAe,GAAG;AACvD,kBAAY,MAAM,OAAO,YAAY,eAAe,GAAG;AAAA,IACzD,CAAC;AAED,iBAAa,MAAM,MAAM;AACvB,YAAM,eAAe;AAAA,QACnB,GAAG;AAAA,QACH,eAAe,KAAK;AAAA,QACpB,gBAAgB,KAAK;AAAA,MACvB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Base, ScrollInViewProps } from '@studiometa/js-toolkit';
|
|
2
|
+
import type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';
|
|
3
|
+
import { ScrollAnimationTarget } from './ScrollAnimationTarget.js';
|
|
4
|
+
export interface ScrollAnimationTimelineProps extends BaseProps {
|
|
5
|
+
$children: {
|
|
6
|
+
ScrollAnimationTarget: ScrollAnimationTarget[];
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
declare const ScrollAnimationTimeline_base: import("@studiometa/js-toolkit").BaseDecorator<import("@studiometa/js-toolkit").WithScrolledInViewInterface, Base<BaseProps>, import("@studiometa/js-toolkit").WithScrolledInViewProps>;
|
|
10
|
+
/**
|
|
11
|
+
* ScrollAnimationTimeline class.
|
|
12
|
+
*
|
|
13
|
+
* A component that manages scroll-based animations for its children.
|
|
14
|
+
* Use with `ScrollAnimationTarget` children components.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```html
|
|
18
|
+
* <div data-component="ScrollAnimationTimeline">
|
|
19
|
+
* <div data-component="ScrollAnimationTarget" data-option-from='{"opacity": 0}' data-option-to='{"opacity": 1}'>
|
|
20
|
+
* Content
|
|
21
|
+
* </div>
|
|
22
|
+
* </div>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class ScrollAnimationTimeline<T extends BaseProps = BaseProps> extends ScrollAnimationTimeline_base<T & ScrollAnimationTimelineProps> {
|
|
26
|
+
/**
|
|
27
|
+
* Config.
|
|
28
|
+
*/
|
|
29
|
+
static config: BaseConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Scrolled in view hook.
|
|
32
|
+
*/
|
|
33
|
+
scrolledInView(props: ScrollInViewProps): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Base, withScrolledInView } from "@studiometa/js-toolkit";
|
|
2
|
+
import { ScrollAnimationTarget } from "./ScrollAnimationTarget.js";
|
|
3
|
+
class ScrollAnimationTimeline extends withScrolledInView(
|
|
4
|
+
Base,
|
|
5
|
+
{}
|
|
6
|
+
) {
|
|
7
|
+
/**
|
|
8
|
+
* Config.
|
|
9
|
+
*/
|
|
10
|
+
static config = {
|
|
11
|
+
name: "ScrollAnimationTimeline",
|
|
12
|
+
components: {
|
|
13
|
+
ScrollAnimationTarget
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Scrolled in view hook.
|
|
18
|
+
*/
|
|
19
|
+
scrolledInView(props) {
|
|
20
|
+
for (const child of this.$children.ScrollAnimationTarget) {
|
|
21
|
+
child.scrolledInView(props);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
ScrollAnimationTimeline
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=ScrollAnimationTimeline.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimationTimeline.ts"],
|
|
4
|
+
"sourcesContent": ["import { Base, ScrollInViewProps, withScrolledInView } from '@studiometa/js-toolkit';\nimport type { BaseConfig, BaseProps } from '@studiometa/js-toolkit';\nimport { ScrollAnimationTarget } from './ScrollAnimationTarget.js';\n\nexport interface ScrollAnimationTimelineProps extends BaseProps {\n $children: {\n ScrollAnimationTarget: ScrollAnimationTarget[];\n };\n}\n\n/**\n * ScrollAnimationTimeline class.\n *\n * A component that manages scroll-based animations for its children.\n * Use with `ScrollAnimationTarget` children components.\n *\n * @example\n * ```html\n * <div data-component=\"ScrollAnimationTimeline\">\n * <div data-component=\"ScrollAnimationTarget\" data-option-from='{\"opacity\": 0}' data-option-to='{\"opacity\": 1}'>\n * Content\n * </div>\n * </div>\n * ```\n */\nexport class ScrollAnimationTimeline<T extends BaseProps = BaseProps> extends withScrolledInView(\n Base,\n {},\n)<T & ScrollAnimationTimelineProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'ScrollAnimationTimeline',\n components: {\n ScrollAnimationTarget,\n },\n };\n\n /**\n * Scrolled in view hook.\n */\n scrolledInView(props: ScrollInViewProps) {\n for (const child of this.$children.ScrollAnimationTarget) {\n child.scrolledInView(props);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,MAAyB,0BAA0B;AAE5D,SAAS,6BAA6B;AAuB/B,MAAM,gCAAiE;AAAA,EAC5E;AAAA,EACA,CAAC;AACH,EAAoC;AAAA;AAAA;AAAA;AAAA,EAIlC,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,IACN,YAAY;AAAA,MACV;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,OAA0B;AACvC,eAAW,SAAS,KAAK,UAAU,uBAAuB;AACxD,YAAM,eAAe,KAAK;AAAA,IAC5B;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { type BaseConfig } from '@studiometa/js-toolkit';
|
|
2
2
|
declare const ScrollAnimationWithEase_base: import("@studiometa/js-toolkit").BaseDecorator<import("#private/index.js").AnimationScrollWithEaseInterface, import("#private/index.js").AbstractScrollAnimation<import("@studiometa/js-toolkit").BaseProps>, import("#private/index.js").AnimationScrollWithEaseProps>;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* ScrollAnimationWithEase class.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated Use `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead.
|
|
5
7
|
*/
|
|
6
8
|
export declare class ScrollAnimationWithEase extends ScrollAnimationWithEase_base {
|
|
7
9
|
/**
|
|
8
10
|
* Config.
|
|
9
11
|
*/
|
|
10
12
|
static config: BaseConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Display deprecation warning.
|
|
15
|
+
*/
|
|
16
|
+
mounted(): void;
|
|
11
17
|
}
|
|
12
18
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDev } from "@studiometa/js-toolkit/utils";
|
|
1
2
|
import { ScrollAnimation } from "./ScrollAnimation.js";
|
|
2
3
|
import { animationScrollWithEase } from "./animationScrollWithEase.js";
|
|
3
4
|
class ScrollAnimationWithEase extends animationScrollWithEase(ScrollAnimation) {
|
|
@@ -8,6 +9,17 @@ class ScrollAnimationWithEase extends animationScrollWithEase(ScrollAnimation) {
|
|
|
8
9
|
...ScrollAnimation.config,
|
|
9
10
|
name: "ScrollAnimationWithEase"
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Display deprecation warning.
|
|
14
|
+
*/
|
|
15
|
+
mounted() {
|
|
16
|
+
if (isDev) {
|
|
17
|
+
console.warn(
|
|
18
|
+
`The ${this.$options.name} component is deprecated.`,
|
|
19
|
+
"\nUse `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead."
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
11
23
|
}
|
|
12
24
|
export {
|
|
13
25
|
ScrollAnimationWithEase
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/ui/ScrollAnimation/ScrollAnimationWithEase.ts"],
|
|
4
|
-
"sourcesContent": ["import { type BaseConfig } from '@studiometa/js-toolkit';\nimport { ScrollAnimation } from './ScrollAnimation.js';\nimport { animationScrollWithEase } from './animationScrollWithEase.js';\n\n/**\n *
|
|
5
|
-
"mappings": "AACA,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;
|
|
4
|
+
"sourcesContent": ["import { type BaseConfig } from '@studiometa/js-toolkit';\nimport { isDev } from '@studiometa/js-toolkit/utils';\nimport { ScrollAnimation } from './ScrollAnimation.js';\nimport { animationScrollWithEase } from './animationScrollWithEase.js';\n\n/**\n * ScrollAnimationWithEase class.\n *\n * @deprecated Use `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead.\n */\nexport class ScrollAnimationWithEase extends animationScrollWithEase(ScrollAnimation) {\n /**\n * Config.\n */\n static config: BaseConfig = {\n ...ScrollAnimation.config,\n name: 'ScrollAnimationWithEase',\n };\n\n /**\n * Display deprecation warning.\n */\n mounted() {\n if (isDev) {\n console.warn(\n `The ${this.$options.name} component is deprecated.`,\n '\\nUse `ScrollAnimationTimeline` with `ScrollAnimationTarget` children instead.',\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AAOjC,MAAM,gCAAgC,wBAAwB,eAAe,EAAE;AAAA;AAAA;AAAA;AAAA,EAIpF,OAAO,SAAqB;AAAA,IAC1B,GAAG,gBAAgB;AAAA,IACnB,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,QAAI,OAAO;AACT,cAAQ;AAAA,QACN,OAAO,KAAK,SAAS,IAAI;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,5 +9,7 @@ export interface AnimationScrollWithEaseInterface extends BaseInterface {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Extend a `ScrollAnimation` component to use easings.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated This decorator is deprecated. Easing can be applied directly via CSS or animation options.
|
|
12
14
|
*/
|
|
13
15
|
export declare function animationScrollWithEase<S extends AbstractScrollAnimation>(ScrollAnimation: typeof AbstractScrollAnimation): BaseDecorator<AnimationScrollWithEaseInterface, S, AnimationScrollWithEaseProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ease } from "@studiometa/js-toolkit/utils";
|
|
1
|
+
import { ease, isDev } from "@studiometa/js-toolkit/utils";
|
|
2
2
|
const regex = /ease([A-Z])/;
|
|
3
3
|
const eases = Object.fromEntries(
|
|
4
4
|
Object.entries(ease).filter(([name]) => name.startsWith("ease")).map(([name, value]) => [name.replace(regex, (match, $1) => $1.toLowerCase()), value])
|
|
@@ -19,6 +19,17 @@ function animationScrollWithEase(ScrollAnimation) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Display a deprecation warning.
|
|
24
|
+
*/
|
|
25
|
+
mounted() {
|
|
26
|
+
if (isDev) {
|
|
27
|
+
console.warn(
|
|
28
|
+
`The animationScrollWithEase decorator is deprecated.`,
|
|
29
|
+
"\nEasing can be applied directly via CSS or animation options."
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
/**
|
|
23
34
|
* Eases the progress value.
|
|
24
35
|
*/
|