marquee-content 3.0.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.468c551c.js +764 -0
- package/dist/index.html +262 -0
- package/dist/index.js +96 -89
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +96 -89
- package/dist/index.module.js.map +1 -1
- package/package.json +5 -5
- package/src/index.html +6 -2
- package/src/index.js +22 -123
- package/src/utils/animation.js +39 -0
- package/src/utils/breakpoints.js +11 -0
- package/src/utils/clearTimeline.js +10 -0
- package/src/utils/cloning.js +22 -0
- package/src/utils/skewed.js +18 -0
- package/src/utils/update.js +15 -0
- package/src/demo.js +0 -4
package/dist/index.html
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="ru">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="robots" content="index, follow">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0">
|
|
7
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
8
|
+
<title></title>
|
|
9
|
+
<style>html {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
font-family: system-ui, -apple-system, Open Sans, Helvetica Neue, Arial, Noto Sans, Liberation Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
|
|
12
|
+
font-size: 10px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
body {
|
|
16
|
+
--c-cells: #f2f2f2;
|
|
17
|
+
font-feature-settings: "kern" 1, "liga" 0;
|
|
18
|
+
background-image: -o-linear-gradient(45deg, var(--c-cells) 25%, transparent 25%), -o-linear-gradient(135deg, var(--c-cells) 25%, transparent 25%), -o-linear-gradient(45deg, transparent 75%, var(--c-cells) 75%), -o-linear-gradient(135deg, transparent 75%, var(--c-cells) 75%);
|
|
19
|
+
background-image: linear-gradient(45deg, var(--c-cells) 25%, transparent 25%), linear-gradient(-45deg, var(--c-cells) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--c-cells) 75%), linear-gradient(-45deg, transparent 75%, var(--c-cells) 75%);
|
|
20
|
+
width: 100vw;
|
|
21
|
+
background-position: 0 0, 0 1rem, 1rem -1rem, -1rem 0;
|
|
22
|
+
background-size: 2rem 2rem;
|
|
23
|
+
margin: 40px;
|
|
24
|
+
font-size: 1.6rem;
|
|
25
|
+
font-weight: 400;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
overflow-x: clip;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
marquee-content {
|
|
31
|
+
width: 100vw;
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
display: flex;
|
|
36
|
+
position: relative;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
marquee-content > * {
|
|
41
|
+
will-change: transform;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
html {
|
|
45
|
+
font-family: system-ui, -apple-system, Open Sans, Helvetica Neue, Arial, Noto Sans, Liberation Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
|
|
46
|
+
font-size: 10px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
body {
|
|
50
|
+
font-feature-settings: "kern" 1, "liga" 0;
|
|
51
|
+
color: #444;
|
|
52
|
+
margin: 80px 0 400px;
|
|
53
|
+
font-size: 1.6rem;
|
|
54
|
+
font-weight: 400;
|
|
55
|
+
line-height: 1.5;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
html, body, input, textarea, button {
|
|
59
|
+
-webkit-font-smoothing: subpixel-antialiased;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.marquee-content {
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
max-width: 100vw;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: center;
|
|
67
|
+
display: flex;
|
|
68
|
+
position: relative;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.font {
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.alkatra {
|
|
77
|
+
font-family: Alkatra, cursive;
|
|
78
|
+
font-size: 48px;
|
|
79
|
+
font-weight: 700;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.anton {
|
|
83
|
+
font-family: Anton, sans-serif;
|
|
84
|
+
font-size: 40px;
|
|
85
|
+
font-weight: 700;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.pt {
|
|
89
|
+
font-family: PT Sans Narrow, sans-serif;
|
|
90
|
+
font-size: 52px;
|
|
91
|
+
font-weight: 400;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.lobster {
|
|
95
|
+
font-family: Lobster, cursive;
|
|
96
|
+
font-size: 50px;
|
|
97
|
+
font-weight: 400;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.prompt {
|
|
101
|
+
font-family: Prompt, sans-serif;
|
|
102
|
+
font-size: 48px;
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
ul {
|
|
107
|
+
align-items: center;
|
|
108
|
+
margin: 0;
|
|
109
|
+
padding: 0;
|
|
110
|
+
list-style: none;
|
|
111
|
+
display: flex;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
li {
|
|
115
|
+
text-align: center;
|
|
116
|
+
padding: 0 10px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.example-1 li {
|
|
120
|
+
background: url("data:image/svg xml,<svg width='26' height='26' viewBox='0 0 26 26' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M15.0527 10.9474L13 0L10.9473 10.9474L0 13L10.9473 15.0526L13 26L15.0527 15.0526L26 13L15.0527 10.9474Z' fill='#444444'/></svg>")center left 20px / 26px 26pxno-repeat;
|
|
121
|
+
padding: 0 0 0 66px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.example-2 li {
|
|
125
|
+
padding: 0 15px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.example-3 li {
|
|
129
|
+
padding: 0 0 0 56px;
|
|
130
|
+
position: relative;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.example-3 li:before {
|
|
134
|
+
content: "";
|
|
135
|
+
width: 7px;
|
|
136
|
+
height: 7px;
|
|
137
|
+
background: #444;
|
|
138
|
+
border-radius: 100%;
|
|
139
|
+
margin: auto;
|
|
140
|
+
position: absolute;
|
|
141
|
+
inset: 0 -33px 0 auto;
|
|
142
|
+
transform: translateY(5px);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.example-4 {
|
|
146
|
+
text-transform: uppercase;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.data-code {
|
|
150
|
+
max-width: 1400px;
|
|
151
|
+
margin: 0 auto;
|
|
152
|
+
padding: 120px 20px 30px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.data-code strong {
|
|
156
|
+
border: 1px dotted #ccc;
|
|
157
|
+
padding: 5px 12px;
|
|
158
|
+
display: inline-flex;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
</style>
|
|
162
|
+
</head>
|
|
163
|
+
<body>
|
|
164
|
+
<section class="example-1">
|
|
165
|
+
<marquee-content data-mc-duration="60" role="marquee">
|
|
166
|
+
<ul class="font alkatra">
|
|
167
|
+
<li>Monarch</li>
|
|
168
|
+
<li>Benassi</li>
|
|
169
|
+
<li>Air Max</li>
|
|
170
|
+
<li>Cortez</li>
|
|
171
|
+
<li>Jordan</li>
|
|
172
|
+
<li>Presto</li>
|
|
173
|
+
<li>Vomero</li>
|
|
174
|
+
<li>Pegasus</li>
|
|
175
|
+
</ul>
|
|
176
|
+
</marquee-content>
|
|
177
|
+
</section>
|
|
178
|
+
|
|
179
|
+
<section class="example-7">
|
|
180
|
+
<marquee-content data-mc-duration="20" role="marquee">
|
|
181
|
+
<ul>
|
|
182
|
+
<li><img src="//fastly.picsum.photos/id/634/180/100.jpg?hmac=qB-PFAiiEVuXFwVxRbYUzImrQ4RZ2np6oWeK-XHPnXk" alt=""></li>
|
|
183
|
+
<li><img src="//fastly.picsum.photos/id/719/180/100.jpg?hmac=_Toti9aQVjjnNHabofyq_la4a0kIFSDp3o65zxnvtRY" alt=""></li>
|
|
184
|
+
<li><img src="//fastly.picsum.photos/id/235/180/100.jpg?hmac=5KlYbDb93R7me0GThn6FFoK_OZ8ziPn-fb98FHIMb5c" alt=""></li>
|
|
185
|
+
<li><img src="//fastly.picsum.photos/id/1050/180/100.jpg?hmac=f9i0nGYKBetkohJors44GETXmUhSbLcXMUlSvMCluJY" alt=""></li>
|
|
186
|
+
</ul>
|
|
187
|
+
</marquee-content>
|
|
188
|
+
</section>
|
|
189
|
+
|
|
190
|
+
<section class="example-2">
|
|
191
|
+
<marquee-content data-mc-duration="60" data-mc-direction="ltr" role="marquee">
|
|
192
|
+
<ul>
|
|
193
|
+
<li><span class="font anton">Monarch</span></li>
|
|
194
|
+
<li><span class="font pt">Benassi</span></li>
|
|
195
|
+
<li><span class="font lobster">Air Max</span></li>
|
|
196
|
+
<li><span class="font prompt">Cortez</span></li>
|
|
197
|
+
<li><span class="font anton">Jordan</span></li>
|
|
198
|
+
<li><span class="font pt">Presto</span></li>
|
|
199
|
+
<li><span class="font prompt">Tempo</span></li>
|
|
200
|
+
<li><span class="font anton">Vomero</span></li>
|
|
201
|
+
<li><span class="font pt">Pegasus</span></li>
|
|
202
|
+
</ul>
|
|
203
|
+
</marquee-content>
|
|
204
|
+
</section>
|
|
205
|
+
|
|
206
|
+
<section class="example-3">
|
|
207
|
+
<marquee-content data-mc-duration="60" data-mc-direction="auto" role="marquee">
|
|
208
|
+
<ul class="font lobster">
|
|
209
|
+
<li>Monarch</li>
|
|
210
|
+
<li>Benassi</li>
|
|
211
|
+
<li>Air Max</li>
|
|
212
|
+
<li>Cortez</li>
|
|
213
|
+
<li>Jordan</li>
|
|
214
|
+
<li>Presto</li>
|
|
215
|
+
<li>Tempo</li>
|
|
216
|
+
<li>Vomero</li>
|
|
217
|
+
<li>Pegasus</li>
|
|
218
|
+
</ul>
|
|
219
|
+
</marquee-content>
|
|
220
|
+
</section>
|
|
221
|
+
|
|
222
|
+
<section class="example-4">
|
|
223
|
+
<marquee-content data-mc-duration="60" data-mc-skew="-3" role="marquee">
|
|
224
|
+
<ul class="font pt">
|
|
225
|
+
<li>Monarch</li>
|
|
226
|
+
<li>Benassi</li>
|
|
227
|
+
<li>Air Max</li>
|
|
228
|
+
<li>Cortez</li>
|
|
229
|
+
<li>Jordan</li>
|
|
230
|
+
<li>Presto</li>
|
|
231
|
+
<li>Tempo</li>
|
|
232
|
+
<li>Vomero</li>
|
|
233
|
+
<li>Pegasus</li>
|
|
234
|
+
</ul>
|
|
235
|
+
</marquee-content>
|
|
236
|
+
</section>
|
|
237
|
+
|
|
238
|
+
<section class="example-6">
|
|
239
|
+
<marquee-content data-mc-duration="5" data-mc-max="992" role="marquee">
|
|
240
|
+
<ul class="font pt">
|
|
241
|
+
<li>Jordan</li>
|
|
242
|
+
</ul>
|
|
243
|
+
</marquee-content>
|
|
244
|
+
</section>
|
|
245
|
+
|
|
246
|
+
<section class="example-5">
|
|
247
|
+
<marquee-content data-mc-duration="5" data-mc-min="992" role="marquee">
|
|
248
|
+
<ul class="font pt">
|
|
249
|
+
<li>Cortez</li>
|
|
250
|
+
</ul>
|
|
251
|
+
</marquee-content>
|
|
252
|
+
</section>
|
|
253
|
+
|
|
254
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
|
255
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
|
|
256
|
+
<script src="/index.468c551c.js" defer=""></script>
|
|
257
|
+
<script>gsap.registerPlugin(ScrollTrigger);
|
|
258
|
+
MarqueeContent.registerGSAP(gsap);
|
|
259
|
+
|
|
260
|
+
</script>
|
|
261
|
+
</body>
|
|
262
|
+
</html>
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,90 @@ function $parcel$export(e, n, v, s) {
|
|
|
10
10
|
$parcel$defineInteropFlag(module.exports);
|
|
11
11
|
|
|
12
12
|
$parcel$export(module.exports, "default", () => $4fa36e821943b400$export$2e2bcd8739ae039);
|
|
13
|
+
function $fa2d7eec3b4b552b$var$breakpoints() {
|
|
14
|
+
this.breakpoint = "";
|
|
15
|
+
if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
|
|
16
|
+
else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
|
|
17
|
+
}
|
|
18
|
+
var $fa2d7eec3b4b552b$export$2e2bcd8739ae039 = $fa2d7eec3b4b552b$var$breakpoints;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function $66606e06234aec1c$var$cloning() {
|
|
22
|
+
const removingClones = ()=>{
|
|
23
|
+
while(this.childElementCount > 1)this.removeChild(this.lastChild);
|
|
24
|
+
};
|
|
25
|
+
removingClones();
|
|
26
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
27
|
+
const requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
|
|
28
|
+
if (this.childElementCount < requiredQuantity) {
|
|
29
|
+
const clones = Array.from({
|
|
30
|
+
length: requiredQuantity - 1
|
|
31
|
+
}, ()=>this.firstElementChild.cloneNode(true));
|
|
32
|
+
this.append(...clones);
|
|
33
|
+
}
|
|
34
|
+
return removingClones;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var $66606e06234aec1c$export$2e2bcd8739ae039 = $66606e06234aec1c$var$cloning;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
function $8ce6f1187c98529f$var$skewed() {
|
|
41
|
+
if (!this.dataset.mcSkew) return;
|
|
42
|
+
const abs = Math.abs(parseInt(this.dataset.mcSkew, 10));
|
|
43
|
+
const { style: style } = this;
|
|
44
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
45
|
+
style.transformOrigin = "center center";
|
|
46
|
+
style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
|
|
47
|
+
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
48
|
+
return ()=>{
|
|
49
|
+
style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
var $8ce6f1187c98529f$export$2e2bcd8739ae039 = $8ce6f1187c98529f$var$skewed;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
function $26261098b528e5f4$var$clearTimeline() {
|
|
57
|
+
if (this.timeline) {
|
|
58
|
+
this.timeline.kill();
|
|
59
|
+
this.timeline = null;
|
|
60
|
+
}
|
|
61
|
+
this.gsap.set(this.children, {
|
|
62
|
+
clearProps: true
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
var $26261098b528e5f4$export$2e2bcd8739ae039 = $26261098b528e5f4$var$clearTimeline;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
function $7206b27cbeabecb6$var$animation() {
|
|
69
|
+
if (this.timeline) (0, $26261098b528e5f4$export$2e2bcd8739ae039).call(this);
|
|
70
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
71
|
+
this.timeline = this.gsap.to(this.children, {
|
|
72
|
+
duration: this.dataset.mcDuration || 20,
|
|
73
|
+
x: "-100%",
|
|
74
|
+
repeat: -1,
|
|
75
|
+
ease: "none",
|
|
76
|
+
scrollTrigger: {
|
|
77
|
+
trigger: this,
|
|
78
|
+
start: "-=50% bottom",
|
|
79
|
+
end: "bottom top",
|
|
80
|
+
toggleActions: "resume pause resume pause",
|
|
81
|
+
onUpdate: (self)=>{
|
|
82
|
+
if (this.dataset.mcDirection === "ltr") this.timeline.timeScale(-1);
|
|
83
|
+
else if (this.dataset.mcDirection === "auto") this.timeline.timeScale(self.direction);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
this.timeline.totalProgress(0.5);
|
|
88
|
+
return ()=>{
|
|
89
|
+
if (this.timeline) (0, $26261098b528e5f4$export$2e2bcd8739ae039).call(this);
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
var $7206b27cbeabecb6$export$2e2bcd8739ae039 = $7206b27cbeabecb6$var$animation;
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
13
97
|
class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
14
98
|
constructor(){
|
|
15
99
|
super();
|
|
@@ -30,106 +114,29 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
30
114
|
timer = requestAnimationFrame(this.update);
|
|
31
115
|
};
|
|
32
116
|
};
|
|
33
|
-
breakpoints() {
|
|
34
|
-
this.breakpoint = "";
|
|
35
|
-
if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
|
|
36
|
-
else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
|
|
37
|
-
}
|
|
38
|
-
templates() {
|
|
39
|
-
const wrapper = document.createElement("div");
|
|
40
|
-
wrapper.classList.add("marquee-wrapper");
|
|
41
|
-
const inner = document.createElement("div");
|
|
42
|
-
inner.classList.add("marquee-inner");
|
|
43
|
-
inner.style.display = "inline-block";
|
|
44
|
-
inner.style.whiteSpace = "nowrap";
|
|
45
|
-
while(this.firstChild)inner.appendChild(this.firstChild);
|
|
46
|
-
wrapper.appendChild(inner);
|
|
47
|
-
this.appendChild(wrapper);
|
|
48
|
-
}
|
|
49
|
-
cloning() {
|
|
50
|
-
const removingClones = ()=>{
|
|
51
|
-
while(this.childElementCount > 1)this.removeChild(this.lastChild);
|
|
52
|
-
};
|
|
53
|
-
removingClones();
|
|
54
|
-
this.MM.add(this.breakpoint, ()=>{
|
|
55
|
-
const requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
|
|
56
|
-
if (this.childElementCount < requiredQuantity) {
|
|
57
|
-
const clones = Array.from({
|
|
58
|
-
length: requiredQuantity - 1
|
|
59
|
-
}, ()=>this.firstElementChild.cloneNode(true));
|
|
60
|
-
this.append(...clones);
|
|
61
|
-
}
|
|
62
|
-
return removingClones;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
skewed() {
|
|
66
|
-
if (!this.dataset.mcSkew) return;
|
|
67
|
-
const abs = Math.abs(parseInt(this.dataset.mcSkew, 10));
|
|
68
|
-
const { style: style } = this;
|
|
69
|
-
this.MM.add(this.breakpoint, ()=>{
|
|
70
|
-
style.transformOrigin = "center center";
|
|
71
|
-
style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
|
|
72
|
-
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
73
|
-
return ()=>{
|
|
74
|
-
style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
clearTimeline() {
|
|
79
|
-
if (this.timeline) {
|
|
80
|
-
this.timeline.kill();
|
|
81
|
-
this.timeline = null;
|
|
82
|
-
}
|
|
83
|
-
this.gsap.set(this.children, {
|
|
84
|
-
clearProps: true
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
animation() {
|
|
88
|
-
if (this.timeline) this.clearTimeline.call(this);
|
|
89
|
-
this.MM.add(this.breakpoint, ()=>{
|
|
90
|
-
this.timeline = this.gsap.to(this.children, {
|
|
91
|
-
duration: this.dataset.mcDuration || 20,
|
|
92
|
-
x: "-100%",
|
|
93
|
-
ease: "none",
|
|
94
|
-
repeat: -1,
|
|
95
|
-
scrollTrigger: {
|
|
96
|
-
trigger: this,
|
|
97
|
-
start: "-=50% bottom",
|
|
98
|
-
end: "bottom top",
|
|
99
|
-
toggleActions: "resume pause resume pause",
|
|
100
|
-
onUpdate: (self)=>{
|
|
101
|
-
if (this.dataset.mcDirection === "ltr") this.timeline.timeScale(-1);
|
|
102
|
-
else if (this.dataset.mcDirection === "auto") this.timeline.timeScale(self.direction);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
this.timeline.totalProgress(0.5);
|
|
107
|
-
return ()=>{
|
|
108
|
-
if (this.timeline) this.clearTimeline.call(this);
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
117
|
update() {
|
|
113
118
|
cancelAnimationFrame(this.af);
|
|
114
119
|
if (this.firstElementChild) this.af = requestAnimationFrame(()=>{
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
(0, $66606e06234aec1c$export$2e2bcd8739ae039).call(this);
|
|
121
|
+
(0, $7206b27cbeabecb6$export$2e2bcd8739ae039).call(this);
|
|
117
122
|
});
|
|
118
123
|
}
|
|
119
124
|
init() {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
(0, $fa2d7eec3b4b552b$export$2e2bcd8739ae039).call(this);
|
|
126
|
+
(0, $8ce6f1187c98529f$export$2e2bcd8739ae039).call(this);
|
|
127
|
+
(0, $66606e06234aec1c$export$2e2bcd8739ae039).call(this);
|
|
128
|
+
(0, $7206b27cbeabecb6$export$2e2bcd8739ae039).call(this);
|
|
129
|
+
}
|
|
130
|
+
destroy() {
|
|
131
|
+
cancelAnimationFrame(this.af);
|
|
132
|
+
(0, $26261098b528e5f4$export$2e2bcd8739ae039).call(this);
|
|
133
|
+
if (this.resizeObserver) this.resizeObserver.disconnect();
|
|
125
134
|
}
|
|
126
135
|
connectedCallback() {
|
|
127
136
|
this.init();
|
|
128
137
|
}
|
|
129
138
|
disconnectedCallback() {
|
|
130
|
-
|
|
131
|
-
this.clearTimeline();
|
|
132
|
-
if (this.resizeObserver) this.resizeObserver.disconnect();
|
|
139
|
+
this.destroy();
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
if (!customElements.get("marquee-content")) customElements.define("marquee-content", $4fa36e821943b400$export$2e2bcd8739ae039);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;ACAA,SAAS;IACP,IAAI,CAAC,UAAU,GAAG;IAElB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EACpB,IAAI,CAAC,UAAU,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC;SAC1D,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAC3B,IAAI,CAAC,UAAU,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;AAE5D;IAEA,2CAAe;;;ACVf,SAAS;IACP,MAAM,iBAAiB;QACrB,MAAO,IAAI,CAAC,iBAAiB,GAAG,EAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS;IAEnC;IAEA;IAEA,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE;QAC3B,MAAM,mBAAmB,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,GAAG;QAE3F,IAAI,IAAI,CAAC,iBAAiB,GAAG,kBAAkB;YAC7C,MAAM,SAAS,MAAM,IAAI,CAAC;gBAAE,QAAQ,mBAAmB;YAAE,GAAG,IAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC;YACnG,IAAI,CAAC,MAAM,IAAI;QACjB;QAEA,OAAO;IACT;AACF;IAEA,2CAAe;;;ACrBf,SAAS;IACP,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,M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,wCAAM,EAAE,IAAI,CAAC,IAAI;QACjB,CAAA,GAAA,wCAAQ,EAAE,IAAI,CAAC,IAAI;IACrB;IAEA,UAAU;QACR,qBAAqB,IAAI,CAAC,EAAE;QAE5B,CAAA,GAAA,wCAAY,EAAE,IAAI,CAAC,IAAI;QAEvB,IAAI,IAAI,CAAC,cAAc,EACrB,IAAI,CAAC,cAAc,CAAC,UAAU;IAElC;IAEA,oBAAoB;QAClB,IAAI,CAAC,IAAI;IACX;IAEA,uBAAuB;QACrB,IAAI,CAAC,OAAO;IACd;AACF;AAEA,IAAI,CAAC,eAAe,GAAG,CAAC,oBACtB,eAAe,MAAM,CAAC,mBAAmB","sources":["src/index.js","src/utils/breakpoints.js","src/utils/cloning.js","src/utils/skewed.js","src/utils/animation.js","src/utils/clearTimeline.js"],"sourcesContent":["import breakpoints from './utils/breakpoints';\nimport cloning from './utils/cloning';\nimport skewed from './utils/skewed';\nimport animation from './utils/animation';\nimport clearTimeline from './utils/clearTimeline';\n\nexport default class MarqueeContent extends HTMLElement {\n constructor() {\n super();\n\n this.gsap = MarqueeContent.gsap || window.gsap;\n this.MM = this.gsap.matchMedia();\n this.timeline = null;\n this.update = this.update.bind(this);\n this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this)));\n this.resizeObserver.observe(this);\n }\n\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap;\n }\n\n debounce = () => {\n let timer;\n\n return () => {\n cancelAnimationFrame(timer);\n timer = requestAnimationFrame(this.update);\n };\n };\n\n update() {\n cancelAnimationFrame(this.af);\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n cloning.call(this);\n animation.call(this);\n });\n }\n }\n\n init() {\n breakpoints.call(this);\n skewed.call(this);\n cloning.call(this);\n animation.call(this);\n }\n\n destroy() {\n cancelAnimationFrame(this.af);\n\n clearTimeline.call(this);\n\n if (this.resizeObserver) {\n this.resizeObserver.disconnect();\n }\n }\n\n connectedCallback() {\n this.init();\n }\n\n disconnectedCallback() {\n this.destroy();\n }\n}\n\nif (!customElements.get('marquee-content')) {\n customElements.define('marquee-content', MarqueeContent);\n}\n","function breakpoints() {\n this.breakpoint = '';\n\n if (this.dataset.mcMax) {\n this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;\n } else if (this.dataset.mcMin) {\n this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;\n }\n};\n\nexport default breakpoints;\n","function cloning() {\n const removingClones = () => {\n while (this.childElementCount > 1) {\n this.removeChild(this.lastChild);\n }\n };\n\n removingClones();\n\n this.MM.add(this.breakpoint, () => {\n const requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);\n\n if (this.childElementCount < requiredQuantity) {\n const clones = Array.from({ length: requiredQuantity - 1 }, () => this.firstElementChild.cloneNode(true));\n this.append(...clones);\n }\n\n return removingClones;\n });\n}\n\nexport default cloning;\n","function skewed() {\n if (!this.dataset.mcSkew) return;\n\n const abs = Math.abs(parseInt(this.dataset.mcSkew, 10));\n const { style } = this;\n\n this.MM.add(this.breakpoint, () => {\n style.transformOrigin = 'center center';\n style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;\n style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;\n\n return () => {\n style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;';\n };\n });\n}\n\nexport default skewed;\n","import clearTimeline from './clearTimeline';\n\nfunction animation() {\n if (this.timeline) {\n clearTimeline.call(this);\n }\n\n this.MM.add(this.breakpoint, () => {\n this.timeline = this.gsap.to(this.children, {\n duration: this.dataset.mcDuration || 20,\n x: '-100%',\n repeat: -1,\n ease: 'none',\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause',\n onUpdate: (self) => {\n if (this.dataset.mcDirection === 'ltr') {\n this.timeline.timeScale(-1);\n } else if (this.dataset.mcDirection === 'auto') {\n this.timeline.timeScale(self.direction);\n }\n },\n },\n });\n\n this.timeline.totalProgress(0.5);\n\n return () => {\n if (this.timeline) {\n clearTimeline.call(this);\n }\n };\n });\n}\n\nexport default animation;\n","function clearTimeline() {\n if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\n this.gsap.set(this.children, { clearProps: true });\n}\n\nexport default clearTimeline;\n"],"names":[],"version":3,"file":"index.js.map"}
|