@studiometa/ui 0.2.7 → 0.2.8
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/atoms/LargeText/LargeText.cjs +3 -3
- package/atoms/LargeText/LargeText.d.ts +1 -2
- package/atoms/LargeText/LargeText.js +1 -1
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +18 -59
- package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +28 -55
- package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -1
- package/atoms/ScrollAnimation/ScrollAnimation.d.ts +9 -4
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs +3 -24
- package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -1
- package/molecules/Slider/AbstractSliderChild.cjs +8 -1
- package/molecules/Slider/AbstractSliderChild.d.ts +2 -2
- package/molecules/Slider/AbstractSliderChild.js +1 -1
- package/molecules/Slider/SliderBtn.d.ts +8 -0
- package/molecules/Slider/SliderCount.d.ts +8 -0
- package/molecules/Slider/SliderDots.d.ts +8 -0
- package/molecules/Slider/SliderDrag.cjs +5 -1
- package/molecules/Slider/SliderDrag.d.ts +7 -0
- package/molecules/Slider/SliderDrag.js +1 -1
- package/molecules/Slider/SliderItem.cjs +3 -3
- package/molecules/Slider/SliderItem.d.ts +5 -1
- package/molecules/Slider/SliderItem.js +1 -1
- package/molecules/Slider/SliderProgress.cjs +7 -3
- package/molecules/Slider/SliderProgress.d.ts +8 -0
- package/molecules/Slider/SliderProgress.js +1 -1
- package/organisms/Frame/Frame.cjs +4 -2
- package/organisms/Frame/Frame.js +1 -1
- package/package.json +2 -2
|
@@ -59,9 +59,9 @@ var LargeText = class extends (0, import_js_toolkit.withMountWhenInView)(import_
|
|
|
59
59
|
this.translateX = 0;
|
|
60
60
|
this.transform.translateX -= this.width;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
62
|
+
return () => {
|
|
63
|
+
(0, import_utils.transform)(this.$refs.target, this.transform);
|
|
64
|
+
};
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
__publicField(LargeText, "config", {
|
|
@@ -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,
|
|
1
|
+
import{Base as i,withMountWhenInView as e}from"@studiometa/js-toolkit";import{damp as t,clamp as a,transform as r}from"@studiometa/js-toolkit/utils";class n 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(){return 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(a(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),()=>{r(this.$refs.target,this.transform)}}}export{n as default};
|
|
@@ -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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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:
|
|
117
|
-
merge: true
|
|
70
|
+
default: () => ({})
|
|
118
71
|
},
|
|
119
72
|
to: {
|
|
120
73
|
type: Object,
|
|
121
|
-
default:
|
|
122
|
-
|
|
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:
|
|
8
|
-
* to:
|
|
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:
|
|
47
|
-
merge: boolean;
|
|
51
|
+
default: () => {};
|
|
48
52
|
};
|
|
49
53
|
to: {
|
|
50
54
|
type: ObjectConstructor;
|
|
51
|
-
default:
|
|
52
|
-
|
|
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
|
-
*
|
|
73
|
+
* @type {ReturnType<animate>}
|
|
64
74
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
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:
|
|
109
|
-
to:
|
|
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
|
|
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: () =>
|
|
30
|
-
merge: boolean;
|
|
29
|
+
default: () => {};
|
|
31
30
|
};
|
|
32
31
|
to: {
|
|
33
32
|
type: ObjectConstructor;
|
|
34
|
-
default: () =>
|
|
35
|
-
|
|
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
|
|
27
|
-
|
|
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{
|
|
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};
|
|
@@ -51,7 +51,14 @@ var AbstractSliderChild = class extends import_js_toolkit.Base {
|
|
|
51
51
|
}
|
|
52
52
|
handleEvent(event) {
|
|
53
53
|
if (event.type === "index") {
|
|
54
|
-
|
|
54
|
+
import_utils.domScheduler.read(() => {
|
|
55
|
+
const callback = this.update(event.detail[0]);
|
|
56
|
+
if ((0, import_utils.isFunction)(callback)) {
|
|
57
|
+
import_utils.domScheduler.write(() => {
|
|
58
|
+
callback();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
update(index) {
|
|
@@ -45,9 +45,9 @@ export default class AbstractSliderChild extends Base {
|
|
|
45
45
|
*
|
|
46
46
|
* @this {AbstractSliderChildInterface}
|
|
47
47
|
* @param {number} index The new active index.
|
|
48
|
-
* @returns {void}
|
|
48
|
+
* @returns {void|(()=>void)}
|
|
49
49
|
*/
|
|
50
|
-
update(this: AbstractSliderChildInterface, index: number): void;
|
|
50
|
+
update(this: AbstractSliderChildInterface, index: number): void | (() => void);
|
|
51
51
|
}
|
|
52
52
|
export type AbstractSliderChildInterface = AbstractSliderChild & {
|
|
53
53
|
$parent: Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as r}from"@studiometa/js-toolkit";import{nextFrame as d,domScheduler as i,isFunction as n}from"@studiometa/js-toolkit/utils";import o from"./Slider.js";class a extends r{static config={name:"AbstractSliderChild"};$parent;mounted(){if(!(this.$parent instanceof o))throw new Error(`The \`${this.$options.name}\` component must be a direct child of a \`Slider\` component.`);this.$parent.$on("index",this)}resized(){d(()=>{this.update(this.$parent.currentIndex)})}destroyed(){this.$parent.$off("index",this)}handleEvent(e){e.type==="index"&&i.read(()=>{const t=this.update(e.detail[0]);n(t)&&i.write(()=>{t()})})}update(e){throw new Error(`The \`AbstractSliderChild.update(${e})\` method must be implemented.`)}}export{a as default};
|
|
@@ -17,6 +17,14 @@ export default class SliderBtn extends AbstractSliderChild {
|
|
|
17
17
|
next: BooleanConstructor;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Update attributes.
|
|
22
|
+
*
|
|
23
|
+
* @this {SliderBtnInterface}
|
|
24
|
+
* @param {number} index
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
update(this: SliderBtnInterface, index: number): void;
|
|
20
28
|
/**
|
|
21
29
|
* Go prev or next on click.
|
|
22
30
|
*
|
|
@@ -12,6 +12,14 @@ export default class SliderCount extends AbstractSliderChild {
|
|
|
12
12
|
name: string;
|
|
13
13
|
refs: string[];
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Update the current counter indicator.
|
|
17
|
+
*
|
|
18
|
+
* @this {SliderCountInterface}
|
|
19
|
+
* @param {number} index The new active index.
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
update(this: SliderCountInterface, index: number): void;
|
|
15
23
|
}
|
|
16
24
|
export type SliderCountInterface = SliderCount & {
|
|
17
25
|
$refs: {
|
|
@@ -16,6 +16,14 @@ export default class SliderDots extends AbstractSliderChild {
|
|
|
16
16
|
name: string;
|
|
17
17
|
refs: string[];
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Update dots classes according to the new index.
|
|
21
|
+
*
|
|
22
|
+
* @this {SliderDotsInterface}
|
|
23
|
+
* @param {number} index
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
update(this: SliderDotsInterface, index: number): void;
|
|
19
27
|
/**
|
|
20
28
|
* Go to the given index on dot click.
|
|
21
29
|
*
|
|
@@ -35,6 +35,10 @@ var SliderDrag = class extends (0, import_js_toolkit.withDrag)(import_js_toolkit
|
|
|
35
35
|
};
|
|
36
36
|
__publicField(SliderDrag, "config", {
|
|
37
37
|
name: "SliderDrag",
|
|
38
|
-
emits: ["start", "drag", "drop", "inertia", "stop"]
|
|
38
|
+
emits: ["start", "drag", "drop", "inertia", "stop"],
|
|
39
|
+
sensitivity: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 1
|
|
42
|
+
}
|
|
39
43
|
});
|
|
40
44
|
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
* SliderDrag class.
|
|
3
3
|
*/
|
|
4
4
|
export default class SliderDrag extends Base {
|
|
5
|
+
/**
|
|
6
|
+
* Config.
|
|
7
|
+
*/
|
|
5
8
|
static config: {
|
|
6
9
|
name: string;
|
|
7
10
|
emits: string[];
|
|
11
|
+
sensitivity: {
|
|
12
|
+
type: NumberConstructor;
|
|
13
|
+
default: number;
|
|
14
|
+
};
|
|
8
15
|
};
|
|
9
16
|
/**
|
|
10
17
|
* Emit drag events.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as e,withDrag as
|
|
1
|
+
import{Base as e,withDrag as i}from"@studiometa/js-toolkit";class a extends i(e){static config={name:"SliderDrag",emits:["start","drag","drop","inertia","stop"],sensitivity:{type:Number,default:1}};dragged(t){this.$emit(t.mode,t)}}export{a as default};
|
|
@@ -80,9 +80,9 @@ var SliderItem = class extends (0, import_js_toolkit.withIntersectionObserver)(i
|
|
|
80
80
|
this.render();
|
|
81
81
|
}
|
|
82
82
|
render() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
83
|
+
import_utils.domScheduler.write(() => {
|
|
84
|
+
(0, import_utils.transform)(this.$el, { x: this.dampedX });
|
|
85
|
+
});
|
|
86
86
|
}
|
|
87
87
|
willBeVisible(targetPosition) {
|
|
88
88
|
return this.rect.x + targetPosition < window.innerWidth * 1.5 && this.rect.x + targetPosition + this.rect.width > window.innerWidth * -0.5;
|
|
@@ -52,6 +52,9 @@ export default class SliderItem extends Base {
|
|
|
52
52
|
/**
|
|
53
53
|
* Ticked hook.
|
|
54
54
|
*
|
|
55
|
+
* @todo create AbstractSliderItem with `render` method
|
|
56
|
+
* @todo add state to SliderItem
|
|
57
|
+
* @todo add origin to SliderItem
|
|
55
58
|
* @returns {void}
|
|
56
59
|
*/
|
|
57
60
|
ticked(): void;
|
|
@@ -82,7 +85,8 @@ export default class SliderItem extends Base {
|
|
|
82
85
|
*/
|
|
83
86
|
moveInstantly(targetPosition: number): void;
|
|
84
87
|
/**
|
|
85
|
-
* Render the
|
|
88
|
+
* Render the component.
|
|
89
|
+
*
|
|
86
90
|
* @returns {void}
|
|
87
91
|
*/
|
|
88
92
|
render(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as t,withIntersectionObserver as s}from"@studiometa/js-toolkit";import{damp as d,domScheduler as h,transform as r}from"@studiometa/js-toolkit/utils";class l extends s(t,{threshold:[0,1]}){static config={name:"SliderItem",emits:["is-fully-visible","is-partially-visible","is-hidden"]};isVisible=!1;x=0;dampedX=0;mounted(){this.updateRectAdjustedWithX()}resized(){this.updateRectAdjustedWithX()}destroyed(){this.moveInstantly(0)}intersected([{intersectionRatio:e,isIntersecting:i}]){e>=1?(this.$emit("is-fully-visible"),this.$el.setAttribute("aria-hidden","false")):e>0?(this.$emit("is-partially-visible"),this.$el.setAttribute("aria-hidden","true")):(this.$emit("is-hidden"),this.$el.setAttribute("aria-hidden","true")),this.isVisible=i}ticked(){this.dampedX=d(this.x,this.dampedX,.2,1e-5),this.render(),this.dampedX===this.x&&this.$services.disable("ticked")}activate(){this.$el.classList.add("is-active")}disactivate(){this.$el.classList.remove("is-active")}move(e){this.x=e,this.$services.has("ticked")||this.$services.enable("ticked")}moveInstantly(e){this.x=e,this.dampedX=e,this.render()}render(){h.write(()=>{r(this.$el,{x:this.dampedX})})}willBeVisible(e){return this.rect.x+e<window.innerWidth*1.5&&this.rect.x+e+this.rect.width>window.innerWidth*-.5}willBeFullyVisible(e){return this.rect.x+e<window.innerWidth&&this.rect.x+e>0&&this.rect.x+e+this.rect.width<window.innerWidth&&this.rect.x+e+this.rect.width>0}updateRectAdjustedWithX(){const e=this.x*-1,i=this.$el.getBoundingClientRect().toJSON();this.rect={...i,left:i.left+e,right:i.left+e+i.width,x:i.left+e}}}export{l as default};
|
|
@@ -34,9 +34,13 @@ var import_utils = require("@studiometa/js-toolkit/utils");
|
|
|
34
34
|
var import_AbstractSliderChild = __toESM(require("./AbstractSliderChild.cjs"), 1);
|
|
35
35
|
var SliderProgress = class extends import_AbstractSliderChild.default {
|
|
36
36
|
update(index) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
import_utils.domScheduler.read(() => {
|
|
38
|
+
const unit = this.$refs.progress.clientWidth / (this.$parent.indexMax + 1);
|
|
39
|
+
import_utils.domScheduler.write(() => {
|
|
40
|
+
this.$refs.progress.style.transform = (0, import_utils.matrix)({
|
|
41
|
+
translateX: (0, import_utils.map)(index, 0, this.$parent.indexMax, (this.$refs.progress.clientWidth - unit) * -1, 0)
|
|
42
|
+
});
|
|
43
|
+
});
|
|
40
44
|
});
|
|
41
45
|
}
|
|
42
46
|
};
|
|
@@ -17,6 +17,14 @@ export default class SliderProgress extends AbstractSliderChild {
|
|
|
17
17
|
name: string;
|
|
18
18
|
refs: string[];
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Update the progress indicator.
|
|
22
|
+
*
|
|
23
|
+
* @this {SliderProgressInterface}
|
|
24
|
+
* @param {number} index The new active index.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
update(this: SliderProgressInterface, index: number): void;
|
|
20
28
|
}
|
|
21
29
|
export type SliderProgressInterface = SliderProgress & {
|
|
22
30
|
$refs: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matrix as t,map as
|
|
1
|
+
import{matrix as t,map as i,domScheduler as r}from"@studiometa/js-toolkit/utils";import a from"./AbstractSliderChild.js";class o extends a{static config={name:"SliderProgress",refs:["progress"]};update(e){r.read(()=>{const s=this.$refs.progress.clientWidth/(this.$parent.indexMax+1);r.write(()=>{this.$refs.progress.style.transform=t({translateX:i(e,0,this.$parent.indexMax,(this.$refs.progress.clientWidth-s)*-1,0)})})})}}export{o as default};
|
|
@@ -59,7 +59,7 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
59
59
|
return this.getDirectChild("FrameAnchor");
|
|
60
60
|
}
|
|
61
61
|
get directChildFrameForm() {
|
|
62
|
-
return this.getDirectChild("
|
|
62
|
+
return this.getDirectChild("FrameForm");
|
|
63
63
|
}
|
|
64
64
|
get directChildFrameTarget() {
|
|
65
65
|
return this.getDirectChild("FrameTarget");
|
|
@@ -112,7 +112,9 @@ var _Frame = class extends import_js_toolkit.Base {
|
|
|
112
112
|
this.$log("onFrameFormFrameSubmit", event);
|
|
113
113
|
event.preventDefault();
|
|
114
114
|
const form = this.$children.FrameForm[index];
|
|
115
|
-
|
|
115
|
+
const url = new URL(form.action);
|
|
116
|
+
url.search = new URLSearchParams(new FormData(form.$el)).toString();
|
|
117
|
+
this.goTo(url.toString());
|
|
116
118
|
}
|
|
117
119
|
parseHTML(string = "") {
|
|
118
120
|
return new DOMParser().parseFromString(string, "text/html");
|
package/organisms/Frame/Frame.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as d}from"@studiometa/js-toolkit";import{nextFrame as c,historyPush as f}from"@studiometa/js-toolkit/utils";import p from"./FrameAnchor.js";import g from"./FrameForm.js";import F from"./FrameTarget.js";function u(){return{left:window.pageXOffset,top:window.pageYOffset}}const a=new Map;class s extends d{static config={name:"Frame",emits:["before-fetch","after-fetch","before-leave","after-leave","before-content","after-content","before-enter","after-enter"],log:!0,components:{FrameAnchor:p,FrameForm:g,FrameTarget:F,Frame:s},options:{history:Boolean}};get id(){return this.$el.id}getDirectChild(e){return this.$children[e]?this.$children.Frame?this.$children[e].filter(t=>this.$children.Frame.every(r=>r.$children[e]?!r.$children[e].includes(t):!0)):this.$children[e]:[]}get directChildFrameAnchor(){return this.getDirectChild("FrameAnchor")}get directChildFrameForm(){return this.getDirectChild("FrameForm")}get directChildFrameTarget(){return this.getDirectChild("FrameTarget")}mounted(){this.$options.history&&window.addEventListener("popstate",this)}destroyed(){window.removeEventListener("popstate",this)}handleEvent(e){e.type==="popstate"&&this.onWindowPopstate(e),e.type==="beforeunload"&&this.onWindowUnload()}onWindowUnload(){const{history:e}=window;!e.state||e.replaceState({...e.state,scroll:u()},"")}onWindowPopstate(e){this.goTo(window.location.href,e.state)}onFrameAnchorFrameClick(e,t){if(!this.directChildFrameAnchor.includes(this.$children.FrameAnchor[t]))return;this.$log("onAFrameClick",e,t),e.preventDefault();const r=this.$children.FrameAnchor[t];r.href!==window.location.href&&this.goTo(r.href)}onFrameFormFrameSubmit(e,t){if(!this.directChildFrameForm.includes(this.$children.FrameForm[t]))return;this.$log("onFrameFormFrameSubmit",e),e.preventDefault();const r=this.$children.FrameForm[t],i=new URL(r.action);i.search=new URLSearchParams(new FormData(r.$el)).toString(),this.goTo(i.toString())}parseHTML(e=""){return new DOMParser().parseFromString(e,"text/html")}async goTo(e,t=null){this.$log("goTo",e);const r=new URL(e);if(r.origin!==window.location.origin)throw new Error("Cross origin request are not allowed.");this.$emit("before-fetch",e);const i=await this.fetch(e),n=this.parseHTML(i),l=n.querySelector(`#${this.id}`),h=new s(l);h.$children.registerAll(),this.$emit("after-fetch",e,i),this.$emit("before-leave"),await Promise.all(this.directChildFrameTarget.map(o=>o.leave())),this.$emit("after-leave"),this.$emit("before-content"),this.directChildFrameTarget.map((o,m)=>o.updateContent(h.directChildFrameTarget[m])),this.$options.history&&(document.title=n.title,f({path:r.pathname,search:r.searchParams})),t&&(document.scrollingElement.scrollTop=t.top,document.scrollingElement.scrollLeft=t.left),await c(),this.$root.$update(),await c(),this.$emit("after-content"),this.$emit("before-enter"),await Promise.all(this.directChildFrameTarget.map(o=>o.enter())),this.$emit("after-enter")}async fetch(e){const t=a.get(e);if(t)return t.status==="pending"?t.promise:t.content;const r=fetch(e);try{a.set(e,{promise:r,status:"pending",content:void 0});const i=await r.then(n=>n.text());return a.set(e,{promise:r,status:"resolved",content:i}),i}catch(i){return a.set(e,{promise:r,status:"error",content:i}),i}}}export{s as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "A set of opiniated, unstyled and accessible components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/studiometa/ui#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@studiometa/js-toolkit": "^2.
|
|
32
|
+
"@studiometa/js-toolkit": "^2.2.2",
|
|
33
33
|
"deepmerge": "^4.2.2"
|
|
34
34
|
}
|
|
35
35
|
}
|