@studiometa/ui 0.2.5 → 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/Button/Button.twig +68 -0
- package/atoms/Button/StyledButton.twig +47 -0
- package/atoms/Cursor/Cursor.twig +28 -0
- package/atoms/Figure/Figure.twig +120 -0
- package/atoms/Icon/Icon.twig +13 -0
- package/atoms/LargeText/LargeText.cjs +3 -3
- package/atoms/LargeText/LargeText.d.ts +1 -2
- package/atoms/LargeText/LargeText.js +1 -1
- package/atoms/LargeText/LargeText.twig +49 -0
- 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/index.cjs +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/molecules/Accordion/Accordion.twig +54 -0
- package/molecules/Modal/Modal.twig +108 -0
- package/molecules/Modal/StyledModal.twig +39 -0
- package/molecules/Panel/Panel.twig +73 -0
- package/molecules/Panel/StyledPanel.twig +28 -0
- 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/Slider.cjs +12 -4
- package/molecules/Slider/Slider.d.ts +11 -0
- package/molecules/Slider/Slider.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 +7 -6
- package/molecules/Slider/SliderItem.d.ts +9 -0
- 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/molecules/Sticky/Sticky.twig +31 -0
- package/molecules/Tabs/Tabs.twig +20 -0
- package/organisms/Frame/Frame.cjs +44 -3
- package/organisms/Frame/Frame.d.ts +34 -1
- package/organisms/Frame/Frame.js +1 -1
- package/organisms/Frame/FrameTarget.cjs +3 -3
- package/organisms/Frame/FrameTarget.js +1 -1
- package/organisms/ImageGrid/ImageGrid.twig +42 -0
- package/package.json +2 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Button component.
|
|
5
|
+
*
|
|
6
|
+
* @param string $label
|
|
7
|
+
* @param string $tag
|
|
8
|
+
* @param string $href
|
|
9
|
+
* @param array $attr
|
|
10
|
+
* @param string $icon
|
|
11
|
+
* @param array|string $icon_classes
|
|
12
|
+
* @param 'start'|'end' $icon_position
|
|
13
|
+
* @param boolean $icon_only
|
|
14
|
+
*/
|
|
15
|
+
#}
|
|
16
|
+
|
|
17
|
+
{# Customizable tag with a default value. #}
|
|
18
|
+
{% set tag =
|
|
19
|
+
tag|default(href is defined or (attr is defined and attr.href is defined) ? 'a' : 'button')
|
|
20
|
+
%}
|
|
21
|
+
|
|
22
|
+
{# Default icon values #}
|
|
23
|
+
{% set icon_position = icon_position|default('start') %}
|
|
24
|
+
{% set icon_only = icon_only|default(false) %}
|
|
25
|
+
|
|
26
|
+
{# Final attributes are a merge of the defaults, the given and then the required #}
|
|
27
|
+
{% set attributes =
|
|
28
|
+
merge_html_attributes(
|
|
29
|
+
attr ?? null,
|
|
30
|
+
{
|
|
31
|
+
title: label,
|
|
32
|
+
type: tag == 'button' ? 'button' : false,
|
|
33
|
+
href: tag == 'a' and href is defined ? href : false,
|
|
34
|
+
aria_label: icon_only ? label : false
|
|
35
|
+
},
|
|
36
|
+
{ class: ['btn'] }
|
|
37
|
+
)
|
|
38
|
+
%}
|
|
39
|
+
|
|
40
|
+
{% set rendered_icon %}
|
|
41
|
+
{% block icon %}
|
|
42
|
+
{% include '@ui/atoms/Icon/Icon.twig' with {
|
|
43
|
+
name: icon ?? '',
|
|
44
|
+
classes: icon_classes ?? {
|
|
45
|
+
'mr-3': not icon_only and icon_position == 'start',
|
|
46
|
+
'ml-3': not icon_only and icon_position == 'end',
|
|
47
|
+
}
|
|
48
|
+
} %}
|
|
49
|
+
{% endblock %}
|
|
50
|
+
{% endset %}
|
|
51
|
+
|
|
52
|
+
{% html_element tag with attributes %}
|
|
53
|
+
{% block content %}
|
|
54
|
+
{% if icon is defined and icon_position == 'start' %}
|
|
55
|
+
{{ rendered_icon }}
|
|
56
|
+
{% endif %}
|
|
57
|
+
{% block label %}
|
|
58
|
+
{% if icon_only %}
|
|
59
|
+
<span class="sr-only">{{ label }}</span>
|
|
60
|
+
{% else %}
|
|
61
|
+
{{ label }}
|
|
62
|
+
{% endif %}
|
|
63
|
+
{% endblock %}
|
|
64
|
+
{% if icon is defined and icon_position == 'end' %}
|
|
65
|
+
{{ rendered_icon }}
|
|
66
|
+
{% endif %}
|
|
67
|
+
{% endblock %}
|
|
68
|
+
{% end_html_element %}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Styled button.
|
|
5
|
+
*
|
|
6
|
+
* @param 'primary'|'secondary'|'tertiary' $theme
|
|
7
|
+
*/
|
|
8
|
+
#}
|
|
9
|
+
|
|
10
|
+
{% extends '@ui/atoms/Button/Button.twig' %}
|
|
11
|
+
|
|
12
|
+
{% set icon_only = icon_only|default(false) %}
|
|
13
|
+
|
|
14
|
+
{% set theme = theme|default('primary') %}
|
|
15
|
+
|
|
16
|
+
{% set theme_shared = [
|
|
17
|
+
'rounded cursor-pointer transition',
|
|
18
|
+
'disabled:cursor-not-allowed',
|
|
19
|
+
{
|
|
20
|
+
'inline-block': icon is not defined,
|
|
21
|
+
'inline-flex items-center': icon is defined,
|
|
22
|
+
'px-6 py-4': not icon_only,
|
|
23
|
+
'p-4': icon_only
|
|
24
|
+
}
|
|
25
|
+
] %}
|
|
26
|
+
|
|
27
|
+
{% set theme_primary = ['text-white bg-black', 'hover:bg-opacity-75 disabled:bg-opacity-50'] %}
|
|
28
|
+
|
|
29
|
+
{% set theme_secondary = [
|
|
30
|
+
'ring ring-inset ring-2 ring-black ring-opacity-25',
|
|
31
|
+
{
|
|
32
|
+
'hover:ring-opacity-100': (attr is defined and attr.disabled is not defined)
|
|
33
|
+
or attr is not defined
|
|
34
|
+
}
|
|
35
|
+
] %}
|
|
36
|
+
|
|
37
|
+
{% set attr =
|
|
38
|
+
attr
|
|
39
|
+
|default({})
|
|
40
|
+
|merge({
|
|
41
|
+
class: [
|
|
42
|
+
theme_shared,
|
|
43
|
+
theme == 'primary' ? theme_primary : '',
|
|
44
|
+
theme == 'secondary' ? theme_secondary : ''
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
%}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Cursor component.
|
|
5
|
+
*
|
|
6
|
+
* @param array $attr
|
|
7
|
+
* Custom attributes for the root element.
|
|
8
|
+
*
|
|
9
|
+
* @block $content
|
|
10
|
+
* Custom content for the root element, defaults to `''`.
|
|
11
|
+
*/
|
|
12
|
+
#}
|
|
13
|
+
|
|
14
|
+
{% set attributes =
|
|
15
|
+
merge_html_attributes(
|
|
16
|
+
attr ?? null,
|
|
17
|
+
{
|
|
18
|
+
data_component: 'Cursor',
|
|
19
|
+
class: 'fixed top-0 left-0 w-12 h-12 -mt-6 -ml-6 rounded-full bg-black'
|
|
20
|
+
},
|
|
21
|
+
{ class: 'pointer-events-none' }
|
|
22
|
+
)
|
|
23
|
+
%}
|
|
24
|
+
|
|
25
|
+
<div {{ html_attributes(attributes) }}>
|
|
26
|
+
{% block content %}
|
|
27
|
+
{% endblock %}
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Figure component.
|
|
5
|
+
*
|
|
6
|
+
* @param string $src
|
|
7
|
+
* @param string $srcset
|
|
8
|
+
* @param string $sizes
|
|
9
|
+
* @param number $width
|
|
10
|
+
* @param number $height
|
|
11
|
+
* @param string $alt
|
|
12
|
+
* @param string $caption
|
|
13
|
+
* @param boolean $lazy
|
|
14
|
+
* @param 'cover'|'contain'|'fill'|'none' $fit
|
|
15
|
+
* Define how the image will fit.
|
|
16
|
+
* @param boolean $absolute
|
|
17
|
+
* Use absolute position on the image holder instead of relative.
|
|
18
|
+
* @param boolean $inline
|
|
19
|
+
* Wether to enable the display of the figure inline or not. When `inline`, the root element
|
|
20
|
+
* will have a max-width set corresponding to the `width` given. Use with caution.
|
|
21
|
+
* @param array $attr
|
|
22
|
+
* Custom attributes for the root element.
|
|
23
|
+
* @param array $inner_attr
|
|
24
|
+
* Custom attributes for the inner element.
|
|
25
|
+
* @param array $img_attr
|
|
26
|
+
* Custom attributes for the image element.
|
|
27
|
+
* @param array $caption_attr
|
|
28
|
+
* Custom attributes for the caption element.
|
|
29
|
+
*
|
|
30
|
+
* @block $caption
|
|
31
|
+
* Use this block to customize the image's caption.
|
|
32
|
+
*
|
|
33
|
+
* @todo
|
|
34
|
+
* - twicpics: use TwicPics to serve image at the right size
|
|
35
|
+
* - loading: display a loader while loading, the fallback image if there was an error
|
|
36
|
+
* - mode: img | background → is it really necessary with `object-fit-...`?
|
|
37
|
+
*/
|
|
38
|
+
#}
|
|
39
|
+
|
|
40
|
+
{% set absolute = absolute|default(false) %}
|
|
41
|
+
{% set inline = inline|default(false) %}
|
|
42
|
+
{% set fit = fit ?? null %}
|
|
43
|
+
{% set height = height|default(100) %}
|
|
44
|
+
{% set width = width|default(100) %}
|
|
45
|
+
{% set lazy = lazy ?? true %}
|
|
46
|
+
|
|
47
|
+
{%- set placeholder_markup -%}
|
|
48
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
|
49
|
+
viewbox="0 0 {{ width }} {{ height }}"
|
|
50
|
+
width="{{ width }}"
|
|
51
|
+
height="{{ height }}">
|
|
52
|
+
<rect x="0" y="0" width="{{ width }}" height="{{ height }}" fill="#eee" />
|
|
53
|
+
</svg>
|
|
54
|
+
{%- endset -%}
|
|
55
|
+
{% set generic_placeholder = 'data:image/svg+xml,%s'|format(placeholder_markup|url_encode) %}
|
|
56
|
+
|
|
57
|
+
{% set attributes =
|
|
58
|
+
merge_html_attributes(
|
|
59
|
+
attr ?? null,
|
|
60
|
+
{ data_component: 'Figure', class: ['figure', 'w-full'] },
|
|
61
|
+
{
|
|
62
|
+
style: { height: absolute ? '100%' : '', maxWidth: inline ? width ~ 'px' : '' },
|
|
63
|
+
data_option_lazy: lazy
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
%}
|
|
67
|
+
|
|
68
|
+
{% set img_attributes =
|
|
69
|
+
merge_html_attributes(
|
|
70
|
+
img_attr ?? null,
|
|
71
|
+
{ class: 'figure__img' },
|
|
72
|
+
{
|
|
73
|
+
class: [
|
|
74
|
+
'absolute inset-0 w-full max-w-none h-full',
|
|
75
|
+
{
|
|
76
|
+
'object-cover': fit == 'cover',
|
|
77
|
+
'object-contain': fit == 'contain',
|
|
78
|
+
'object-fill': fit == 'fill',
|
|
79
|
+
'object-none': fit == 'none'
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
src: lazy ? placeholder|default(generic_placeholder) : src,
|
|
83
|
+
data_src: lazy ? src|default(generic_placeholder) : src,
|
|
84
|
+
alt: alt|default(''),
|
|
85
|
+
width: width|default(false),
|
|
86
|
+
height: height|default(false),
|
|
87
|
+
srcset: srcset|default(false),
|
|
88
|
+
sizes: sizes|default(false),
|
|
89
|
+
data_ref: 'img'
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
%}
|
|
93
|
+
|
|
94
|
+
{% set inner_attributes =
|
|
95
|
+
merge_html_attributes(
|
|
96
|
+
inner_attr ?? null,
|
|
97
|
+
{ class: ['figure__inner'] },
|
|
98
|
+
{
|
|
99
|
+
class: absolute ? ['absolute', 'inset-0'] : ['relative', 'w-full', 'h-0'],
|
|
100
|
+
style: { paddingTop: absolute ? '' : height * 100 / width ~ '%' }
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
%}
|
|
104
|
+
|
|
105
|
+
{% set caption_attributes =
|
|
106
|
+
merge_html_attributes(caption_attr ?? null, { class: 'figure__caption' })
|
|
107
|
+
%}
|
|
108
|
+
|
|
109
|
+
<figure {{ html_attributes(attributes) }}>
|
|
110
|
+
<div {{ html_attributes(inner_attributes) }}>
|
|
111
|
+
<img {{ html_attributes(img_attributes) }} />
|
|
112
|
+
</div>
|
|
113
|
+
{% if caption is defined %}
|
|
114
|
+
{% block caption %}
|
|
115
|
+
<figcaption {{ html_attributes(caption_attributes) }}>
|
|
116
|
+
{{ caption }}
|
|
117
|
+
</figcaption>
|
|
118
|
+
{% endblock %}
|
|
119
|
+
{% endif %}
|
|
120
|
+
</figure>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Icon component
|
|
5
|
+
*
|
|
6
|
+
* @param string $name The file name of the icon.
|
|
7
|
+
* @param string[] $classes Additional classes.
|
|
8
|
+
*/
|
|
9
|
+
#}
|
|
10
|
+
|
|
11
|
+
<span class="icon {{ 'icon--%s'|format(name) }} {{ html_classes(classes|default('inline-block')) }}">
|
|
12
|
+
{{ source('@svg/%s.svg'|format(name), ignore_missing = true) }}
|
|
13
|
+
</span>
|
|
@@ -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};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* LargeText component.
|
|
5
|
+
*
|
|
6
|
+
* @param string $content
|
|
7
|
+
* The text content.
|
|
8
|
+
* @param number $repeat
|
|
9
|
+
* The number of times the content should be repeated, defaults to 2.
|
|
10
|
+
* @param array $attr
|
|
11
|
+
* Custom attributes for the root element.
|
|
12
|
+
* @param array $target_attr
|
|
13
|
+
* Custom attributes for the target element.
|
|
14
|
+
*/
|
|
15
|
+
#}
|
|
16
|
+
|
|
17
|
+
{% set attributes =
|
|
18
|
+
merge_html_attributes(
|
|
19
|
+
attr ?? null,
|
|
20
|
+
{ data_component: 'LargeText' },
|
|
21
|
+
{ class: 'overflow-x-hidden pointer-events-none' }
|
|
22
|
+
)
|
|
23
|
+
%}
|
|
24
|
+
|
|
25
|
+
{% set target_attributes =
|
|
26
|
+
merge_html_attributes(
|
|
27
|
+
target_attr ?? null,
|
|
28
|
+
{ class: 'text-9xl font-bold' },
|
|
29
|
+
{ data_ref: 'target', class: 'relative inline-block whitespace-nowrap' }
|
|
30
|
+
)
|
|
31
|
+
%}
|
|
32
|
+
|
|
33
|
+
{% set position_factor = attributes.data_option_sensitivity is defined
|
|
34
|
+
and attributes.data_option_sensitivity < 0
|
|
35
|
+
? - 100
|
|
36
|
+
: 100
|
|
37
|
+
%}
|
|
38
|
+
|
|
39
|
+
<div {{ html_attributes(attributes) }}>
|
|
40
|
+
<span {{ html_attributes(target_attributes) }}>
|
|
41
|
+
{% for count in 1..repeat ?? 2 %}
|
|
42
|
+
{% set content_attributes = {
|
|
43
|
+
style: { left: loop.first ? '' : loop.index0 * position_factor ~ '%' },
|
|
44
|
+
class: { 'absolute top-0': not loop.first }
|
|
45
|
+
} %}
|
|
46
|
+
<span {{ html_attributes(content_attributes) }}> {{ content }}</span>
|
|
47
|
+
{% endfor %}
|
|
48
|
+
</span>
|
|
49
|
+
</div>
|
|
@@ -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};
|
package/index.cjs
CHANGED
|
@@ -19,4 +19,5 @@ module.exports = __toCommonJS(ui_exports);
|
|
|
19
19
|
__reExport(ui_exports, require("./primitives/index.cjs"), module.exports);
|
|
20
20
|
__reExport(ui_exports, require("./atoms/index.cjs"), module.exports);
|
|
21
21
|
__reExport(ui_exports, require("./molecules/index.cjs"), module.exports);
|
|
22
|
+
__reExport(ui_exports, require("./organisms/index.cjs"), module.exports);
|
|
22
23
|
if (module.exports.default) module.exports = module.exports.default;
|