@studiometa/ui 0.2.23 → 0.2.25
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/README.md +2 -12
- package/atoms/AnchorScrollTo/AnchorScrollTo.cjs +11 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.cjs.map +2 -2
- package/atoms/AnchorScrollTo/AnchorScrollTo.js +11 -0
- package/atoms/AnchorScrollTo/AnchorScrollTo.js.map +2 -2
- package/atoms/Button/StyledButton.twig +6 -4
- package/atoms/Button/StyledButtonRounded.twig +65 -0
- package/atoms/Cursor/Cursor.cjs +12 -0
- package/atoms/Cursor/Cursor.cjs.map +2 -2
- package/atoms/Cursor/Cursor.js +12 -0
- package/atoms/Cursor/Cursor.js.map +2 -2
- package/atoms/Figure/Figure.cjs +27 -3
- package/atoms/Figure/Figure.cjs.map +2 -2
- package/atoms/Figure/Figure.js +27 -3
- package/atoms/Figure/Figure.js.map +2 -2
- package/atoms/Figure/Figure.twig +6 -1
- package/atoms/Figure/FigureTwicpics.cjs +21 -0
- package/atoms/Figure/FigureTwicpics.cjs.map +1 -1
- package/atoms/Figure/FigureTwicpics.js +21 -0
- package/atoms/Figure/FigureTwicpics.js.map +1 -1
- package/atoms/LargeText/LargeText.cjs +27 -0
- package/atoms/LargeText/LargeText.cjs.map +2 -2
- package/atoms/LargeText/LargeText.js +27 -0
- package/atoms/LargeText/LargeText.js.map +2 -2
- package/atoms/LazyInclude/LazyInclude.cjs +15 -0
- package/atoms/LazyInclude/LazyInclude.cjs.map +2 -2
- package/atoms/LazyInclude/LazyInclude.js +15 -0
- package/atoms/LazyInclude/LazyInclude.js.map +2 -2
- package/atoms/Prefetch/AbstractPrefetch.cjs +12 -0
- package/atoms/Prefetch/AbstractPrefetch.cjs.map +2 -2
- package/atoms/Prefetch/AbstractPrefetch.js +12 -0
- package/atoms/Prefetch/AbstractPrefetch.js.map +2 -2
- package/atoms/Prefetch/PrefetchWhenOver.cjs +6 -0
- package/atoms/Prefetch/PrefetchWhenOver.cjs.map +2 -2
- package/atoms/Prefetch/PrefetchWhenOver.js +6 -0
- package/atoms/Prefetch/PrefetchWhenOver.js.map +2 -2
- package/atoms/Prefetch/PrefetchWhenVisible.cjs +6 -0
- package/atoms/Prefetch/PrefetchWhenVisible.cjs.map +2 -2
- package/atoms/Prefetch/PrefetchWhenVisible.js +6 -0
- package/atoms/Prefetch/PrefetchWhenVisible.js.map +2 -2
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +12 -0
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs.map +2 -2
- package/atoms/ScrollAnimation/AbstractScrollAnimation.js +12 -0
- package/atoms/ScrollAnimation/AbstractScrollAnimation.js.map +2 -2
- package/atoms/ScrollAnimation/ScrollAnimation.cjs +6 -0
- package/atoms/ScrollAnimation/ScrollAnimation.cjs.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimation.js +6 -0
- package/atoms/ScrollAnimation/ScrollAnimation.js.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +18 -1
- package/atoms/ScrollAnimation/ScrollAnimationChild.cjs.map +2 -2
- package/atoms/ScrollAnimation/ScrollAnimationChild.js +18 -1
- package/atoms/ScrollAnimation/ScrollAnimationChild.js.map +2 -2
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +3 -0
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +3 -0
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +6 -0
- package/atoms/ScrollAnimation/ScrollAnimationParent.cjs.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationParent.js +6 -0
- package/atoms/ScrollAnimation/ScrollAnimationParent.js.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +3 -0
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs.map +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +1 -1
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +3 -0
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.js.map +1 -1
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs +6 -0
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs.map +2 -2
- package/atoms/ScrollAnimation/animationScrollWithEase.js +6 -0
- package/atoms/ScrollAnimation/animationScrollWithEase.js.map +2 -2
- package/atoms/ScrollReveal/ScrollReveal.cjs +12 -0
- package/atoms/ScrollReveal/ScrollReveal.cjs.map +1 -1
- package/atoms/ScrollReveal/ScrollReveal.js +12 -0
- package/atoms/ScrollReveal/ScrollReveal.js.map +1 -1
- package/decorators/withTransition.cjs +16 -2
- package/decorators/withTransition.cjs.map +2 -2
- package/decorators/withTransition.js +16 -2
- package/decorators/withTransition.js.map +2 -2
- package/molecules/Accordion/AccordionCore.cjs +9 -0
- package/molecules/Accordion/AccordionCore.cjs.map +2 -2
- package/molecules/Accordion/AccordionCore.js +9 -0
- package/molecules/Accordion/AccordionCore.js.map +2 -2
- package/molecules/Accordion/AccordionItem.cjs +33 -1
- package/molecules/Accordion/AccordionItem.cjs.map +2 -2
- package/molecules/Accordion/AccordionItem.d.ts +1 -1
- package/molecules/Accordion/AccordionItem.js +29 -1
- package/molecules/Accordion/AccordionItem.js.map +2 -2
- package/molecules/Menu/Menu.cjs +47 -0
- package/molecules/Menu/Menu.cjs.map +1 -1
- package/molecules/Menu/Menu.js +47 -0
- package/molecules/Menu/Menu.js.map +1 -1
- package/molecules/Menu/MenuBtn.cjs +24 -0
- package/molecules/Menu/MenuBtn.cjs.map +1 -1
- package/molecules/Menu/MenuBtn.js +24 -0
- package/molecules/Menu/MenuBtn.js.map +1 -1
- package/molecules/Menu/MenuList.cjs +39 -0
- package/molecules/Menu/MenuList.cjs.map +2 -2
- package/molecules/Menu/MenuList.d.ts +1 -1
- package/molecules/Menu/MenuList.js +39 -0
- package/molecules/Menu/MenuList.js.map +2 -2
- package/molecules/Modal/Modal.cjs +50 -1
- package/molecules/Modal/Modal.cjs.map +2 -2
- package/molecules/Modal/Modal.d.ts +3 -3
- package/molecules/Modal/Modal.js +50 -1
- package/molecules/Modal/Modal.js.map +2 -2
- package/molecules/Modal/ModalWithTransition.cjs +6 -0
- package/molecules/Modal/ModalWithTransition.cjs.map +2 -2
- package/molecules/Modal/ModalWithTransition.js +6 -0
- package/molecules/Modal/ModalWithTransition.js.map +2 -2
- package/molecules/Panel/Panel.cjs +19 -0
- package/molecules/Panel/Panel.cjs.map +2 -2
- package/molecules/Panel/Panel.js +19 -0
- package/molecules/Panel/Panel.js.map +2 -2
- package/molecules/Slider/AbstractSliderChild.cjs +24 -0
- package/molecules/Slider/AbstractSliderChild.cjs.map +2 -2
- package/molecules/Slider/AbstractSliderChild.js +24 -0
- package/molecules/Slider/AbstractSliderChild.js.map +2 -2
- package/molecules/Slider/Slider.cjs +97 -0
- package/molecules/Slider/Slider.cjs.map +2 -2
- package/molecules/Slider/Slider.d.ts +3 -2
- package/molecules/Slider/Slider.js +97 -0
- package/molecules/Slider/Slider.js.map +2 -2
- package/molecules/Slider/SliderBtn.cjs +22 -2
- package/molecules/Slider/SliderBtn.cjs.map +2 -2
- package/molecules/Slider/SliderBtn.d.ts +1 -0
- package/molecules/Slider/SliderBtn.js +22 -2
- package/molecules/Slider/SliderBtn.js.map +2 -2
- package/molecules/Slider/SliderCount.cjs +9 -0
- package/molecules/Slider/SliderCount.cjs.map +2 -2
- package/molecules/Slider/SliderCount.js +9 -0
- package/molecules/Slider/SliderCount.js.map +2 -2
- package/molecules/Slider/SliderDots.cjs +19 -0
- package/molecules/Slider/SliderDots.cjs.map +2 -2
- package/molecules/Slider/SliderDots.js +19 -0
- package/molecules/Slider/SliderDots.js.map +2 -2
- package/molecules/Slider/SliderDrag.cjs +15 -0
- package/molecules/Slider/SliderDrag.cjs.map +2 -2
- package/molecules/Slider/SliderDrag.js +15 -0
- package/molecules/Slider/SliderDrag.js.map +2 -2
- package/molecules/Slider/SliderItem.cjs +75 -14
- package/molecules/Slider/SliderItem.cjs.map +2 -2
- package/molecules/Slider/SliderItem.d.ts +12 -11
- package/molecules/Slider/SliderItem.js +75 -14
- package/molecules/Slider/SliderItem.js.map +2 -2
- package/molecules/Slider/SliderProgress.cjs +6 -0
- package/molecules/Slider/SliderProgress.cjs.map +2 -2
- package/molecules/Slider/SliderProgress.js +6 -0
- package/molecules/Slider/SliderProgress.js.map +2 -2
- package/molecules/Sticky/Sticky.cjs +56 -0
- package/molecules/Sticky/Sticky.cjs.map +2 -2
- package/molecules/Sticky/Sticky.js +56 -0
- package/molecules/Sticky/Sticky.js.map +2 -2
- package/molecules/TableOfContent/TableOfContent.cjs +13 -0
- package/molecules/TableOfContent/TableOfContent.cjs.map +1 -1
- package/molecules/TableOfContent/TableOfContent.js +13 -0
- package/molecules/TableOfContent/TableOfContent.js.map +1 -1
- package/molecules/TableOfContent/TableOfContentAnchor.cjs +16 -0
- package/molecules/TableOfContent/TableOfContentAnchor.cjs.map +2 -2
- package/molecules/TableOfContent/TableOfContentAnchor.js +16 -0
- package/molecules/TableOfContent/TableOfContentAnchor.js.map +2 -2
- package/molecules/Tabs/Tabs.cjs +16 -0
- package/molecules/Tabs/Tabs.cjs.map +2 -2
- package/molecules/Tabs/Tabs.d.ts +3 -3
- package/molecules/Tabs/Tabs.js +16 -0
- package/molecules/Tabs/Tabs.js.map +2 -2
- package/organisms/Frame/Frame.cjs +30 -0
- package/organisms/Frame/Frame.cjs.map +2 -2
- package/organisms/Frame/Frame.js +30 -0
- package/organisms/Frame/Frame.js.map +2 -2
- package/organisms/Frame/FrameAnchor.cjs +6 -0
- package/organisms/Frame/FrameAnchor.cjs.map +1 -1
- package/organisms/Frame/FrameAnchor.js +6 -0
- package/organisms/Frame/FrameAnchor.js.map +1 -1
- package/organisms/Frame/FrameForm.cjs +6 -0
- package/organisms/Frame/FrameForm.cjs.map +1 -1
- package/organisms/Frame/FrameForm.js +6 -0
- package/organisms/Frame/FrameForm.js.map +1 -1
- package/organisms/Frame/FrameTarget.cjs +25 -2
- package/organisms/Frame/FrameTarget.cjs.map +2 -2
- package/organisms/Frame/FrameTarget.d.ts +1 -1
- package/organisms/Frame/FrameTarget.js +25 -2
- package/organisms/Frame/FrameTarget.js.map +2 -2
- package/organisms/Hero/Hero.twig +151 -0
- package/package.json +2 -2
- package/primitives/Draggable/Draggable.cjs +18 -0
- package/primitives/Draggable/Draggable.cjs.map +2 -2
- package/primitives/Draggable/Draggable.js +18 -0
- package/primitives/Draggable/Draggable.js.map +2 -2
- package/primitives/Sentinel/Sentinel.cjs +3 -0
- package/primitives/Sentinel/Sentinel.cjs.map +2 -2
- package/primitives/Sentinel/Sentinel.js +3 -0
- package/primitives/Sentinel/Sentinel.js.map +2 -2
- package/primitives/Transition/Transition.cjs +3 -0
- package/primitives/Transition/Transition.cjs.map +1 -1
- package/primitives/Transition/Transition.js +3 -0
- package/primitives/Transition/Transition.js.map +1 -1
|
@@ -31,6 +31,9 @@ var import_js_toolkit = require("@studiometa/js-toolkit");
|
|
|
31
31
|
var import_utils = require("@studiometa/js-toolkit/utils");
|
|
32
32
|
var import_Slider = require("./Slider.cjs");
|
|
33
33
|
var AbstractSliderChild = class extends import_js_toolkit.Base {
|
|
34
|
+
/**
|
|
35
|
+
* Listen to the `goto` event of the parent on mount.
|
|
36
|
+
*/
|
|
34
37
|
mounted() {
|
|
35
38
|
if (!(this.$parent instanceof import_Slider.Slider)) {
|
|
36
39
|
throw new Error(
|
|
@@ -39,14 +42,26 @@ var AbstractSliderChild = class extends import_js_toolkit.Base {
|
|
|
39
42
|
}
|
|
40
43
|
this.$parent.$on("index", this);
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Trigger update on resize.
|
|
47
|
+
*/
|
|
42
48
|
resized() {
|
|
43
49
|
(0, import_utils.nextFrame)(() => {
|
|
44
50
|
this.update(this.$parent.currentIndex);
|
|
45
51
|
});
|
|
46
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Remove the event listener.
|
|
55
|
+
*/
|
|
47
56
|
destroyed() {
|
|
48
57
|
this.$parent.$off("index", this);
|
|
49
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Dispatch event.
|
|
61
|
+
*
|
|
62
|
+
* @param {CustomEvent} event
|
|
63
|
+
* @returns {void}
|
|
64
|
+
*/
|
|
50
65
|
handleEvent(event) {
|
|
51
66
|
if (event.type === "index") {
|
|
52
67
|
import_utils.domScheduler.read(() => {
|
|
@@ -59,10 +74,19 @@ var AbstractSliderChild = class extends import_js_toolkit.Base {
|
|
|
59
74
|
});
|
|
60
75
|
}
|
|
61
76
|
}
|
|
77
|
+
// eslint-disable-next-line jsdoc/require-returns-check
|
|
78
|
+
/**
|
|
79
|
+
* Update the child component with the given index.
|
|
80
|
+
* @param {number} index The new active index.
|
|
81
|
+
* @returns {void|(()=>void)}
|
|
82
|
+
*/
|
|
62
83
|
update(index) {
|
|
63
84
|
throw new Error(`The \`AbstractSliderChild.update(${index})\` method must be implemented.`);
|
|
64
85
|
}
|
|
65
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Config.
|
|
89
|
+
*/
|
|
66
90
|
__publicField(AbstractSliderChild, "config", {
|
|
67
91
|
name: "AbstractSliderChild"
|
|
68
92
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/molecules/Slider/AbstractSliderChild.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, BaseInterface } from '@studiometa/js-toolkit';\nimport { nextFrame, domScheduler, isFunction } from '@studiometa/js-toolkit/utils';\nimport { Slider } from './Slider.js';\n\nexport interface AbstractSliderChildProps extends BaseProps {\n $parent: Slider;\n}\n\n/**\n * AbstractSliderChild class.\n */\nexport class AbstractSliderChild<T extends BaseProps = BaseProps
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqB;AAErB,mBAAoD;AACpD,oBAAuB;AAShB,IAAM,sBAAN,
|
|
4
|
+
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, BaseInterface } from '@studiometa/js-toolkit';\nimport { nextFrame, domScheduler, isFunction } from '@studiometa/js-toolkit/utils';\nimport { Slider } from './Slider.js';\n\nexport interface AbstractSliderChildProps extends BaseProps {\n $parent: Slider;\n}\n\n/**\n * AbstractSliderChild class.\n */\nexport class AbstractSliderChild<T extends BaseProps = BaseProps>\n extends Base<T & AbstractSliderChildProps>\n implements BaseInterface\n{\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AbstractSliderChild',\n };\n\n /**\n * Listen to the `goto` event of the parent on mount.\n */\n mounted() {\n if (!(this.$parent instanceof Slider)) {\n throw new Error(\n `The \\`${this.$options.name}\\` component must be a direct child of a \\`Slider\\` component.`,\n );\n }\n\n this.$parent.$on('index', this);\n }\n\n /**\n * Trigger update on resize.\n */\n resized() {\n nextFrame(() => {\n this.update(this.$parent.currentIndex);\n });\n }\n\n /**\n * Remove the event listener.\n */\n destroyed() {\n this.$parent.$off('index', this);\n }\n\n /**\n * Dispatch event.\n *\n * @param {CustomEvent} event\n * @returns {void}\n */\n handleEvent(event) {\n if (event.type === 'index') {\n domScheduler.read(() => {\n const callback = this.update(event.detail[0]);\n if (isFunction(callback)) {\n domScheduler.write(() => {\n // @ts-ignore\n callback();\n });\n }\n });\n }\n }\n\n // eslint-disable-next-line jsdoc/require-returns-check\n /**\n * Update the child component with the given index.\n * @param {number} index The new active index.\n * @returns {void|(()=>void)}\n */\n update(index): void | (() => void) {\n throw new Error(`The \\`AbstractSliderChild.update(${index})\\` method must be implemented.`);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqB;AAErB,mBAAoD;AACpD,oBAAuB;AAShB,IAAM,sBAAN,cACG,uBAEV;AAAA;AAAA;AAAA;AAAA,EAWE,UAAU;AACR,QAAI,EAAE,KAAK,mBAAmB,uBAAS;AACrC,YAAM,IAAI;AAAA,QACR,SAAS,KAAK,SAAS;AAAA,MACzB;AAAA,IACF;AAEA,SAAK,QAAQ,IAAI,SAAS,IAAI;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,gCAAU,MAAM;AACd,WAAK,OAAO,KAAK,QAAQ,YAAY;AAAA,IACvC,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY;AACV,SAAK,QAAQ,KAAK,SAAS,IAAI;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,OAAO;AACjB,QAAI,MAAM,SAAS,SAAS;AAC1B,gCAAa,KAAK,MAAM;AACtB,cAAM,WAAW,KAAK,OAAO,MAAM,OAAO,CAAC,CAAC;AAC5C,gBAAI,yBAAW,QAAQ,GAAG;AACxB,oCAAa,MAAM,MAAM;AAEvB,qBAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAA4B;AACjC,UAAM,IAAI,MAAM,oCAAoC,sCAAsC;AAAA,EAC5F;AACF;AAAA;AAAA;AAAA;AA9DE,cAPW,qBAOJ,UAAqB;AAAA,EAC1B,MAAM;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,9 +2,15 @@ import { Base } from "@studiometa/js-toolkit";
|
|
|
2
2
|
import { nextFrame, domScheduler, isFunction } from "@studiometa/js-toolkit/utils";
|
|
3
3
|
import { Slider } from "./Slider.js";
|
|
4
4
|
class AbstractSliderChild extends Base {
|
|
5
|
+
/**
|
|
6
|
+
* Config.
|
|
7
|
+
*/
|
|
5
8
|
static config = {
|
|
6
9
|
name: "AbstractSliderChild"
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Listen to the `goto` event of the parent on mount.
|
|
13
|
+
*/
|
|
8
14
|
mounted() {
|
|
9
15
|
if (!(this.$parent instanceof Slider)) {
|
|
10
16
|
throw new Error(
|
|
@@ -13,14 +19,26 @@ class AbstractSliderChild extends Base {
|
|
|
13
19
|
}
|
|
14
20
|
this.$parent.$on("index", this);
|
|
15
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Trigger update on resize.
|
|
24
|
+
*/
|
|
16
25
|
resized() {
|
|
17
26
|
nextFrame(() => {
|
|
18
27
|
this.update(this.$parent.currentIndex);
|
|
19
28
|
});
|
|
20
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Remove the event listener.
|
|
32
|
+
*/
|
|
21
33
|
destroyed() {
|
|
22
34
|
this.$parent.$off("index", this);
|
|
23
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Dispatch event.
|
|
38
|
+
*
|
|
39
|
+
* @param {CustomEvent} event
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
24
42
|
handleEvent(event) {
|
|
25
43
|
if (event.type === "index") {
|
|
26
44
|
domScheduler.read(() => {
|
|
@@ -33,6 +51,12 @@ class AbstractSliderChild extends Base {
|
|
|
33
51
|
});
|
|
34
52
|
}
|
|
35
53
|
}
|
|
54
|
+
// eslint-disable-next-line jsdoc/require-returns-check
|
|
55
|
+
/**
|
|
56
|
+
* Update the child component with the given index.
|
|
57
|
+
* @param {number} index The new active index.
|
|
58
|
+
* @returns {void|(()=>void)}
|
|
59
|
+
*/
|
|
36
60
|
update(index) {
|
|
37
61
|
throw new Error(`The \`AbstractSliderChild.update(${index})\` method must be implemented.`);
|
|
38
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/molecules/Slider/AbstractSliderChild.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, BaseInterface } from '@studiometa/js-toolkit';\nimport { nextFrame, domScheduler, isFunction } from '@studiometa/js-toolkit/utils';\nimport { Slider } from './Slider.js';\n\nexport interface AbstractSliderChildProps extends BaseProps {\n $parent: Slider;\n}\n\n/**\n * AbstractSliderChild class.\n */\nexport class AbstractSliderChild<T extends BaseProps = BaseProps
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,WAAW,cAAc,kBAAkB;AACpD,SAAS,cAAc;AAShB,MAAM,
|
|
4
|
+
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, BaseInterface } from '@studiometa/js-toolkit';\nimport { nextFrame, domScheduler, isFunction } from '@studiometa/js-toolkit/utils';\nimport { Slider } from './Slider.js';\n\nexport interface AbstractSliderChildProps extends BaseProps {\n $parent: Slider;\n}\n\n/**\n * AbstractSliderChild class.\n */\nexport class AbstractSliderChild<T extends BaseProps = BaseProps>\n extends Base<T & AbstractSliderChildProps>\n implements BaseInterface\n{\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'AbstractSliderChild',\n };\n\n /**\n * Listen to the `goto` event of the parent on mount.\n */\n mounted() {\n if (!(this.$parent instanceof Slider)) {\n throw new Error(\n `The \\`${this.$options.name}\\` component must be a direct child of a \\`Slider\\` component.`,\n );\n }\n\n this.$parent.$on('index', this);\n }\n\n /**\n * Trigger update on resize.\n */\n resized() {\n nextFrame(() => {\n this.update(this.$parent.currentIndex);\n });\n }\n\n /**\n * Remove the event listener.\n */\n destroyed() {\n this.$parent.$off('index', this);\n }\n\n /**\n * Dispatch event.\n *\n * @param {CustomEvent} event\n * @returns {void}\n */\n handleEvent(event) {\n if (event.type === 'index') {\n domScheduler.read(() => {\n const callback = this.update(event.detail[0]);\n if (isFunction(callback)) {\n domScheduler.write(() => {\n // @ts-ignore\n callback();\n });\n }\n });\n }\n }\n\n // eslint-disable-next-line jsdoc/require-returns-check\n /**\n * Update the child component with the given index.\n * @param {number} index The new active index.\n * @returns {void|(()=>void)}\n */\n update(index): void | (() => void) {\n throw new Error(`The \\`AbstractSliderChild.update(${index})\\` method must be implemented.`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,WAAW,cAAc,kBAAkB;AACpD,SAAS,cAAc;AAShB,MAAM,4BACH,KAEV;AAAA;AAAA;AAAA;AAAA,EAIE,OAAO,SAAqB;AAAA,IAC1B,MAAM;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,QAAI,EAAE,KAAK,mBAAmB,SAAS;AACrC,YAAM,IAAI;AAAA,QACR,SAAS,KAAK,SAAS;AAAA,MACzB;AAAA,IACF;AAEA,SAAK,QAAQ,IAAI,SAAS,IAAI;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU;AACR,cAAU,MAAM;AACd,WAAK,OAAO,KAAK,QAAQ,YAAY;AAAA,IACvC,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY;AACV,SAAK,QAAQ,KAAK,SAAS,IAAI;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,YAAY,OAAO;AACjB,QAAI,MAAM,SAAS,SAAS;AAC1B,mBAAa,KAAK,MAAM;AACtB,cAAM,WAAW,KAAK,OAAO,MAAM,OAAO,CAAC,CAAC;AAC5C,YAAI,WAAW,QAAQ,GAAG;AACxB,uBAAa,MAAM,MAAM;AAEvB,qBAAS;AAAA,UACX,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAA4B;AACjC,UAAM,IAAI,MAAM,oCAAoC,sCAAsC;AAAA,EAC5F;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -34,44 +34,87 @@ var import_SliderItem = require("./SliderItem.cjs");
|
|
|
34
34
|
var Slider = class extends import_js_toolkit.Base {
|
|
35
35
|
__distanceX = 0;
|
|
36
36
|
__initialX = 0;
|
|
37
|
+
/**
|
|
38
|
+
* Index of the current active slide.
|
|
39
|
+
*/
|
|
37
40
|
__currentIndex = 0;
|
|
41
|
+
/**
|
|
42
|
+
* Get the current index.
|
|
43
|
+
*/
|
|
38
44
|
get currentIndex() {
|
|
39
45
|
return this.__currentIndex;
|
|
40
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Set the current index and emit the `index` event.
|
|
49
|
+
*/
|
|
41
50
|
set currentIndex(value) {
|
|
42
51
|
this.currentSliderItem.disactivate();
|
|
43
52
|
this.$emit("index", value);
|
|
44
53
|
this.__currentIndex = value;
|
|
45
54
|
this.currentSliderItem.activate();
|
|
46
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Store all the states.
|
|
58
|
+
*/
|
|
47
59
|
states = [];
|
|
60
|
+
/**
|
|
61
|
+
* Origins for the different modes.
|
|
62
|
+
*/
|
|
48
63
|
origins = {
|
|
49
64
|
left: 0,
|
|
50
65
|
center: 0,
|
|
51
66
|
right: 0
|
|
52
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Wether or not the wrapper is focused.
|
|
70
|
+
* @type {boolean}
|
|
71
|
+
*/
|
|
53
72
|
hasFocus = false;
|
|
73
|
+
/**
|
|
74
|
+
* Get the current state.
|
|
75
|
+
*/
|
|
54
76
|
get currentState() {
|
|
55
77
|
return this.states[this.currentIndex];
|
|
56
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the first state.
|
|
81
|
+
*/
|
|
57
82
|
get firstState() {
|
|
58
83
|
return this.states[0];
|
|
59
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the last state.
|
|
87
|
+
*/
|
|
60
88
|
get lastState() {
|
|
61
89
|
return this.states.at(-1);
|
|
62
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Get the minimal contain state value.
|
|
93
|
+
*/
|
|
63
94
|
get containMinState() {
|
|
64
95
|
return this.getStateValueByMode(this.firstState.x, "left");
|
|
65
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the maximal contain state value.
|
|
99
|
+
*/
|
|
66
100
|
get containMaxState() {
|
|
67
101
|
return this.getStateValueByMode(this.lastState.x, "right");
|
|
68
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the last index.
|
|
105
|
+
*/
|
|
69
106
|
get indexMax() {
|
|
70
107
|
return this.$children.SliderItem.length - 1;
|
|
71
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the current SliderItem
|
|
111
|
+
*/
|
|
72
112
|
get currentSliderItem() {
|
|
73
113
|
return this.$children.SliderItem[this.currentIndex];
|
|
74
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the states for each SliderItem.
|
|
117
|
+
*/
|
|
75
118
|
getStates() {
|
|
76
119
|
const { wrapper } = this.$refs;
|
|
77
120
|
const originRect = wrapper.getBoundingClientRect();
|
|
@@ -124,17 +167,29 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
124
167
|
}
|
|
125
168
|
return states;
|
|
126
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Get an origin by mode.
|
|
172
|
+
*/
|
|
127
173
|
getOriginByMode(mode) {
|
|
128
174
|
return this.origins[mode ?? this.$options.mode];
|
|
129
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Get a state value according to the given mode.
|
|
178
|
+
*/
|
|
130
179
|
getStateValueByMode(state, mode) {
|
|
131
180
|
return state[mode ?? this.$options.mode];
|
|
132
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Mounted hook.
|
|
184
|
+
*/
|
|
133
185
|
mounted() {
|
|
134
186
|
this.states = this.getStates();
|
|
135
187
|
this.prepareInvisibleItems();
|
|
136
188
|
this.goTo(this.currentIndex);
|
|
137
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Resized hook.
|
|
192
|
+
*/
|
|
138
193
|
resized() {
|
|
139
194
|
(0, import_utils.nextFrame)(() => {
|
|
140
195
|
this.states = this.getStates();
|
|
@@ -144,18 +199,27 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
144
199
|
});
|
|
145
200
|
});
|
|
146
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Go to the next slide.
|
|
204
|
+
*/
|
|
147
205
|
goNext() {
|
|
148
206
|
if (this.currentIndex + 1 > this.indexMax) {
|
|
149
207
|
return;
|
|
150
208
|
}
|
|
151
209
|
this.goTo(this.currentIndex + 1);
|
|
152
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Go to the previous slide.
|
|
213
|
+
*/
|
|
153
214
|
goPrev() {
|
|
154
215
|
if (this.currentIndex - 1 < 0) {
|
|
155
216
|
return;
|
|
156
217
|
}
|
|
157
218
|
this.goTo(this.currentIndex - 1);
|
|
158
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Go to the given index.
|
|
222
|
+
*/
|
|
159
223
|
goTo(index, { withInstantMove = true } = {}) {
|
|
160
224
|
if (index < 0 || index > this.indexMax) {
|
|
161
225
|
throw new Error("Index out of bound.");
|
|
@@ -176,10 +240,16 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
176
240
|
this.currentIndex = index;
|
|
177
241
|
this.$emit("goto", index);
|
|
178
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Listen to the Draggable `start` event.
|
|
245
|
+
*/
|
|
179
246
|
onSliderDragStart() {
|
|
180
247
|
this.__initialX = this.currentSliderItem ? this.currentSliderItem.x : 0;
|
|
181
248
|
this.__distanceX = this.__initialX;
|
|
182
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Listen to the Draggable `drag` event.
|
|
252
|
+
*/
|
|
183
253
|
onSliderDragDrag(props) {
|
|
184
254
|
if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {
|
|
185
255
|
return;
|
|
@@ -189,6 +259,9 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
189
259
|
item.moveInstantly(this.__distanceX);
|
|
190
260
|
});
|
|
191
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Listen to the Draggable `drop` event and find the new active slide.
|
|
264
|
+
*/
|
|
192
265
|
onSliderDragDrop(props) {
|
|
193
266
|
if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {
|
|
194
267
|
return;
|
|
@@ -216,12 +289,21 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
216
289
|
this.currentIndex = closestIndex;
|
|
217
290
|
}
|
|
218
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Enable focus.
|
|
294
|
+
*/
|
|
219
295
|
onWrapperFocus() {
|
|
220
296
|
this.hasFocus = true;
|
|
221
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Disable focus.
|
|
300
|
+
*/
|
|
222
301
|
onWrapperBlur() {
|
|
223
302
|
this.hasFocus = false;
|
|
224
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Go prev or next when focus is on the wrapper and pressing arrow keys.
|
|
306
|
+
*/
|
|
225
307
|
keyed({ LEFT, RIGHT, isDown }) {
|
|
226
308
|
if (this.hasFocus && isDown) {
|
|
227
309
|
if (LEFT) {
|
|
@@ -231,6 +313,9 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
231
313
|
}
|
|
232
314
|
}
|
|
233
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Prepare invisible items.
|
|
318
|
+
*/
|
|
234
319
|
prepareInvisibleItems() {
|
|
235
320
|
const state = this.states[this.currentIndex];
|
|
236
321
|
const nextItemsToPrepare = [];
|
|
@@ -257,6 +342,9 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
257
342
|
}
|
|
258
343
|
});
|
|
259
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Get the state where the given item will be visible.
|
|
347
|
+
*/
|
|
260
348
|
getStateWhereItemWillBeInvisible(item, { reversed = false } = {}) {
|
|
261
349
|
const visibleStates = this.states.filter(
|
|
262
350
|
(state) => item.willBeVisible(this.getStateValueByMode(state.x))
|
|
@@ -269,15 +357,24 @@ var Slider = class extends import_js_toolkit.Base {
|
|
|
269
357
|
const lastVisibleStateIndex = this.states.findIndex((state) => state.x === lastVisibleState.x);
|
|
270
358
|
return reversed ? this.states[lastVisibleStateIndex + 1] : this.states[firstVisibleStateIndex - 1];
|
|
271
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Get the visible slides for the given position.
|
|
362
|
+
*/
|
|
272
363
|
getVisibleItems(target) {
|
|
273
364
|
return this.$children.SliderItem.filter((item) => item.isVisible || item.willBeVisible(target));
|
|
274
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Get the invisible slides for the given position.
|
|
368
|
+
*/
|
|
275
369
|
getInvisibleItems(target) {
|
|
276
370
|
return this.$children.SliderItem.filter(
|
|
277
371
|
(item) => !item.isVisible && !item.willBeVisible(target)
|
|
278
372
|
);
|
|
279
373
|
}
|
|
280
374
|
};
|
|
375
|
+
/**
|
|
376
|
+
* Config.
|
|
377
|
+
*/
|
|
281
378
|
__publicField(Slider, "config", {
|
|
282
379
|
name: "Slider",
|
|
283
380
|
refs: ["wrapper", "debug"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/ui/molecules/Slider/Slider.ts"],
|
|
4
|
-
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type { BaseProps, BaseConfig, DragServiceProps, KeyServiceProps } from '@studiometa/js-toolkit';\nimport { clamp, inertiaFinalValue, nextFrame, isDev } from '@studiometa/js-toolkit/utils';\nimport { SliderDrag } from './SliderDrag.js';\nimport { SliderItem } from './SliderItem.js';\n\nexport type SliderModes = 'left' | 'center' | 'right';\n\ntype SliderState = { x: Record<SliderModes, number> };\n\nexport interface SliderProps extends BaseProps {\n $refs: {\n wrapper: HTMLElement;\n }\n $children: {\n SliderItem: SliderItem[];\n SliderDrag: SliderDrag[];\n };\n $options: {\n mode: SliderModes;\n fitBounds: boolean;\n sensitivity: number;\n dropSensitivity: number;\n }\n}\n\n/**\n * Orchestrate the slider items state transition.\n * @todo a11y\n */\nexport class Slider<T extends BaseProps = BaseProps> extends Base<T & SliderProps> {\n /**\n * Config.\n */\n static config :BaseConfig = {\n name: 'Slider',\n refs: ['wrapper', 'debug'],\n emits: ['goto', 'index'],\n components: {\n SliderItem,\n SliderDrag,\n },\n options: {\n mode: { type: String, default: 'left' },\n fitBounds: Boolean,\n contain: Boolean,\n sensitivity: { type: Number, default: 1 },\n dropSensitivity: { type: Number, default: 2 },\n },\n };\n\n __distanceX = 0;\n\n __initialX = 0;\n\n /**\n * Index of the current active slide.\n */\n __currentIndex = 0;\n\n /**\n * Get the current index.\n */\n get currentIndex() {\n return this.__currentIndex;\n }\n\n /**\n * Set the current index and emit the `index` event.\n */\n set currentIndex(value:number) {\n this.currentSliderItem.disactivate();\n this.$emit('index', value);\n this.__currentIndex = value;\n this.currentSliderItem.activate();\n }\n\n /**\n * Store all the states.\n */\n states:SliderState[] = [];\n\n /**\n * Origins for the different modes.\n */\n origins:Record<SliderModes, number> = {\n left: 0,\n center: 0,\n right: 0,\n };\n\n /**\n * Wether or not the wrapper is focused.\n * @type {boolean}\n */\n hasFocus = false;\n\n /**\n * Get the current state.\n */\n get currentState() {\n return this.states[this.currentIndex];\n }\n\n /**\n * Get the first state.\n */\n get firstState() {\n return this.states[0];\n }\n\n /**\n * Get the last state.\n */\n get lastState() {\n return this.states.at(-1);\n }\n\n /**\n * Get the minimal contain state value.\n */\n get containMinState():number {\n return this.getStateValueByMode(this.firstState.x, 'left');\n }\n\n /**\n * Get the maximal contain state value.\n */\n get containMaxState():number {\n return this.getStateValueByMode(this.lastState.x, 'right');\n }\n\n /**\n * Get the last index.\n */\n get indexMax():number {\n return this.$children.SliderItem.length - 1;\n }\n\n /**\n * Get the current SliderItem\n */\n get currentSliderItem() {\n return this.$children.SliderItem[this.currentIndex];\n }\n\n /**\n * Get the states for each SliderItem.\n */\n getStates():SliderState[] {\n const { wrapper } = this.$refs;\n const originRect = wrapper.getBoundingClientRect();\n\n this.origins = {\n left: originRect.left,\n center: originRect.x + originRect.width / 2,\n right: originRect.x + originRect.width,\n };\n\n const states:SliderState[] = this.$children.SliderItem.map((item) => ({\n x: {\n left: (item.rect.x - this.origins.left) * -1,\n center: (item.rect.x + item.rect.width / 2 - this.origins.center) * -1,\n right: (item.rect.x + item.rect.width - this.origins.right) * -1,\n },\n }));\n\n if (this.$options.contain) {\n const { mode } = this.$options;\n // Find state where last child has passed the wrapper bound completely\n if (mode === 'left') {\n const lastChild = this.$children.SliderItem.at(-1);\n\n const maxState = states.find((state) => {\n const lastChildPosition =\n lastChild.rect.x - this.origins.left + lastChild.rect.width + state.x.left;\n const diffWithWrapperBound = originRect.width - lastChildPosition;\n if (diffWithWrapperBound > 0) {\n state.x.left = Math.min(state.x.left + diffWithWrapperBound, 0);\n return true;\n }\n\n return false;\n });\n\n if (maxState) {\n return states.map((state) => {\n state.x.left = Math.max(state.x.left, maxState.x.left);\n return state;\n });\n }\n }\n\n if (mode === 'right') {\n const maxStateIndex = states.findIndex((state) => state.x.right <= 0);\n const maxState = maxStateIndex < 0 ? states.at(-1) : states[maxStateIndex - 1];\n\n return states.map((state) => {\n state.x.right = maxStateIndex < 0 ? maxState.x.right : Math.min(state.x.right, 0);\n return state;\n });\n }\n\n if (mode === 'center' && isDev) {\n console.warn(\n `[${this.$id}]`,\n 'The `center` mode is not yet compatible with the `contain` mode.',\n );\n }\n }\n\n return states;\n }\n\n /**\n * Get an origin by mode.\n */\n getOriginByMode(mode?:SliderModes) {\n return this.origins[mode ?? this.$options.mode];\n }\n\n /**\n * Get a state value according to the given mode.\n */\n getStateValueByMode(state:SliderState['x'], mode?:SliderModes) {\n return state[mode ?? this.$options.mode];\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.states = this.getStates();\n this.prepareInvisibleItems();\n this.goTo(this.currentIndex);\n }\n\n /**\n * Resized hook.\n */\n resized() {\n nextFrame(() => {\n this.states = this.getStates();\n nextFrame(() => {\n this.prepareInvisibleItems();\n this.goTo(this.currentIndex);\n });\n });\n }\n\n /**\n * Go to the next slide.\n */\n goNext() {\n if (this.currentIndex + 1 > this.indexMax) {\n return;\n }\n\n this.goTo(this.currentIndex + 1);\n }\n\n /**\n * Go to the previous slide.\n */\n goPrev() {\n if (this.currentIndex - 1 < 0) {\n return;\n }\n\n this.goTo(this.currentIndex - 1);\n }\n\n /**\n * Go to the given index.\n */\n goTo(index:number, { withInstantMove = true } = {}) {\n if (index < 0 || index > this.indexMax) {\n throw new Error('Index out of bound.');\n }\n\n const currentState = this.getStateValueByMode(this.currentState.x);\n const state = this.getStateValueByMode(this.states[index].x);\n const itemsToMove = this.getVisibleItems(state);\n const invisibleItemsToMoveInstantly = this.getInvisibleItems(state);\n\n itemsToMove.forEach((item) => {\n // Better perfs when going fast through the slides\n if (currentState !== state && withInstantMove) {\n item.moveInstantly(currentState);\n }\n nextFrame(() => item.move(state));\n });\n invisibleItemsToMoveInstantly.forEach((item) => {\n item.moveInstantly(state);\n });\n\n this.currentIndex = index;\n this.$emit('goto', index);\n }\n\n /**\n * Listen to the Draggable `start` event.\n */\n onSliderDragStart() {\n this.__initialX = this.currentSliderItem ? this.currentSliderItem.x : 0;\n this.__distanceX = this.__initialX;\n }\n\n /**\n * Listen to the Draggable `drag` event.\n */\n onSliderDragDrag(props:DragServiceProps) {\n if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {\n return;\n }\n\n this.__distanceX = this.__initialX + props.distance.x * this.$options.sensitivity;\n\n this.getVisibleItems(this.__distanceX).forEach((item) => {\n item.moveInstantly(this.__distanceX);\n });\n }\n\n /**\n * Listen to the Draggable `drop` event and find the new active slide.\n */\n onSliderDragDrop(props:DragServiceProps) {\n if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {\n return;\n }\n\n let finalX = clamp(\n inertiaFinalValue(this.__distanceX, props.delta.x * this.$options.dropSensitivity),\n this.getStateValueByMode(this.firstState.x),\n this.getStateValueByMode(this.lastState.x),\n );\n\n const absoluteDifferencesBetweenDistanceAndState = this.states.map((state) =>\n Math.abs(finalX - this.getStateValueByMode(state.x)),\n );\n const minimumDifference = Math.min(...absoluteDifferencesBetweenDistanceAndState);\n const closestIndex = absoluteDifferencesBetweenDistanceAndState.indexOf(minimumDifference);\n\n if (this.$options.fitBounds) {\n this.goTo(closestIndex, { withInstantMove: false });\n } else {\n if (this.$options.contain) {\n finalX = Math.min(this.containMinState, finalX);\n finalX = Math.max(this.containMaxState, finalX);\n }\n this.$children.SliderItem.forEach((item) => {\n item.move(finalX);\n });\n this.currentIndex = closestIndex;\n }\n }\n\n /**\n * Enable focus.\n */\n onWrapperFocus() {\n this.hasFocus = true;\n }\n\n /**\n * Disable focus.\n */\n onWrapperBlur() {\n this.hasFocus = false;\n }\n\n /**\n * Go prev or next when focus is on the wrapper and pressing arrow keys.\n */\n keyed({ LEFT, RIGHT, isDown }:KeyServiceProps) {\n if (this.hasFocus && isDown) {\n if (LEFT) {\n this.goPrev();\n } else if (RIGHT) {\n this.goNext();\n }\n }\n }\n\n /**\n * Prepare invisible items.\n */\n prepareInvisibleItems() {\n const state = this.states[this.currentIndex];\n const nextItemsToPrepare = [];\n const previousItemsToPrepare = [];\n\n this.getInvisibleItems(this.getStateValueByMode(state.x)).forEach((item, i) => {\n if (i > this.currentIndex) {\n nextItemsToPrepare.push(item);\n return;\n }\n\n if (i < this.currentIndex) {\n previousItemsToPrepare.push(item);\n }\n });\n\n nextItemsToPrepare.forEach((item) => {\n const invisibleState = this.getStateWhereItemWillBeInvisible(item);\n if (invisibleState) {\n item.moveInstantly(this.getStateValueByMode(invisibleState.x));\n }\n });\n\n previousItemsToPrepare.forEach((item) => {\n const invisibleState = this.getStateWhereItemWillBeInvisible(item, { reversed: true });\n if (invisibleState) {\n item.moveInstantly(this.getStateValueByMode(invisibleState.x));\n }\n });\n }\n\n /**\n * Get the state where the given item will be visible.\n */\n getStateWhereItemWillBeInvisible(item:SliderItem, { reversed = false } = {}):SliderState {\n const visibleStates = this.states.filter((state) =>\n item.willBeVisible(this.getStateValueByMode(state.x)),\n );\n const firstVisibleState = visibleStates[0];\n const lastVisibleState = visibleStates.at(-1);\n const firstVisibleStateIndex = this.states.findIndex(\n (state) =>\n this.getStateValueByMode(state.x) === this.getStateValueByMode(firstVisibleState.x),\n );\n const lastVisibleStateIndex = this.states.findIndex((state) => state.x === lastVisibleState.x);\n\n return reversed\n ? this.states[lastVisibleStateIndex + 1]\n : this.states[firstVisibleStateIndex - 1];\n }\n\n /**\n * Get the visible slides for the given position.\n */\n getVisibleItems(target:number) {\n return this.$children.SliderItem.filter((item) => item.isVisible || item.willBeVisible(target));\n }\n\n /**\n * Get the invisible slides for the given position.\n */\n getInvisibleItems(target:number) {\n return this.$children.SliderItem.filter(\n (item) => !item.isVisible && !item.willBeVisible(target),\n );\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqB;
|
|
4
|
+
"sourcesContent": ["import { Base } from '@studiometa/js-toolkit';\nimport type {\n BaseProps,\n BaseConfig,\n DragServiceProps,\n KeyServiceProps,\n} from '@studiometa/js-toolkit';\nimport { clamp, inertiaFinalValue, nextFrame, isDev } from '@studiometa/js-toolkit/utils';\nimport { SliderDrag } from './SliderDrag.js';\nimport { SliderItem } from './SliderItem.js';\n\nexport type SliderModes = 'left' | 'center' | 'right';\n\ntype SliderState = { x: Record<SliderModes, number> };\n\nexport interface SliderProps extends BaseProps {\n $refs: {\n wrapper: HTMLElement;\n };\n $children: {\n SliderItem: SliderItem[];\n SliderDrag: SliderDrag[];\n };\n $options: {\n mode: SliderModes;\n fitBounds: boolean;\n contain: boolean;\n sensitivity: number;\n dropSensitivity: number;\n };\n}\n\n/**\n * Orchestrate the slider items state transition.\n * @todo a11y\n */\nexport class Slider<T extends BaseProps = BaseProps> extends Base<T & SliderProps> {\n /**\n * Config.\n */\n static config: BaseConfig = {\n name: 'Slider',\n refs: ['wrapper', 'debug'],\n emits: ['goto', 'index'],\n components: {\n SliderItem,\n SliderDrag,\n },\n options: {\n mode: { type: String, default: 'left' },\n fitBounds: Boolean,\n contain: Boolean,\n sensitivity: { type: Number, default: 1 },\n dropSensitivity: { type: Number, default: 2 },\n },\n };\n\n __distanceX = 0;\n\n __initialX = 0;\n\n /**\n * Index of the current active slide.\n */\n __currentIndex = 0;\n\n /**\n * Get the current index.\n */\n get currentIndex() {\n return this.__currentIndex;\n }\n\n /**\n * Set the current index and emit the `index` event.\n */\n set currentIndex(value: number) {\n this.currentSliderItem.disactivate();\n this.$emit('index', value);\n this.__currentIndex = value;\n this.currentSliderItem.activate();\n }\n\n /**\n * Store all the states.\n */\n states: SliderState[] = [];\n\n /**\n * Origins for the different modes.\n */\n origins: Record<SliderModes, number> = {\n left: 0,\n center: 0,\n right: 0,\n };\n\n /**\n * Wether or not the wrapper is focused.\n * @type {boolean}\n */\n hasFocus = false;\n\n /**\n * Get the current state.\n */\n get currentState() {\n return this.states[this.currentIndex];\n }\n\n /**\n * Get the first state.\n */\n get firstState() {\n return this.states[0];\n }\n\n /**\n * Get the last state.\n */\n get lastState() {\n return this.states.at(-1);\n }\n\n /**\n * Get the minimal contain state value.\n */\n get containMinState(): number {\n return this.getStateValueByMode(this.firstState.x, 'left');\n }\n\n /**\n * Get the maximal contain state value.\n */\n get containMaxState(): number {\n return this.getStateValueByMode(this.lastState.x, 'right');\n }\n\n /**\n * Get the last index.\n */\n get indexMax(): number {\n return this.$children.SliderItem.length - 1;\n }\n\n /**\n * Get the current SliderItem\n */\n get currentSliderItem() {\n return this.$children.SliderItem[this.currentIndex];\n }\n\n /**\n * Get the states for each SliderItem.\n */\n getStates(): SliderState[] {\n const { wrapper } = this.$refs;\n const originRect = wrapper.getBoundingClientRect();\n\n this.origins = {\n left: originRect.left,\n center: originRect.x + originRect.width / 2,\n right: originRect.x + originRect.width,\n };\n\n const states: SliderState[] = this.$children.SliderItem.map((item) => ({\n x: {\n left: (item.rect.x - this.origins.left) * -1,\n center: (item.rect.x + item.rect.width / 2 - this.origins.center) * -1,\n right: (item.rect.x + item.rect.width - this.origins.right) * -1,\n },\n }));\n\n if (this.$options.contain) {\n const { mode } = this.$options;\n // Find state where last child has passed the wrapper bound completely\n if (mode === 'left') {\n const lastChild = this.$children.SliderItem.at(-1);\n\n const maxState = states.find((state) => {\n const lastChildPosition =\n lastChild.rect.x - this.origins.left + lastChild.rect.width + state.x.left;\n const diffWithWrapperBound = originRect.width - lastChildPosition;\n if (diffWithWrapperBound > 0) {\n state.x.left = Math.min(state.x.left + diffWithWrapperBound, 0);\n return true;\n }\n\n return false;\n });\n\n if (maxState) {\n return states.map((state) => {\n state.x.left = Math.max(state.x.left, maxState.x.left);\n return state;\n });\n }\n }\n\n if (mode === 'right') {\n const maxStateIndex = states.findIndex((state) => state.x.right <= 0);\n const maxState = maxStateIndex < 0 ? states.at(-1) : states[maxStateIndex - 1];\n\n return states.map((state) => {\n state.x.right = maxStateIndex < 0 ? maxState.x.right : Math.min(state.x.right, 0);\n return state;\n });\n }\n\n if (mode === 'center' && isDev) {\n console.warn(\n `[${this.$id}]`,\n 'The `center` mode is not yet compatible with the `contain` mode.',\n );\n }\n }\n\n return states;\n }\n\n /**\n * Get an origin by mode.\n */\n getOriginByMode(mode?: SliderModes) {\n return this.origins[mode ?? this.$options.mode];\n }\n\n /**\n * Get a state value according to the given mode.\n */\n getStateValueByMode(state: SliderState['x'], mode?: SliderModes) {\n return state[mode ?? this.$options.mode];\n }\n\n /**\n * Mounted hook.\n */\n mounted() {\n this.states = this.getStates();\n this.prepareInvisibleItems();\n this.goTo(this.currentIndex);\n }\n\n /**\n * Resized hook.\n */\n resized() {\n nextFrame(() => {\n this.states = this.getStates();\n nextFrame(() => {\n this.prepareInvisibleItems();\n this.goTo(this.currentIndex);\n });\n });\n }\n\n /**\n * Go to the next slide.\n */\n goNext() {\n if (this.currentIndex + 1 > this.indexMax) {\n return;\n }\n\n this.goTo(this.currentIndex + 1);\n }\n\n /**\n * Go to the previous slide.\n */\n goPrev() {\n if (this.currentIndex - 1 < 0) {\n return;\n }\n\n this.goTo(this.currentIndex - 1);\n }\n\n /**\n * Go to the given index.\n */\n goTo(index: number, { withInstantMove = true } = {}) {\n if (index < 0 || index > this.indexMax) {\n throw new Error('Index out of bound.');\n }\n\n const currentState = this.getStateValueByMode(this.currentState.x);\n const state = this.getStateValueByMode(this.states[index].x);\n const itemsToMove = this.getVisibleItems(state);\n const invisibleItemsToMoveInstantly = this.getInvisibleItems(state);\n\n itemsToMove.forEach((item) => {\n // Better perfs when going fast through the slides\n if (currentState !== state && withInstantMove) {\n item.moveInstantly(currentState);\n }\n nextFrame(() => item.move(state));\n });\n invisibleItemsToMoveInstantly.forEach((item) => {\n item.moveInstantly(state);\n });\n\n this.currentIndex = index;\n this.$emit('goto', index);\n }\n\n /**\n * Listen to the Draggable `start` event.\n */\n onSliderDragStart() {\n this.__initialX = this.currentSliderItem ? this.currentSliderItem.x : 0;\n this.__distanceX = this.__initialX;\n }\n\n /**\n * Listen to the Draggable `drag` event.\n */\n onSliderDragDrag(props: DragServiceProps) {\n if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {\n return;\n }\n\n this.__distanceX = this.__initialX + props.distance.x * this.$options.sensitivity;\n\n this.getVisibleItems(this.__distanceX).forEach((item) => {\n item.moveInstantly(this.__distanceX);\n });\n }\n\n /**\n * Listen to the Draggable `drop` event and find the new active slide.\n */\n onSliderDragDrop(props: DragServiceProps) {\n if (Math.abs(props.delta.y) > Math.abs(props.delta.x)) {\n return;\n }\n\n let finalX = clamp(\n inertiaFinalValue(this.__distanceX, props.delta.x * this.$options.dropSensitivity),\n this.getStateValueByMode(this.firstState.x),\n this.getStateValueByMode(this.lastState.x),\n );\n\n const absoluteDifferencesBetweenDistanceAndState = this.states.map((state) =>\n Math.abs(finalX - this.getStateValueByMode(state.x)),\n );\n const minimumDifference = Math.min(...absoluteDifferencesBetweenDistanceAndState);\n const closestIndex = absoluteDifferencesBetweenDistanceAndState.indexOf(minimumDifference);\n\n if (this.$options.fitBounds) {\n this.goTo(closestIndex, { withInstantMove: false });\n } else {\n if (this.$options.contain) {\n finalX = Math.min(this.containMinState, finalX);\n finalX = Math.max(this.containMaxState, finalX);\n }\n this.$children.SliderItem.forEach((item) => {\n item.move(finalX);\n });\n this.currentIndex = closestIndex;\n }\n }\n\n /**\n * Enable focus.\n */\n onWrapperFocus() {\n this.hasFocus = true;\n }\n\n /**\n * Disable focus.\n */\n onWrapperBlur() {\n this.hasFocus = false;\n }\n\n /**\n * Go prev or next when focus is on the wrapper and pressing arrow keys.\n */\n keyed({ LEFT, RIGHT, isDown }: KeyServiceProps) {\n if (this.hasFocus && isDown) {\n if (LEFT) {\n this.goPrev();\n } else if (RIGHT) {\n this.goNext();\n }\n }\n }\n\n /**\n * Prepare invisible items.\n */\n prepareInvisibleItems() {\n const state = this.states[this.currentIndex];\n const nextItemsToPrepare = [];\n const previousItemsToPrepare = [];\n\n this.getInvisibleItems(this.getStateValueByMode(state.x)).forEach((item, i) => {\n if (i > this.currentIndex) {\n nextItemsToPrepare.push(item);\n return;\n }\n\n if (i < this.currentIndex) {\n previousItemsToPrepare.push(item);\n }\n });\n\n nextItemsToPrepare.forEach((item) => {\n const invisibleState = this.getStateWhereItemWillBeInvisible(item);\n if (invisibleState) {\n item.moveInstantly(this.getStateValueByMode(invisibleState.x));\n }\n });\n\n previousItemsToPrepare.forEach((item) => {\n const invisibleState = this.getStateWhereItemWillBeInvisible(item, { reversed: true });\n if (invisibleState) {\n item.moveInstantly(this.getStateValueByMode(invisibleState.x));\n }\n });\n }\n\n /**\n * Get the state where the given item will be visible.\n */\n getStateWhereItemWillBeInvisible(item: SliderItem, { reversed = false } = {}): SliderState {\n const visibleStates = this.states.filter((state) =>\n item.willBeVisible(this.getStateValueByMode(state.x)),\n );\n const firstVisibleState = visibleStates[0];\n const lastVisibleState = visibleStates.at(-1);\n const firstVisibleStateIndex = this.states.findIndex(\n (state) =>\n this.getStateValueByMode(state.x) === this.getStateValueByMode(firstVisibleState.x),\n );\n const lastVisibleStateIndex = this.states.findIndex((state) => state.x === lastVisibleState.x);\n\n return reversed\n ? this.states[lastVisibleStateIndex + 1]\n : this.states[firstVisibleStateIndex - 1];\n }\n\n /**\n * Get the visible slides for the given position.\n */\n getVisibleItems(target: number) {\n return this.$children.SliderItem.filter((item) => item.isVisible || item.willBeVisible(target));\n }\n\n /**\n * Get the invisible slides for the given position.\n */\n getInvisibleItems(target: number) {\n return this.$children.SliderItem.filter(\n (item) => !item.isVisible && !item.willBeVisible(target),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAqB;AAOrB,mBAA2D;AAC3D,wBAA2B;AAC3B,wBAA2B;AA2BpB,IAAM,SAAN,cAAsD,uBAAsB;AAAA,EAqBjF,cAAc;AAAA,EAEd,aAAa;AAAA;AAAA;AAAA;AAAA,EAKb,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAKjB,IAAI,eAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,aAAa,OAAe;AAC9B,SAAK,kBAAkB,YAAY;AACnC,SAAK,MAAM,SAAS,KAAK;AACzB,SAAK,iBAAiB;AACtB,SAAK,kBAAkB,SAAS;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,SAAwB,CAAC;AAAA;AAAA;AAAA;AAAA,EAKzB,UAAuC;AAAA,IACrC,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW;AAAA;AAAA;AAAA;AAAA,EAKX,IAAI,eAAe;AACjB,WAAO,KAAK,OAAO,KAAK,YAAY;AAAA,EACtC;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AS;AAAA,IACT,aAAa,EAAE,MAAM,QAAQ,SAAS,EAAE;AAAA,IACxC,iBAAiB,EAAE,MAAM,QAAQ,SAAS,EAAE;AAAA,EAC9C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,8 +2,8 @@ import { Base } from '@studiometa/js-toolkit';
|
|
|
2
2
|
import type { BaseProps, BaseConfig, DragServiceProps, KeyServiceProps } from '@studiometa/js-toolkit';
|
|
3
3
|
import { SliderDrag } from './SliderDrag.js';
|
|
4
4
|
import { SliderItem } from './SliderItem.js';
|
|
5
|
-
export
|
|
6
|
-
|
|
5
|
+
export type SliderModes = 'left' | 'center' | 'right';
|
|
6
|
+
type SliderState = {
|
|
7
7
|
x: Record<SliderModes, number>;
|
|
8
8
|
};
|
|
9
9
|
export interface SliderProps extends BaseProps {
|
|
@@ -17,6 +17,7 @@ export interface SliderProps extends BaseProps {
|
|
|
17
17
|
$options: {
|
|
18
18
|
mode: SliderModes;
|
|
19
19
|
fitBounds: boolean;
|
|
20
|
+
contain: boolean;
|
|
20
21
|
sensitivity: number;
|
|
21
22
|
dropSensitivity: number;
|
|
22
23
|
};
|