@studiometa/ui 0.2.6 → 0.2.9

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.
Files changed (56) hide show
  1. package/atoms/Cursor/Cursor.cjs +5 -1
  2. package/atoms/Cursor/Cursor.d.ts +6 -0
  3. package/atoms/Cursor/Cursor.js +1 -1
  4. package/atoms/LargeText/LargeText.cjs +14 -14
  5. package/atoms/LargeText/LargeText.d.ts +3 -4
  6. package/atoms/LargeText/LargeText.js +1 -1
  7. package/atoms/LargeText/LargeText.twig +1 -1
  8. package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +18 -59
  9. package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +28 -55
  10. package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -1
  11. package/atoms/ScrollAnimation/ScrollAnimation.d.ts +9 -4
  12. package/atoms/ScrollAnimation/animationScrollWithEase.cjs +3 -24
  13. package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -1
  14. package/molecules/Menu/Menu.cjs +7 -16
  15. package/molecules/Menu/Menu.d.ts +12 -12
  16. package/molecules/Menu/Menu.js +1 -1
  17. package/molecules/Menu/MenuBtn.cjs +1 -5
  18. package/molecules/Menu/MenuBtn.d.ts +0 -1
  19. package/molecules/Menu/MenuBtn.js +1 -1
  20. package/molecules/Menu/MenuList.cjs +1 -2
  21. package/molecules/Menu/MenuList.d.ts +1 -2
  22. package/molecules/Menu/MenuList.js +1 -1
  23. package/molecules/Modal/Modal.cjs +11 -3
  24. package/molecules/Modal/Modal.d.ts +17 -5
  25. package/molecules/Modal/Modal.js +1 -1
  26. package/molecules/Modal/Modal.twig +5 -2
  27. package/molecules/Modal/StyledModal.twig +5 -2
  28. package/molecules/Panel/StyledPanel.twig +8 -3
  29. package/molecules/Slider/AbstractSliderChild.cjs +8 -1
  30. package/molecules/Slider/AbstractSliderChild.d.ts +2 -2
  31. package/molecules/Slider/AbstractSliderChild.js +1 -1
  32. package/molecules/Slider/Slider.cjs +12 -4
  33. package/molecules/Slider/Slider.d.ts +11 -0
  34. package/molecules/Slider/Slider.js +1 -1
  35. package/molecules/Slider/SliderBtn.d.ts +8 -0
  36. package/molecules/Slider/SliderCount.d.ts +8 -0
  37. package/molecules/Slider/SliderDots.d.ts +8 -0
  38. package/molecules/Slider/SliderDrag.cjs +5 -1
  39. package/molecules/Slider/SliderDrag.d.ts +7 -0
  40. package/molecules/Slider/SliderDrag.js +1 -1
  41. package/molecules/Slider/SliderItem.cjs +7 -6
  42. package/molecules/Slider/SliderItem.d.ts +9 -0
  43. package/molecules/Slider/SliderItem.js +1 -1
  44. package/molecules/Slider/SliderProgress.cjs +7 -3
  45. package/molecules/Slider/SliderProgress.d.ts +8 -0
  46. package/molecules/Slider/SliderProgress.js +1 -1
  47. package/organisms/Frame/Frame.cjs +12 -16
  48. package/organisms/Frame/Frame.d.ts +4 -14
  49. package/organisms/Frame/Frame.js +1 -1
  50. package/organisms/Frame/FrameAnchor.cjs +1 -5
  51. package/organisms/Frame/FrameAnchor.d.ts +0 -8
  52. package/organisms/Frame/FrameAnchor.js +1 -1
  53. package/organisms/Frame/FrameForm.cjs +1 -5
  54. package/organisms/Frame/FrameForm.d.ts +0 -8
  55. package/organisms/Frame/FrameForm.js +1 -1
  56. package/package.json +2 -2
@@ -51,7 +51,7 @@ var Cursor = class extends import_js_toolkit.Base {
51
51
  }
52
52
  this.pointerX = x;
53
53
  this.pointerY = y;
54
- let scale = 1;
54
+ let { scale } = this.$options;
55
55
  if (!event) {
56
56
  this.pointerScale = scale;
57
57
  return;
@@ -96,6 +96,10 @@ __publicField(Cursor, "config", {
96
96
  type: String,
97
97
  default: "[data-cursor-shrink], [data-cursor-shrink] *"
98
98
  },
99
+ scale: {
100
+ type: Number,
101
+ default: 1
102
+ },
99
103
  growTo: {
100
104
  type: Number,
101
105
  default: 2
@@ -6,6 +6,7 @@
6
6
  * @typedef {Object} CursorOptions
7
7
  * @property {string} growSelectors
8
8
  * @property {string} shrinkSelectors
9
+ * @property {number} scale
9
10
  * @property {number} growTo
10
11
  * @property {number} shrinkTo
11
12
  * @property {number} translateDampFactor
@@ -37,6 +38,10 @@ export default class Cursor extends Base {
37
38
  type: StringConstructor;
38
39
  default: string;
39
40
  };
41
+ scale: {
42
+ type: NumberConstructor;
43
+ default: number;
44
+ };
40
45
  growTo: {
41
46
  type: NumberConstructor;
42
47
  default: number;
@@ -125,6 +130,7 @@ export type BaseOptions = import('@studiometa/js-toolkit/Base').BaseOptions;
125
130
  export type CursorOptions = {
126
131
  growSelectors: string;
127
132
  shrinkSelectors: string;
133
+ scale: number;
128
134
  growTo: number;
129
135
  shrinkTo: number;
130
136
  translateDampFactor: number;
@@ -1 +1 @@
1
- import{Base as n}from"@studiometa/js-toolkit";import{damp as a,matrix as c}from"@studiometa/js-toolkit/utils";class l extends n{static config={name:"Cursor",options:{growSelectors:{type:String,default:"a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *"},shrinkSelectors:{type:String,default:"[data-cursor-shrink], [data-cursor-shrink] *"},growTo:{type:Number,default:2},shrinkTo:{type:Number,default:.5},translateDampFactor:{type:Number,default:.25},growDampFactor:{type:Number,default:.25},shrinkDampFactor:{type:Number,default:.25}}};x=0;y=0;scale=0;pointerX=0;pointerY=0;pointerScale=0;mounted(){this.x=0,this.y=0,this.scale=0,this.pointerX=0,this.pointerY=0,this.pointerScale=0,this.render({x:this.x,y:this.y,scale:this.scale})}moved({event:t,x:i,y:s,isDown:r}){this.$services.has("ticked")||this.$services.enable("ticked"),this.pointerX=i,this.pointerY=s;let e=1;if(!t){this.pointerScale=e;return}const o=t.target instanceof Element&&t.target.matches(this.$options.growSelectors)||!1,h=r||t.target instanceof Element&&t.target.matches(this.$options.shrinkSelectors)||!1;o&&(e=this.$options.growTo),h&&(e=this.$options.shrinkTo),this.pointerScale=e}ticked(){this.x=a(this.pointerX,this.x,this.$options.translateDampFactor),this.y=a(this.pointerY,this.y,this.$options.translateDampFactor),this.scale=a(this.pointerScale,this.scale,this.pointerScale<this.scale?this.$options.shrinkDampFactor:this.$options.growDampFactor),this.render({x:this.x,y:this.y,scale:this.scale}),this.x===this.pointerX&&this.y===this.pointerY&&this.scale===this.pointerScale&&this.$services.disable("ticked")}render({x:t,y:i,scale:s}){const r=c({translateX:t,translateY:i,scaleX:s,scaleY:s});this.$el.style.transform=`translateZ(0) ${r}`}}export{l as default};
1
+ import{Base as n}from"@studiometa/js-toolkit";import{damp as a,matrix as c}from"@studiometa/js-toolkit/utils";class l extends n{static config={name:"Cursor",options:{growSelectors:{type:String,default:"a, a *, button, button *, [data-cursor-grow], [data-cursor-grow] *"},shrinkSelectors:{type:String,default:"[data-cursor-shrink], [data-cursor-shrink] *"},scale:{type:Number,default:1},growTo:{type:Number,default:2},shrinkTo:{type:Number,default:.5},translateDampFactor:{type:Number,default:.25},growDampFactor:{type:Number,default:.25},shrinkDampFactor:{type:Number,default:.25}}};x=0;y=0;scale=0;pointerX=0;pointerY=0;pointerScale=0;mounted(){this.x=0,this.y=0,this.scale=0,this.pointerX=0,this.pointerY=0,this.pointerScale=0,this.render({x:this.x,y:this.y,scale:this.scale})}moved({event:t,x:i,y:s,isDown:r}){this.$services.has("ticked")||this.$services.enable("ticked"),this.pointerX=i,this.pointerY=s;let{scale:e}=this.$options;if(!t){this.pointerScale=e;return}const o=t.target instanceof Element&&t.target.matches(this.$options.growSelectors)||!1,h=r||t.target instanceof Element&&t.target.matches(this.$options.shrinkSelectors)||!1;o&&(e=this.$options.growTo),h&&(e=this.$options.shrinkTo),this.pointerScale=e}ticked(){this.x=a(this.pointerX,this.x,this.$options.translateDampFactor),this.y=a(this.pointerY,this.y,this.$options.translateDampFactor),this.scale=a(this.pointerScale,this.scale,this.pointerScale<this.scale?this.$options.shrinkDampFactor:this.$options.growDampFactor),this.render({x:this.x,y:this.y,scale:this.scale}),this.x===this.pointerX&&this.y===this.pointerY&&this.scale===this.pointerScale&&this.$services.disable("ticked")}render({x:t,y:i,scale:s}){const r=c({translateX:t,translateY:i,scaleX:s,scaleY:s});this.$el.style.transform=`translateZ(0) ${r}`}}export{l as default};
@@ -30,11 +30,11 @@ module.exports = __toCommonJS(LargeText_exports);
30
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
31
31
  var import_utils = require("@studiometa/js-toolkit/utils");
32
32
  var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_js_toolkit.Base, { rootMargin: "50%" }) {
33
- translateX = 0;
33
+ x = 0;
34
34
  deltaY = 0;
35
35
  transform = {
36
36
  skewX: 0,
37
- translateX: 0
37
+ x: 0
38
38
  };
39
39
  width = 0;
40
40
  mounted() {
@@ -47,21 +47,21 @@ var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_
47
47
  this.deltaY = props.delta.y;
48
48
  }
49
49
  ticked() {
50
- this.translateX -= (Math.abs(this.deltaY) + 1) * this.$options.sensitivity;
51
- this.transform.translateX = (0, import_utils.damp)(this.translateX, this.transform.translateX, 0.25);
50
+ this.x -= (Math.abs(this.deltaY) + 1) * this.$options.sensitivity;
51
+ this.transform.x = (0, import_utils.damp)(this.x, this.transform.x, 0.25);
52
52
  if (this.$options.skew) {
53
- this.transform.skewX = (0, import_utils.damp)((0, import_utils.clamp)(this.deltaY / 20 * -1, -0.5, 0.5) * this.$options.skewSensitivity, this.transform.skewX, 0.25);
53
+ this.transform.skewX = (0, import_utils.damp)((0, import_utils.clamp)(this.deltaY * -1, -50, 50) * this.$options.skewSensitivity, this.transform.skewX, 0.25);
54
54
  }
55
- if (this.translateX <= this.width * -1) {
56
- this.translateX = 0;
57
- this.transform.translateX += this.width;
58
- } else if (this.$options.sensitivity < 0 && this.translateX >= this.width) {
59
- this.translateX = 0;
60
- this.transform.translateX -= this.width;
55
+ if (this.x <= this.width * -1) {
56
+ this.x = 0;
57
+ this.transform.x += this.width;
58
+ } else if (this.$options.sensitivity < 0 && this.x >= this.width) {
59
+ this.x = 0;
60
+ this.transform.x -= this.width;
61
61
  }
62
- (0, import_utils.nextFrame)(() => {
63
- this.$refs.target.style.transform = (0, import_utils.matrix)(this.transform) + " translateZ(0px)";
64
- });
62
+ return () => {
63
+ (0, import_utils.transform)(this.$refs.target, this.transform);
64
+ };
65
65
  }
66
66
  };
67
67
  __publicField(LargeText, "config", {
@@ -34,7 +34,7 @@ export default class LargeText extends Base {
34
34
  * Translate X.
35
35
  * @type {number}
36
36
  */
37
- translateX: number;
37
+ x: number;
38
38
  /**
39
39
  * Scroll delta Y.
40
40
  * @type {number}
@@ -45,7 +45,7 @@ export default class LargeText extends Base {
45
45
  */
46
46
  transform: {
47
47
  skewX: number;
48
- translateX: number;
48
+ x: number;
49
49
  };
50
50
  /**
51
51
  * Target width.
@@ -77,9 +77,8 @@ export default class LargeText extends Base {
77
77
  * Update values on raf.
78
78
  *
79
79
  * @this {LargeTextInterface}
80
- * @returns {void}
81
80
  */
82
- ticked(this: LargeTextInterface): void;
81
+ ticked(this: LargeTextInterface): () => void;
83
82
  }
84
83
  export type LargeTextInterface = LargeText & {
85
84
  $refs: {
@@ -1 +1 @@
1
- import{Base as i,withMountWhenInView as e}from"@studiometa/js-toolkit";import{damp as t,matrix as a,clamp as r,nextFrame as n}from"@studiometa/js-toolkit/utils";class h extends e(i,{rootMargin:"50%"}){static config={name:"LargeText",refs:["target"],options:{skew:Boolean,sensitivity:{type:Number,default:1},skewSensitivity:{type:Number,default:1}}};translateX=0;deltaY=0;transform={skewX:0,translateX:0};width=0;mounted(){this.width=this.$refs.target.clientWidth}resized(){this.width=this.$refs.target.clientWidth}scrolled(s){this.deltaY=s.delta.y}ticked(){this.translateX-=(Math.abs(this.deltaY)+1)*this.$options.sensitivity,this.transform.translateX=t(this.translateX,this.transform.translateX,.25),this.$options.skew&&(this.transform.skewX=t(r(this.deltaY/20*-1,-.5,.5)*this.$options.skewSensitivity,this.transform.skewX,.25)),this.translateX<=this.width*-1?(this.translateX=0,this.transform.translateX+=this.width):this.$options.sensitivity<0&&this.translateX>=this.width&&(this.translateX=0,this.transform.translateX-=this.width),n(()=>{this.$refs.target.style.transform=a(this.transform)+" translateZ(0px)"})}}export{h as default};
1
+ import{Base as s,withMountWhenInView as e}from"@studiometa/js-toolkit";import{damp as t,clamp as h,transform as r}from"@studiometa/js-toolkit/utils";class a extends e(s,{rootMargin:"50%"}){static config={name:"LargeText",refs:["target"],options:{skew:Boolean,sensitivity:{type:Number,default:1},skewSensitivity:{type:Number,default:1}}};x=0;deltaY=0;transform={skewX:0,x:0};width=0;mounted(){this.width=this.$refs.target.clientWidth}resized(){this.width=this.$refs.target.clientWidth}scrolled(i){this.deltaY=i.delta.y}ticked(){return this.x-=(Math.abs(this.deltaY)+1)*this.$options.sensitivity,this.transform.x=t(this.x,this.transform.x,.25),this.$options.skew&&(this.transform.skewX=t(h(this.deltaY*-1,-50,50)*this.$options.skewSensitivity,this.transform.skewX,.25)),this.x<=this.width*-1?(this.x=0,this.transform.x+=this.width):this.$options.sensitivity<0&&this.x>=this.width&&(this.x=0,this.transform.x-=this.width),()=>{r(this.$refs.target,this.transform)}}}export{a as default};
@@ -18,7 +18,7 @@
18
18
  merge_html_attributes(
19
19
  attr ?? null,
20
20
  { data_component: 'LargeText' },
21
- { class: 'overflow-x-hidden pointer-events-none' }
21
+ { class: 'overflow-x-hidden pointer-events-none', style: { contain: 'content' } }
22
22
  )
23
23
  %}
24
24
 
@@ -29,71 +29,25 @@ __export(AbstractScrollAnimation_exports, {
29
29
  module.exports = __toCommonJS(AbstractScrollAnimation_exports);
30
30
  var import_js_toolkit = require("@studiometa/js-toolkit");
31
31
  var import_utils = require("@studiometa/js-toolkit/utils");
32
- function getDefaults() {
33
- return {
34
- x: 0,
35
- y: 0,
36
- z: 0,
37
- scale: 1,
38
- scaleX: 1,
39
- scaleY: 1,
40
- rotate: 0,
41
- skewX: 0,
42
- skewY: 0,
43
- opacity: 1
44
- };
45
- }
46
32
  var AbstractScrollAnimation = class extends (0, import_js_toolkit.withFreezedOptions)(import_js_toolkit.Base) {
47
33
  get target() {
48
34
  return this.$el;
49
35
  }
50
- get has() {
51
- const has = {
52
- x: false,
53
- y: false,
54
- z: false,
55
- scale: false,
56
- scaleX: false,
57
- scaleY: false,
58
- rotate: false,
59
- skewX: false,
60
- skewY: false,
61
- opacity: false,
62
- transform: false
63
- };
64
- Object.keys(this.$options.from).forEach((key) => {
65
- has[key] = this.$options.from[key] !== this.$options.to[key];
66
- });
67
- has.transform = Object.keys(has).filter((key) => key !== "opacity" && key !== "transform").some((key) => has[key]);
68
- Object.defineProperty(this, "has", { value: has });
69
- return has;
36
+ animation;
37
+ mounted() {
38
+ let { keyframes } = this.$options;
39
+ const { from, to } = this.$options;
40
+ if (keyframes.length <= 0 && from && to) {
41
+ keyframes = [from, to];
42
+ }
43
+ this.animation = (0, import_utils.animate)(this.target, keyframes, { easing: this.$options.easing });
70
44
  }
71
45
  scrolledInView(props) {
72
- if (!this.has.opacity && !this.has.transform) {
73
- return;
74
- }
75
46
  const progress = (0, import_utils.map)((0, import_utils.clamp)(props.dampedProgress.y, this.$options.playRange[0], this.$options.playRange[1]), this.$options.playRange[0], this.$options.playRange[1], 0, 1);
76
47
  this.render(progress);
77
48
  }
78
49
  render(progress) {
79
- if (this.has.opacity) {
80
- this.target.style.opacity = String((0, import_utils.map)(progress, 0, 1, this.$options.from.opacity, this.$options.to.opacity));
81
- }
82
- if (this.has.transform) {
83
- let transform = (0, import_utils.matrix)({
84
- translateX: this.has.x ? (0, import_utils.lerp)(this.$options.from.x, this.$options.to.x, progress) : void 0,
85
- translateY: this.has.y ? (0, import_utils.lerp)(this.$options.from.y, this.$options.to.y, progress) : void 0,
86
- scaleX: this.has.scale ? (0, import_utils.lerp)(this.$options.from.scale, this.$options.to.scale, progress) : this.has.scaleX ? (0, import_utils.lerp)(this.$options.from.scaleX, this.$options.to.scaleX, progress) : void 0,
87
- scaleY: this.has.scale ? (0, import_utils.lerp)(this.$options.from.scale, this.$options.to.scale, progress) : this.has.scaleY ? (0, import_utils.lerp)(this.$options.from.scaleY, this.$options.to.scaleY, progress) : void 0,
88
- skewX: this.has.skewX ? (0, import_utils.lerp)(this.$options.from.skewX, this.$options.to.skewX, progress) : void 0,
89
- skewY: this.has.skewY ? (0, import_utils.lerp)(this.$options.from.skewY, this.$options.to.skewY, progress) : void 0
90
- });
91
- if (this.has.rotate) {
92
- transform += ` rotate(${(0, import_utils.lerp)(this.$options.from.rotate, this.$options.to.rotate, progress)}deg)`;
93
- }
94
- transform += `translateZ(${this.has.z ? (0, import_utils.lerp)(this.$options.from.z, this.$options.to.z, progress) : 0})`;
95
- this.target.style.transform = transform;
96
- }
50
+ this.animation.progress(progress);
97
51
  }
98
52
  };
99
53
  __publicField(AbstractScrollAnimation, "config", {
@@ -113,13 +67,18 @@ __publicField(AbstractScrollAnimation, "config", {
113
67
  },
114
68
  from: {
115
69
  type: Object,
116
- default: getDefaults,
117
- merge: true
70
+ default: () => ({})
118
71
  },
119
72
  to: {
120
73
  type: Object,
121
- default: getDefaults,
122
- merge: true
74
+ default: () => ({})
75
+ },
76
+ keyframes: {
77
+ type: Array
78
+ },
79
+ easing: {
80
+ type: Array,
81
+ default: () => [0, 0, 1, 1]
123
82
  }
124
83
  }
125
84
  });
@@ -1,11 +1,16 @@
1
+ /**
2
+ * @typedef {typeof AbstractScrollAnimation} AbstractScrollAnimationConstructor
3
+ * @typedef {import('@studiometa/js-toolkit/utils/css/animate.js').Keyframe} Keyframe
4
+ */
1
5
  /**
2
6
  * @typedef {AbstractScrollAnimation & {
3
7
  * $options: {
4
8
  * playRange: string,
5
9
  * dampFactor: number,
6
10
  * dampPrecision: number,
7
- * from: AnimationOptions,
8
- * to: AnimationOptions,
11
+ * from: Keyframe,
12
+ * to: Keyframe,
13
+ * keyframes: Keyframe[],
9
14
  * },
10
15
  * }} ScrollAnimationChildInterface
11
16
  */
@@ -43,13 +48,18 @@ export default class AbstractScrollAnimation extends Base {
43
48
  };
44
49
  from: {
45
50
  type: ObjectConstructor;
46
- default: typeof getDefaults;
47
- merge: boolean;
51
+ default: () => {};
48
52
  };
49
53
  to: {
50
54
  type: ObjectConstructor;
51
- default: typeof getDefaults;
52
- merge: boolean;
55
+ default: () => {};
56
+ };
57
+ keyframes: {
58
+ type: ArrayConstructor;
59
+ };
60
+ easing: {
61
+ type: ArrayConstructor;
62
+ default: () => number[];
53
63
  };
54
64
  };
55
65
  };
@@ -60,21 +70,14 @@ export default class AbstractScrollAnimation extends Base {
60
70
  */
61
71
  get target(): HTMLElement;
62
72
  /**
63
- * Flags for style detection.
73
+ * @type {ReturnType<animate>}
64
74
  */
65
- get has(): {
66
- x: boolean;
67
- y: boolean;
68
- z: boolean;
69
- scale: boolean;
70
- scaleX: boolean;
71
- scaleY: boolean;
72
- rotate: boolean;
73
- skewX: boolean;
74
- skewY: boolean;
75
- opacity: boolean;
76
- transform: boolean;
77
- };
75
+ animation: ReturnType<typeof animate>;
76
+ /**
77
+ * @this {ScrollAnimationChildInterface}
78
+ * @returns {void}
79
+ */
80
+ mounted(this: ScrollAnimationChildInterface): void;
78
81
  /**
79
82
  * @todo do not add unnecessary styles
80
83
  */
@@ -88,46 +91,16 @@ export default class AbstractScrollAnimation extends Base {
88
91
  render(progress: number): void;
89
92
  }
90
93
  export type AbstractScrollAnimationConstructor = typeof AbstractScrollAnimation;
91
- export type AnimationOptions = {
92
- x?: number;
93
- y?: number;
94
- z?: number;
95
- scale?: number;
96
- scaleX?: number;
97
- scaleY?: number;
98
- rotate?: number;
99
- skewX?: number;
100
- skewY?: number;
101
- opacity?: number;
102
- };
94
+ export type Keyframe = import('@studiometa/js-toolkit/utils/css/animate.js').Keyframe;
103
95
  export type ScrollAnimationChildInterface = AbstractScrollAnimation & {
104
96
  $options: {
105
97
  playRange: string;
106
98
  dampFactor: number;
107
99
  dampPrecision: number;
108
- from: AnimationOptions;
109
- to: AnimationOptions;
100
+ from: Keyframe;
101
+ to: Keyframe;
102
+ keyframes: Keyframe[];
110
103
  };
111
104
  };
112
105
  import { Base } from "@studiometa/js-toolkit";
113
- /**
114
- * @typedef {typeof AbstractScrollAnimation} AbstractScrollAnimationConstructor
115
- * @typedef {{
116
- * x?: number;
117
- * y?: number;
118
- * z?: number;
119
- * scale?: number;
120
- * scaleX?: number;
121
- * scaleY?: number;
122
- * rotate?: number;
123
- * skewX?: number;
124
- * skewY?: number;
125
- * opacity?: number;
126
- * }} AnimationOptions
127
- */
128
- /**
129
- * Get animation configuration defaults.
130
- * @returns {AnimationOptions}
131
- */
132
- declare function getDefaults(): AnimationOptions;
133
- export {};
106
+ import { animate } from "@studiometa/js-toolkit/utils/css/animate.js";
@@ -1 +1 @@
1
- import{Base as a,withFreezedOptions as n}from"@studiometa/js-toolkit";import{matrix as h,lerp as e,map as o,clamp as r}from"@studiometa/js-toolkit/utils";function i(){return{x:0,y:0,z:0,scale:1,scaleX:1,scaleY:1,rotate:0,skewX:0,skewY:0,opacity:1}}class l extends n(a){static config={name:"AbstractScrollAnimation",options:{playRange:{type:Array,default:()=>[0,1]},dampFactor:{type:Number,default:.5},dampPrecision:{type:Number,default:.001},from:{type:Object,default:i,merge:!0},to:{type:Object,default:i,merge:!0}}};get target(){return this.$el}get has(){const t={x:!1,y:!1,z:!1,scale:!1,scaleX:!1,scaleY:!1,rotate:!1,skewX:!1,skewY:!1,opacity:!1,transform:!1};return Object.keys(this.$options.from).forEach(s=>{t[s]=this.$options.from[s]!==this.$options.to[s]}),t.transform=Object.keys(t).filter(s=>s!=="opacity"&&s!=="transform").some(s=>t[s]),Object.defineProperty(this,"has",{value:t}),t}scrolledInView(t){if(!this.has.opacity&&!this.has.transform)return;const s=o(r(t.dampedProgress.y,this.$options.playRange[0],this.$options.playRange[1]),this.$options.playRange[0],this.$options.playRange[1],0,1);this.render(s)}render(t){if(this.has.opacity&&(this.target.style.opacity=String(o(t,0,1,this.$options.from.opacity,this.$options.to.opacity))),this.has.transform){let s=h({translateX:this.has.x?e(this.$options.from.x,this.$options.to.x,t):void 0,translateY:this.has.y?e(this.$options.from.y,this.$options.to.y,t):void 0,scaleX:this.has.scale?e(this.$options.from.scale,this.$options.to.scale,t):this.has.scaleX?e(this.$options.from.scaleX,this.$options.to.scaleX,t):void 0,scaleY:this.has.scale?e(this.$options.from.scale,this.$options.to.scale,t):this.has.scaleY?e(this.$options.from.scaleY,this.$options.to.scaleY,t):void 0,skewX:this.has.skewX?e(this.$options.from.skewX,this.$options.to.skewX,t):void 0,skewY:this.has.skewY?e(this.$options.from.skewY,this.$options.to.skewY,t):void 0});this.has.rotate&&(s+=` rotate(${e(this.$options.from.rotate,this.$options.to.rotate,t)}deg)`),s+=`translateZ(${this.has.z?e(this.$options.from.z,this.$options.to.z,t):0})`,this.target.style.transform=s}}}export{l as default};
1
+ import{Base as i,withFreezedOptions as o}from"@studiometa/js-toolkit";import{map as s,clamp as n,animate as r}from"@studiometa/js-toolkit/utils";class p extends o(i){static config={name:"AbstractScrollAnimation",options:{playRange:{type:Array,default:()=>[0,1]},dampFactor:{type:Number,default:.5},dampPrecision:{type:Number,default:.001},from:{type:Object,default:()=>({})},to:{type:Object,default:()=>({})},keyframes:{type:Array},easing:{type:Array,default:()=>[0,0,1,1]}}};get target(){return this.$el}animation;mounted(){let{keyframes:t}=this.$options;const{from:e,to:a}=this.$options;t.length<=0&&e&&a&&(t=[e,a]),this.animation=r(this.target,t,{easing:this.$options.easing})}scrolledInView(t){const e=s(n(t.dampedProgress.y,this.$options.playRange[0],this.$options.playRange[1]),this.$options.playRange[0],this.$options.playRange[1],0,1);this.render(e)}render(t){this.animation.progress(t)}}export{p as default};
@@ -26,13 +26,18 @@ export default class ScrollAnimation extends AbstractScrollAnimation {
26
26
  };
27
27
  from: {
28
28
  type: ObjectConstructor;
29
- default: () => import("./AbstractScrollAnimation.js").AnimationOptions;
30
- merge: boolean;
29
+ default: () => {};
31
30
  };
32
31
  to: {
33
32
  type: ObjectConstructor;
34
- default: () => import("./AbstractScrollAnimation.js").AnimationOptions;
35
- merge: boolean;
33
+ default: () => {};
34
+ };
35
+ keyframes: {
36
+ type: ArrayConstructor;
37
+ };
38
+ easing: {
39
+ type: ArrayConstructor;
40
+ default: () => number[];
36
41
  };
37
42
  };
38
43
  };
@@ -23,29 +23,8 @@ __export(animationScrollWithEase_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(animationScrollWithEase_exports);
25
25
  var import_utils = require("@studiometa/js-toolkit/utils");
26
- var eases = {
27
- outQuad: import_utils.easeOutQuad,
28
- inQuad: import_utils.easeInQuad,
29
- inOutQuad: import_utils.easeInOutQuad,
30
- outCubic: import_utils.easeOutCubic,
31
- inCubic: import_utils.easeInCubic,
32
- inOutCubic: import_utils.easeInOutCubic,
33
- outQuart: import_utils.easeOutQuart,
34
- inQuart: import_utils.easeInQuart,
35
- inOutQuart: import_utils.easeInOutQuart,
36
- outQuint: import_utils.easeOutQuint,
37
- inQuint: import_utils.easeInQuint,
38
- inOutQuint: import_utils.easeInOutQuint,
39
- outSine: import_utils.easeOutSine,
40
- inSine: import_utils.easeInSine,
41
- inOutSine: import_utils.easeInOutSine,
42
- outCirc: import_utils.easeOutCirc,
43
- inCirc: import_utils.easeInCirc,
44
- inOutCirc: import_utils.easeInOutCirc,
45
- outExpo: import_utils.easeOutExpo,
46
- inExpo: import_utils.easeInExpo,
47
- inOutExpo: import_utils.easeInOutExpo
48
- };
26
+ var regex = /ease([A-Z])/;
27
+ var eases = Object.fromEntries(Object.entries(import_utils.ease).filter(([name]) => name.startsWith("ease")).map(([name, value]) => [name.replace(regex, (match, $1) => $1.toLowerCase()), value]));
49
28
  function animationScrollWithEase(ScrollAnimation) {
50
29
  return class extends ScrollAnimation {
51
30
  static config = {
@@ -60,7 +39,7 @@ function animationScrollWithEase(ScrollAnimation) {
60
39
  }
61
40
  };
62
41
  render(progress) {
63
- if (eases[this.$options.ease]) {
42
+ if (typeof eases[this.$options.ease] === "function") {
64
43
  progress = eases[this.$options.ease](progress);
65
44
  }
66
45
  super.render(progress);
@@ -1 +1 @@
1
- import{easeOutQuad as n,easeInQuad as i,easeInOutQuad as a,easeOutCubic as s,easeInCubic as o,easeInOutCubic as O,easeOutQuart as c,easeInQuart as Q,easeInOutQuart as r,easeOutQuint as I,easeInQuint as p,easeInOutQuint as C,easeOutSine as d,easeInSine as f,easeInOutSine as x,easeOutCirc as E,easeInCirc as b,easeInOutCirc as S,easeOutExpo as h,easeInExpo as g,easeInOutExpo as $}from"@studiometa/js-toolkit/utils";const u={outQuad:n,inQuad:i,inOutQuad:a,outCubic:s,inCubic:o,inOutCubic:O,outQuart:c,inQuart:Q,inOutQuart:r,outQuint:I,inQuint:p,inOutQuint:C,outSine:d,inSine:f,inOutSine:x,outCirc:E,inCirc:b,inOutCirc:S,outExpo:h,inExpo:g,inOutExpo:$};function m(e){return class extends e{static config={...e.config,name:`${e.config.name}WithEase`,options:{...e.config.options,ease:{type:String,default:"outExpo"}}};render(t){u[this.$options.ease]&&(t=u[this.$options.ease](t)),super.render(t)}}}export{m as default};
1
+ import{ease as n}from"@studiometa/js-toolkit/utils";const o=/ease([A-Z])/,s=Object.fromEntries(Object.entries(n).filter(([e])=>e.startsWith("ease")).map(([e,t])=>[e.replace(o,(f,a)=>a.toLowerCase()),t]));function i(e){return class extends e{static config={...e.config,name:`${e.config.name}WithEase`,options:{...e.config.options,ease:{type:String,default:"outExpo"}}};render(t){typeof s[this.$options.ease]=="function"&&(t=s[this.$options.ease](t)),super.render(t)}}}export{i as default};
@@ -35,20 +35,11 @@ var import_utils = require("@studiometa/js-toolkit/utils");
35
35
  var import_MenuBtn = __toESM(require("./MenuBtn.cjs"), 1);
36
36
  var import_MenuList = __toESM(require("./MenuList.cjs"), 1);
37
37
  var _Menu = class extends import_js_toolkit.Base {
38
- getDirectChildren(name) {
39
- if (!this.$children[name]) {
40
- return [];
41
- }
42
- if (!this.$children.Menu) {
43
- return this.$children[name];
44
- }
45
- return this.$children[name].filter((child) => this.$children.Menu.every((menu) => menu.$children[name] ? !menu.$children[name].includes(child) : true));
46
- }
47
38
  get menuList() {
48
- return this.getDirectChildren("MenuList")[0];
39
+ return (0, import_js_toolkit.getDirectChildren)(this, "Menu", "MenuList")[0];
49
40
  }
50
41
  get menuBtn() {
51
- return this.getDirectChildren("MenuBtn")[0];
42
+ return (0, import_js_toolkit.getDirectChildren)(this, "Menu", "MenuBtn")[0];
52
43
  }
53
44
  get shouldReactOnClick() {
54
45
  return this.$options.mode === "click";
@@ -80,18 +71,18 @@ var _Menu = class extends import_js_toolkit.Base {
80
71
  }
81
72
  }
82
73
  }
83
- onMenuBtnBtnClick(event, index) {
84
- if (this.$children.MenuBtn[index] === this.menuBtn && this.shouldReactOnClick) {
74
+ onMenuBtnClick(index, event) {
75
+ if ((0, import_js_toolkit.isDirectChild)(this, "Menu", "MenuBtn", this.$children.MenuBtn[index]) && this.shouldReactOnClick) {
85
76
  event.preventDefault();
86
77
  this.toggle();
87
78
  }
88
79
  }
89
- onMenuBtnBtnMouseenter(event, index) {
80
+ onMenuBtnMouseenter(index) {
90
81
  if (this.$children.MenuBtn[index] === this.menuBtn && !this.shouldReactOnClick) {
91
82
  this.open();
92
83
  }
93
84
  }
94
- onMenuBtnBtnMouseleave() {
85
+ onMenuBtnMouseleave() {
95
86
  if (this.shouldReactOnClick) {
96
87
  return;
97
88
  }
@@ -101,7 +92,7 @@ var _Menu = class extends import_js_toolkit.Base {
101
92
  }
102
93
  });
103
94
  }
104
- onMenuListItemsMouseleave() {
95
+ onMenuListMouseleave() {
105
96
  if (this.shouldReactOnClick) {
106
97
  return;
107
98
  }
@@ -4,6 +4,9 @@
4
4
  * Menu: Menu[],
5
5
  * MenuBtn: MenuBtn[],
6
6
  * MenuList: MenuList[],
7
+ * },
8
+ * $options: {
9
+ * mode: 'click'|'hover'
7
10
  * }
8
11
  * }} MenuInterface
9
12
  */
@@ -29,14 +32,6 @@ export default class Menu extends Base {
29
32
  };
30
33
  };
31
34
  };
32
- /**
33
- * Get direct children.
34
- *
35
- * @this {MenuInterface}
36
- * @param {string} name
37
- * @returns {any[]}
38
- */
39
- getDirectChildren(this: MenuInterface, name: string): any[];
40
35
  /**
41
36
  * Get the first `MenuList` instance.
42
37
  *
@@ -79,31 +74,33 @@ export default class Menu extends Base {
79
74
  * Toggle menu items on button click;
80
75
  *
81
76
  * @this {MenuInterface}
77
+ * @param {number} index
82
78
  * @param {MouseEvent} event
83
79
  * @returns {void}
84
80
  */
85
- onMenuBtnBtnClick(this: MenuInterface, event: MouseEvent, index: any): void;
81
+ onMenuBtnClick(this: MenuInterface, index: number, event: MouseEvent): void;
86
82
  /**
87
83
  * Open menu items on button mouse enter.
88
84
  *
89
85
  * @this {MenuInterface}
86
+ * @param {number} index
90
87
  * @returns {void}
91
88
  */
92
- onMenuBtnBtnMouseenter(this: MenuInterface, event: any, index: any): void;
89
+ onMenuBtnMouseenter(this: MenuInterface, index: number): void;
93
90
  /**
94
91
  * Close menu items on button mouse leave.
95
92
  *
96
93
  * @this {MenuInterface}
97
94
  * @returns {void}
98
95
  */
99
- onMenuBtnBtnMouseleave(this: MenuInterface): void;
96
+ onMenuBtnMouseleave(this: MenuInterface): void;
100
97
  /**
101
98
  * Close menu items on button mouse leave.
102
99
  *
103
100
  * @this {MenuInterface}
104
101
  * @returns {void}
105
102
  */
106
- onMenuListItemsMouseleave(this: MenuInterface): void;
103
+ onMenuListMouseleave(this: MenuInterface): void;
107
104
  /**
108
105
  * Close other non-parent menu items on menu items open.
109
106
  *
@@ -134,6 +131,9 @@ export type MenuInterface = Menu & {
134
131
  MenuBtn: MenuBtn[];
135
132
  MenuList: MenuList[];
136
133
  };
134
+ $options: {
135
+ mode: 'click' | 'hover';
136
+ };
137
137
  };
138
138
  import { Base } from "@studiometa/js-toolkit";
139
139
  import MenuList from "./MenuList.js";
@@ -1 +1 @@
1
- import{Base as h}from"@studiometa/js-toolkit";import{nextTick as s}from"@studiometa/js-toolkit/utils";import u from"./MenuBtn.js";import o from"./MenuList.js";class n extends h{static config={name:"Menu",debug:!0,components:{MenuBtn:u,MenuList:o,Menu:n},options:{mode:{type:String,default:"click"}}};getDirectChildren(t){return this.$children[t]?this.$children.Menu?this.$children[t].filter(e=>this.$children.Menu.every(i=>i.$children[t]?!i.$children[t].includes(e):!0)):this.$children[t]:[]}get menuList(){return this.getDirectChildren("MenuList")[0]}get menuBtn(){return this.getDirectChildren("MenuBtn")[0]}get shouldReactOnClick(){return this.$options.mode==="click"}get isHover(){return this.menuBtn.isHover||this.menuList.isHover}mounted(){if(!this.menuBtn||!this.menuList){this.$destroy();return}this.menuBtn.$el.setAttribute("aria-controls",this.$id),this.menuList.$el.setAttribute("id",this.$id),this.menuList.close()}keyed({ENTER:t,ESC:e,isUp:i}){if(!!i){if(e){this.close();return}if(!this.shouldReactOnClick){const r=document.activeElement===this.menuBtn.$el;t&&r&&this.toggle()}}}onMenuBtnBtnClick(t,e){this.$children.MenuBtn[e]===this.menuBtn&&this.shouldReactOnClick&&(t.preventDefault(),this.toggle())}onMenuBtnBtnMouseenter(t,e){this.$children.MenuBtn[e]===this.menuBtn&&!this.shouldReactOnClick&&this.open()}onMenuBtnBtnMouseleave(){this.shouldReactOnClick||s(()=>{this.isHover||this.close()})}onMenuListItemsMouseleave(){this.shouldReactOnClick||s(()=>{this.isHover||this.close()})}onMenuListItemsOpen(t){const e=this.$children.MenuList[t];this.$children.MenuList.forEach(i=>{i.$el.contains(e.$el)||i.close()})}close(){this.menuList.close()}open(){this.menuList.open()}toggle(){this.menuList.toggle()}}export{n as default};
1
+ import{Base as h,isDirectChild as r,getDirectChildren as s}from"@studiometa/js-toolkit";import{nextTick as o}from"@studiometa/js-toolkit/utils";import l from"./MenuBtn.js";import c from"./MenuList.js";class n extends h{static config={name:"Menu",debug:!0,components:{MenuBtn:l,MenuList:c,Menu:n},options:{mode:{type:String,default:"click"}}};get menuList(){return s(this,"Menu","MenuList")[0]}get menuBtn(){return s(this,"Menu","MenuBtn")[0]}get shouldReactOnClick(){return this.$options.mode==="click"}get isHover(){return this.menuBtn.isHover||this.menuList.isHover}mounted(){if(!this.menuBtn||!this.menuList){this.$destroy();return}this.menuBtn.$el.setAttribute("aria-controls",this.$id),this.menuList.$el.setAttribute("id",this.$id),this.menuList.close()}keyed({ENTER:t,ESC:e,isUp:i}){if(!!i){if(e){this.close();return}if(!this.shouldReactOnClick){const u=document.activeElement===this.menuBtn.$el;t&&u&&this.toggle()}}}onMenuBtnClick(t,e){r(this,"Menu","MenuBtn",this.$children.MenuBtn[t])&&this.shouldReactOnClick&&(e.preventDefault(),this.toggle())}onMenuBtnMouseenter(t){this.$children.MenuBtn[t]===this.menuBtn&&!this.shouldReactOnClick&&this.open()}onMenuBtnMouseleave(){this.shouldReactOnClick||o(()=>{this.isHover||this.close()})}onMenuListMouseleave(){this.shouldReactOnClick||o(()=>{this.isHover||this.close()})}onMenuListItemsOpen(t){const e=this.$children.MenuList[t];this.$children.MenuList.forEach(i=>{i.$el.contains(e.$el)||i.close()})}close(){this.menuList.close()}open(){this.menuList.open()}toggle(){this.menuList.toggle()}}export{n as default};
@@ -32,22 +32,18 @@ var MenuBtn = class extends import_js_toolkit.Base {
32
32
  isHover = false;
33
33
  onClick(event) {
34
34
  event.stopPropagation();
35
- this.$emit("btn-click", event);
36
35
  }
37
36
  onMouseenter(event) {
38
37
  this.isHover = true;
39
38
  event.stopPropagation();
40
- this.$emit("btn-mouseenter", event);
41
39
  }
42
40
  onMouseleave(event) {
43
41
  this.isHover = false;
44
42
  event.stopPropagation();
45
- this.$emit("btn-mouseleave", event);
46
43
  }
47
44
  };
48
45
  __publicField(MenuBtn, "config", {
49
46
  name: "MenuBtn",
50
- debug: true,
51
- emits: ["btn-click", "btn-mouseenter", "btn-mouseleave"]
47
+ debug: true
52
48
  });
53
49
  if (module.exports.default) module.exports = module.exports.default;
@@ -8,7 +8,6 @@ export default class MenuBtn extends Base {
8
8
  static config: {
9
9
  name: string;
10
10
  debug: boolean;
11
- emits: string[];
12
11
  };
13
12
  /**
14
13
  * Wether the button is hovered or not.
@@ -1 +1 @@
1
- import{Base as t}from"@studiometa/js-toolkit";class o extends t{static config={name:"MenuBtn",debug:!0,emits:["btn-click","btn-mouseenter","btn-mouseleave"]};isHover=!1;onClick(e){e.stopPropagation(),this.$emit("btn-click",e)}onMouseenter(e){this.isHover=!0,e.stopPropagation(),this.$emit("btn-mouseenter",e)}onMouseleave(e){this.isHover=!1,e.stopPropagation(),this.$emit("btn-mouseleave",e)}}export{o as default};
1
+ import{Base as o}from"@studiometa/js-toolkit";class t extends o{static config={name:"MenuBtn",debug:!0};isHover=!1;onClick(e){e.stopPropagation()}onMouseenter(e){this.isHover=!0,e.stopPropagation()}onMouseleave(e){this.isHover=!1,e.stopPropagation()}}export{t as default};
@@ -59,9 +59,8 @@ var _MenuList = class extends import_Transition.default {
59
59
  onMouseenter() {
60
60
  this.isHover = true;
61
61
  }
62
- onMouseleave(event) {
62
+ onMouseleave() {
63
63
  this.isHover = false;
64
- this.$emit("items-mouseleave", event);
65
64
  }
66
65
  open() {
67
66
  if (this.isOpen) {