marquee-content 0.0.4 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/index.html +30 -182
- package/dist/js/marquee-content.min.js +1 -1
- package/package.json +1 -1
- package/src/index.html +30 -182
- package/src/js/marquee-content.js +38 -15
package/README.md
CHANGED
|
@@ -34,7 +34,6 @@ import { MarqueeContent } from 'marquee-content'
|
|
|
34
34
|
### Usage
|
|
35
35
|
```HTML
|
|
36
36
|
<marquee-content
|
|
37
|
-
data-mc-clone="3"
|
|
38
37
|
data-mc-speed="60"
|
|
39
38
|
role="marquee">
|
|
40
39
|
<ul>
|
|
@@ -49,12 +48,11 @@ import { MarqueeContent } from 'marquee-content'
|
|
|
49
48
|
|
|
50
49
|
### Settings
|
|
51
50
|
|
|
52
|
-
| data- | Default | Description |
|
|
51
|
+
| data- | Default | Description |
|
|
53
52
|
| --- | --- | --- |
|
|
54
|
-
| `data-mc-clone` | `0` | Clones the content of the component the specified number of times. |
|
|
55
53
|
| `data-mc-speed` | `20` | Sets the duration of content scrolling in seconds. It is acceptable to use decimals. |
|
|
56
54
|
| `data-mc-direction` | `rtl` | `ltr` — changes the scroll direction from left to right.<br>`auto` — automatically changes the scrolling direction of the component when scrolling the page. |
|
|
57
|
-
| `data-mc-skew` | `
|
|
55
|
+
| `data-mc-skew` | `null` | Transforms the component by tilting it along the Y axis (it is acceptable to use a positive or negative value). |
|
|
58
56
|
| `data-mc-min` | `null` | Sets the minimum width at which the animation will be played (when the breakpoint intersects, the cloned elements will be removed and the component styles will be cleared). |
|
|
59
57
|
| `data-mc-max` | `null` | Sets the maximum width at which the animation will be played (when the breakpoint intersects, the cloned elements will be removed and the component styles will be cleared). |
|
|
60
58
|
|
package/dist/index.html
CHANGED
|
@@ -11,158 +11,17 @@
|
|
|
11
11
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
12
12
|
<link href="https://fonts.googleapis.com/css2?family=Alkatra:wght@700&family=Anton&family=Lobster&family=PT+Sans+Narrow:wght@700&family=Prompt:wght@500&display=swap" rel="stylesheet">
|
|
13
13
|
<style type="text/css">
|
|
14
|
-
html {
|
|
15
|
-
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";
|
|
16
|
-
font-size: 10px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
body {
|
|
20
|
-
margin: 150px 0 500px;
|
|
21
|
-
font-feature-settings: "kern" 1,"liga" 0;
|
|
22
|
-
font-size: 1.6rem;
|
|
23
|
-
font-weight: 400;
|
|
24
|
-
line-height: 1.5;
|
|
25
|
-
color: #444;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
html,
|
|
29
|
-
body,
|
|
30
|
-
input,
|
|
31
|
-
textarea,
|
|
32
|
-
button {
|
|
33
|
-
-webkit-font-smoothing: subpixel-antialiased;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
marquee-content {
|
|
37
|
-
pointer-events: none;
|
|
38
|
-
max-width: 100vw;
|
|
39
|
-
justify-content: center;
|
|
40
|
-
align-items: center;
|
|
41
|
-
display: flex;
|
|
42
|
-
position: relative;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.font {
|
|
47
|
-
white-space: nowrap;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.alkatra {
|
|
51
|
-
font-family: 'Alkatra', cursive;
|
|
52
|
-
font-weight: 700;
|
|
53
|
-
font-size: 48px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.anton {
|
|
57
|
-
font-family: 'Anton', sans-serif;
|
|
58
|
-
font-weight: 700;
|
|
59
|
-
font-size: 40px;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.pt {
|
|
63
|
-
font-family: 'PT Sans Narrow', sans-serif;
|
|
64
|
-
font-weight: 400;
|
|
65
|
-
font-size: 52px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.lobster {
|
|
69
|
-
font-family: 'Lobster', cursive;
|
|
70
|
-
font-weight: 400;
|
|
71
|
-
font-size: 50px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.prompt {
|
|
75
|
-
font-family: 'Prompt', sans-serif;
|
|
76
|
-
font-weight: 500;
|
|
77
|
-
font-size: 48px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
ul {
|
|
81
|
-
list-style: none;
|
|
82
|
-
margin: 0; padding: 0;
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
li {
|
|
88
|
-
padding: 0 10px;
|
|
89
|
-
text-align: center;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.example-1 {
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.example-1 li {
|
|
97
|
-
padding: 0 0 0 66px;
|
|
98
|
-
background:
|
|
99
|
-
url("data:image/svg+xml,%3Csvg width='26' height='26' viewBox='0 0 26 26' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.0527 10.9474L13 0L10.9473 10.9474L0 13L10.9473 15.0526L13 26L15.0527 15.0526L26 13L15.0527 10.9474Z' fill='%23444444'/%3E%3C/svg%3E")
|
|
100
|
-
center left 20px / 26px 26px
|
|
101
|
-
no-repeat;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.example-2 {
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.example-2 li {
|
|
109
|
-
padding: 0 15px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.example-3 {
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.example-3 li {
|
|
117
|
-
position: relative;
|
|
118
|
-
padding: 0 0 0 56px;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.example-3 li::before {
|
|
122
|
-
content: '';
|
|
123
|
-
position: absolute;
|
|
124
|
-
top: 0; right: -33px; bottom: 0; left: auto;
|
|
125
|
-
margin: auto;
|
|
126
|
-
width: 7px; height: 7px;
|
|
127
|
-
transform: translateY(5px);
|
|
128
|
-
background: #444;
|
|
129
|
-
border-radius: 100%;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.example-4 {
|
|
133
|
-
text-transform: uppercase;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.example-5 {
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.example-6 {
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.data-code {
|
|
145
|
-
margin: 80px auto 30px;
|
|
146
|
-
padding: 0 20px;
|
|
147
|
-
max-width: 1400px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.data-code strong {
|
|
151
|
-
display: inline-flex;
|
|
152
|
-
padding: 5px 12px;
|
|
153
|
-
border: 1px dotted #ccc;
|
|
154
|
-
}
|
|
14
|
+
html{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";font-size: 10px}body{margin: 150px 0 400px;font-feature-settings: "kern" 1,"liga" 0;font-size: 1.6rem;font-weight: 400;line-height: 1.5;color: #444}html,body,input,textarea,button{-webkit-font-smoothing: subpixel-antialiased}marquee-content{pointer-events: none;max-width: 100vw;justify-content: center;align-items: center;display: flex;position: relative;overflow: hidden}.font{white-space: nowrap}.alkatra{font-family: 'Alkatra', cursive;font-weight: 700;font-size: 48px}.anton{font-family: 'Anton', sans-serif;font-weight: 700;font-size: 40px}.pt{font-family: 'PT Sans Narrow', sans-serif;font-weight: 400;font-size: 52px}.lobster{font-family: 'Lobster', cursive;font-weight: 400;font-size: 50px}.prompt{font-family: 'Prompt', sans-serif;font-weight: 500;font-size: 48px}ul{list-style: none;margin: 0;padding: 0;display: flex;align-items: center}li{padding: 0 10px;text-align: center}.example-1 li{padding: 0 0 0 66px;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}.example-2 li{padding: 0 15px}.example-3 li{position: relative;padding: 0 0 0 56px}.example-3 li::before{content: '';position: absolute;top: 0;right: -33px;bottom: 0;left: auto;margin: auto;width: 7px;height: 7px;transform: translateY(5px);background: #444;border-radius: 100%}.example-4{text-transform: uppercase}.data-code{margin: 80px auto 30px;padding: 0 20px;max-width: 1400px}.data-code strong{display: inline-flex;padding: 5px 12px;border: 1px dotted #ccc}
|
|
155
15
|
</style>
|
|
156
16
|
</head>
|
|
157
17
|
<body>
|
|
158
18
|
<section class="data-code">
|
|
159
|
-
<strong>data-mc-
|
|
160
|
-
<p>The basic version, with scrolling content from right to left
|
|
19
|
+
<strong>data-mc-speed="60"</strong>
|
|
20
|
+
<p>The basic version, with scrolling content from right to left</p>
|
|
161
21
|
</section>
|
|
162
22
|
<section class="example-1">
|
|
163
23
|
<marquee-content
|
|
164
|
-
data-mc-
|
|
165
|
-
data-mc-speed="50"
|
|
24
|
+
data-mc-speed="60"
|
|
166
25
|
role="marquee">
|
|
167
26
|
<ul class="font alkatra">
|
|
168
27
|
<li>Monarch</li>
|
|
@@ -178,14 +37,25 @@
|
|
|
178
37
|
</ul>
|
|
179
38
|
</marquee-content>
|
|
180
39
|
</section>
|
|
40
|
+
<section class="example-7">
|
|
41
|
+
<marquee-content
|
|
42
|
+
data-mc-speed="40"
|
|
43
|
+
role="marquee">
|
|
44
|
+
<ul>
|
|
45
|
+
<li><img src="//fastly.picsum.photos/id/634/180/100.jpg?hmac=qB-PFAiiEVuXFwVxRbYUzImrQ4RZ2np6oWeK-XHPnXk" alt></li>
|
|
46
|
+
<li><img src="//fastly.picsum.photos/id/719/180/100.jpg?hmac=_Toti9aQVjjnNHabofyq_la4a0kIFSDp3o65zxnvtRY" alt></li>
|
|
47
|
+
<li><img src="//fastly.picsum.photos/id/235/180/100.jpg?hmac=5KlYbDb93R7me0GThn6FFoK_OZ8ziPn-fb98FHIMb5c" alt></li>
|
|
48
|
+
<li><img src="//fastly.picsum.photos/id/1050/180/100.jpg?hmac=f9i0nGYKBetkohJors44GETXmUhSbLcXMUlSvMCluJY" alt></li>
|
|
49
|
+
</ul>
|
|
50
|
+
</marquee-content>
|
|
51
|
+
</section>
|
|
181
52
|
<section class="data-code">
|
|
182
|
-
<strong>data-mc-
|
|
53
|
+
<strong>data-mc-speed="60" data-mc-direction="ltr"</strong>
|
|
183
54
|
<p><code>data-mc-direction="ltr"</code> — changes the scroll direction from left to right</p>
|
|
184
55
|
</section>
|
|
185
56
|
<section class="example-2">
|
|
186
57
|
<marquee-content
|
|
187
|
-
data-mc-
|
|
188
|
-
data-mc-speed="70"
|
|
58
|
+
data-mc-speed="60"
|
|
189
59
|
data-mc-direction="ltr"
|
|
190
60
|
role="marquee">
|
|
191
61
|
<ul>
|
|
@@ -203,12 +73,11 @@
|
|
|
203
73
|
</marquee-content>
|
|
204
74
|
</section>
|
|
205
75
|
<section class="data-code">
|
|
206
|
-
<strong>data-mc-
|
|
76
|
+
<strong>data-mc-speed="60" data-mc-direction="auto"</strong>
|
|
207
77
|
<p><code>data-mc-direction="auto"</code> — automatically changes the scrolling direction of the component when scrolling the page</p>
|
|
208
78
|
</section>
|
|
209
79
|
<section class="example-3">
|
|
210
80
|
<marquee-content
|
|
211
|
-
data-mc-clone="3"
|
|
212
81
|
data-mc-speed="60"
|
|
213
82
|
data-mc-direction="auto"
|
|
214
83
|
role="marquee">
|
|
@@ -227,14 +96,13 @@
|
|
|
227
96
|
</marquee-content>
|
|
228
97
|
</section>
|
|
229
98
|
<section class="data-code">
|
|
230
|
-
<strong>data-mc-
|
|
231
|
-
<p><code>data-mc-skew="-
|
|
99
|
+
<strong>data-mc-speed="60" data-mc-skew="-4"</strong>
|
|
100
|
+
<p><code>data-mc-skew="-4"</code> — transforms the component by tilting it along the Y axis (it is acceptable to use a positive or negative value)</p>
|
|
232
101
|
</section>
|
|
233
102
|
<section class="example-4">
|
|
234
103
|
<marquee-content
|
|
235
|
-
data-mc-clone="3"
|
|
236
104
|
data-mc-speed="60"
|
|
237
|
-
data-mc-skew="-
|
|
105
|
+
data-mc-skew="-4"
|
|
238
106
|
role="marquee">
|
|
239
107
|
<ul class="font pt">
|
|
240
108
|
<li>Monarch</li>
|
|
@@ -251,50 +119,30 @@
|
|
|
251
119
|
</marquee-content>
|
|
252
120
|
</section>
|
|
253
121
|
<section class="data-code">
|
|
254
|
-
<strong>data-mc-
|
|
255
|
-
<p><code>data-mc-min="
|
|
122
|
+
<strong>data-mc-speed="5" data-mc-min="800"</strong>
|
|
123
|
+
<p><code>data-mc-min="800"</code> — sets the minimum screen width at which the animation will be played (when the breakpoint intersects, the cloned elements will be removed and the component styles will be cleared)</p>
|
|
256
124
|
</section>
|
|
257
125
|
<section class="example-5">
|
|
258
126
|
<marquee-content
|
|
259
|
-
data-mc-
|
|
260
|
-
data-mc-
|
|
261
|
-
data-mc-min="1200"
|
|
127
|
+
data-mc-speed="5"
|
|
128
|
+
data-mc-min="800"
|
|
262
129
|
role="marquee">
|
|
263
130
|
<ul class="font pt">
|
|
264
|
-
<li>Monarch</li>
|
|
265
|
-
<li>Benassi</li>
|
|
266
|
-
<li>Air Max</li>
|
|
267
|
-
<li>Cortez</li>
|
|
268
131
|
<li>Jordan</li>
|
|
269
|
-
<li>Presto</li>
|
|
270
|
-
<li>Roshe</li>
|
|
271
|
-
<li>Tempo</li>
|
|
272
|
-
<li>Vomero</li>
|
|
273
|
-
<li>Pegasus</li>
|
|
274
132
|
</ul>
|
|
275
133
|
</marquee-content>
|
|
276
134
|
</section>
|
|
277
135
|
<section class="data-code">
|
|
278
|
-
<strong>data-mc-
|
|
279
|
-
<p><code>data-mc-max="
|
|
136
|
+
<strong>data-mc-speed="5" data-mc-max="800"</strong>
|
|
137
|
+
<p><code>data-mc-max="800"</code> — sets the maximum screen width at which the animation will be played (when the breakpoint intersects, the cloned elements will be removed and the component styles will be cleared)</p>
|
|
280
138
|
</section>
|
|
281
139
|
<section class="example-6">
|
|
282
140
|
<marquee-content
|
|
283
|
-
data-mc-
|
|
284
|
-
data-mc-
|
|
285
|
-
data-mc-max="1200"
|
|
141
|
+
data-mc-speed="5"
|
|
142
|
+
data-mc-max="800"
|
|
286
143
|
role="marquee">
|
|
287
144
|
<ul class="font pt">
|
|
288
|
-
<li>Monarch</li>
|
|
289
|
-
<li>Benassi</li>
|
|
290
|
-
<li>Air Max</li>
|
|
291
|
-
<li>Cortez</li>
|
|
292
145
|
<li>Jordan</li>
|
|
293
|
-
<li>Presto</li>
|
|
294
|
-
<li>Roshe</li>
|
|
295
|
-
<li>Tempo</li>
|
|
296
|
-
<li>Vomero</li>
|
|
297
|
-
<li>Pegasus</li>
|
|
298
146
|
</ul>
|
|
299
147
|
</marquee-content>
|
|
300
148
|
</section>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.mm=gsap.matchMedia(),this.tl=gsap.timeline(),this.speed=this.dataset.mcSpeed||20,this.
|
|
1
|
+
(()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.mm=gsap.matchMedia(),this.tl=gsap.timeline(),this.speed=this.dataset.mcSpeed||20,this.skew=this.dataset.mcSkew,this.max=this.dataset.mcMax,this.min=this.dataset.mcMin,this.dir=this.dataset.mcDirection,this.breakpoints(),this.cloning(),this.skewed(),this.marquee(),this.scrollReverse(),this.debounce(),this.resizing()}breakpoints(){this.max||this.min?(this.max&&(this.breakpoint=`(max-width: ${this.max-.02}px)`),this.min&&(this.breakpoint=`(min-width: ${this.min}px)`)):this.breakpoint="(min-width: 100vw)"}cloning(){for(;this.children.length>1;)this.removeChild(this.lastChild);this.mm.add(this.breakpoint,(()=>{if(this.hasChildNodes()){let t=(this.clientWidth/this.firstElementChild.clientWidth+2).toFixed(0);for(let e=0;e<t;e++){let t=this.firstElementChild,e=t.cloneNode(!0);t.after(e)}}}))}skewed(){this.skew&&this.mm.add(this.breakpoint,(()=>{let t=this.skew<0?-1*this.skew:this.skew;return this.style.transformOrigin="center center",this.style.transform=`skew(0deg, ${this.skew}deg)`,this.style.minHeight=`calc(${1.25*t}vh + ${1.25*t}vw)`,()=>{this.style.removeProperty("transform-origin"),this.style.removeProperty("transform"),this.style.removeProperty("min-height")}}))}marquee(){this.mm.add(this.breakpoint,(()=>{this.tl=gsap.timeline(),gsap.config({nullTargetWarn:!1}),this.tl.paused(!0),gsap.set(this.children,{"will-change":"transform"}),this.tl.to(this.children,{duration:this.speed,x:"-100%",ease:"none",repeat:-1}).timeScale("ltr"===this.dir?-1:1).totalProgress(.5),ScrollTrigger.create({trigger:this,start:"top bottom",end:"bottom top",onEnter:()=>this.tl.resume(),onLeave:()=>this.tl.pause(),onEnterBack:()=>this.tl.resume(),onLeaveBack:()=>this.tl.pause()})}))}scrollReverse(){"auto"===this.dir&&this.mm.add(this.breakpoint,(()=>{let t=0,e=1;window.addEventListener("scroll",(()=>{let i=window.pageYOffset>t?1:-1;i!==e&&(gsap.to(this.tl,{timeScale:i,overwrite:!0}),e=i),t=window.pageYOffset}))}))}debounce(t,e){let i;return(...s)=>{i&&clearTimeout(i),i=setTimeout((()=>t(...s)),e)}}resizing(){window.addEventListener("resize",this.debounce((()=>{this.tl.pause(),gsap.set(this.children,{clearProps:!0}),this.cloning(),this.marquee()}),250))}}customElements.get("marquee-content")||customElements.define("marquee-content",t),new t})();
|
package/package.json
CHANGED
package/src/index.html
CHANGED
|
@@ -11,158 +11,17 @@
|
|
|
11
11
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
12
12
|
<link href="https://fonts.googleapis.com/css2?family=Alkatra:wght@700&family=Anton&family=Lobster&family=PT+Sans+Narrow:wght@700&family=Prompt:wght@500&display=swap" rel="stylesheet">
|
|
13
13
|
<style type="text/css">
|
|
14
|
-
html {
|
|
15
|
-
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";
|
|
16
|
-
font-size: 10px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
body {
|
|
20
|
-
margin: 150px 0 500px;
|
|
21
|
-
font-feature-settings: "kern" 1,"liga" 0;
|
|
22
|
-
font-size: 1.6rem;
|
|
23
|
-
font-weight: 400;
|
|
24
|
-
line-height: 1.5;
|
|
25
|
-
color: #444;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
html,
|
|
29
|
-
body,
|
|
30
|
-
input,
|
|
31
|
-
textarea,
|
|
32
|
-
button {
|
|
33
|
-
-webkit-font-smoothing: subpixel-antialiased;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
marquee-content {
|
|
37
|
-
pointer-events: none;
|
|
38
|
-
max-width: 100vw;
|
|
39
|
-
justify-content: center;
|
|
40
|
-
align-items: center;
|
|
41
|
-
display: flex;
|
|
42
|
-
position: relative;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.font {
|
|
47
|
-
white-space: nowrap;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.alkatra {
|
|
51
|
-
font-family: 'Alkatra', cursive;
|
|
52
|
-
font-weight: 700;
|
|
53
|
-
font-size: 48px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.anton {
|
|
57
|
-
font-family: 'Anton', sans-serif;
|
|
58
|
-
font-weight: 700;
|
|
59
|
-
font-size: 40px;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.pt {
|
|
63
|
-
font-family: 'PT Sans Narrow', sans-serif;
|
|
64
|
-
font-weight: 400;
|
|
65
|
-
font-size: 52px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.lobster {
|
|
69
|
-
font-family: 'Lobster', cursive;
|
|
70
|
-
font-weight: 400;
|
|
71
|
-
font-size: 50px;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.prompt {
|
|
75
|
-
font-family: 'Prompt', sans-serif;
|
|
76
|
-
font-weight: 500;
|
|
77
|
-
font-size: 48px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
ul {
|
|
81
|
-
list-style: none;
|
|
82
|
-
margin: 0; padding: 0;
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
li {
|
|
88
|
-
padding: 0 10px;
|
|
89
|
-
text-align: center;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.example-1 {
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.example-1 li {
|
|
97
|
-
padding: 0 0 0 66px;
|
|
98
|
-
background:
|
|
99
|
-
url("data:image/svg+xml,%3Csvg width='26' height='26' viewBox='0 0 26 26' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.0527 10.9474L13 0L10.9473 10.9474L0 13L10.9473 15.0526L13 26L15.0527 15.0526L26 13L15.0527 10.9474Z' fill='%23444444'/%3E%3C/svg%3E")
|
|
100
|
-
center left 20px / 26px 26px
|
|
101
|
-
no-repeat;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.example-2 {
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.example-2 li {
|
|
109
|
-
padding: 0 15px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.example-3 {
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.example-3 li {
|
|
117
|
-
position: relative;
|
|
118
|
-
padding: 0 0 0 56px;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.example-3 li::before {
|
|
122
|
-
content: '';
|
|
123
|
-
position: absolute;
|
|
124
|
-
top: 0; right: -33px; bottom: 0; left: auto;
|
|
125
|
-
margin: auto;
|
|
126
|
-
width: 7px; height: 7px;
|
|
127
|
-
transform: translateY(5px);
|
|
128
|
-
background: #444;
|
|
129
|
-
border-radius: 100%;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.example-4 {
|
|
133
|
-
text-transform: uppercase;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.example-5 {
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.example-6 {
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.data-code {
|
|
145
|
-
margin: 80px auto 30px;
|
|
146
|
-
padding: 0 20px;
|
|
147
|
-
max-width: 1400px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.data-code strong {
|
|
151
|
-
display: inline-flex;
|
|
152
|
-
padding: 5px 12px;
|
|
153
|
-
border: 1px dotted #ccc;
|
|
154
|
-
}
|
|
14
|
+
html{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";font-size: 10px}body{margin: 150px 0 400px;font-feature-settings: "kern" 1,"liga" 0;font-size: 1.6rem;font-weight: 400;line-height: 1.5;color: #444}html,body,input,textarea,button{-webkit-font-smoothing: subpixel-antialiased}marquee-content{pointer-events: none;max-width: 100vw;justify-content: center;align-items: center;display: flex;position: relative;overflow: hidden}.font{white-space: nowrap}.alkatra{font-family: 'Alkatra', cursive;font-weight: 700;font-size: 48px}.anton{font-family: 'Anton', sans-serif;font-weight: 700;font-size: 40px}.pt{font-family: 'PT Sans Narrow', sans-serif;font-weight: 400;font-size: 52px}.lobster{font-family: 'Lobster', cursive;font-weight: 400;font-size: 50px}.prompt{font-family: 'Prompt', sans-serif;font-weight: 500;font-size: 48px}ul{list-style: none;margin: 0;padding: 0;display: flex;align-items: center}li{padding: 0 10px;text-align: center}.example-1 li{padding: 0 0 0 66px;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}.example-2 li{padding: 0 15px}.example-3 li{position: relative;padding: 0 0 0 56px}.example-3 li::before{content: '';position: absolute;top: 0;right: -33px;bottom: 0;left: auto;margin: auto;width: 7px;height: 7px;transform: translateY(5px);background: #444;border-radius: 100%}.example-4{text-transform: uppercase}.data-code{margin: 80px auto 30px;padding: 0 20px;max-width: 1400px}.data-code strong{display: inline-flex;padding: 5px 12px;border: 1px dotted #ccc}
|
|
155
15
|
</style>
|
|
156
16
|
</head>
|
|
157
17
|
<body>
|
|
158
18
|
<section class="data-code">
|
|
159
|
-
<strong>data-mc-
|
|
160
|
-
<p>The basic version, with scrolling content from right to left
|
|
19
|
+
<strong>data-mc-speed="60"</strong>
|
|
20
|
+
<p>The basic version, with scrolling content from right to left</p>
|
|
161
21
|
</section>
|
|
162
22
|
<section class="example-1">
|
|
163
23
|
<marquee-content
|
|
164
|
-
data-mc-
|
|
165
|
-
data-mc-speed="50"
|
|
24
|
+
data-mc-speed="60"
|
|
166
25
|
role="marquee">
|
|
167
26
|
<ul class="font alkatra">
|
|
168
27
|
<li>Monarch</li>
|
|
@@ -178,14 +37,25 @@
|
|
|
178
37
|
</ul>
|
|
179
38
|
</marquee-content>
|
|
180
39
|
</section>
|
|
40
|
+
<section class="example-7">
|
|
41
|
+
<marquee-content
|
|
42
|
+
data-mc-speed="40"
|
|
43
|
+
role="marquee">
|
|
44
|
+
<ul>
|
|
45
|
+
<li><img src="//fastly.picsum.photos/id/634/180/100.jpg?hmac=qB-PFAiiEVuXFwVxRbYUzImrQ4RZ2np6oWeK-XHPnXk" alt></li>
|
|
46
|
+
<li><img src="//fastly.picsum.photos/id/719/180/100.jpg?hmac=_Toti9aQVjjnNHabofyq_la4a0kIFSDp3o65zxnvtRY" alt></li>
|
|
47
|
+
<li><img src="//fastly.picsum.photos/id/235/180/100.jpg?hmac=5KlYbDb93R7me0GThn6FFoK_OZ8ziPn-fb98FHIMb5c" alt></li>
|
|
48
|
+
<li><img src="//fastly.picsum.photos/id/1050/180/100.jpg?hmac=f9i0nGYKBetkohJors44GETXmUhSbLcXMUlSvMCluJY" alt></li>
|
|
49
|
+
</ul>
|
|
50
|
+
</marquee-content>
|
|
51
|
+
</section>
|
|
181
52
|
<section class="data-code">
|
|
182
|
-
<strong>data-mc-
|
|
53
|
+
<strong>data-mc-speed="60" data-mc-direction="ltr"</strong>
|
|
183
54
|
<p><code>data-mc-direction="ltr"</code> — changes the scroll direction from left to right</p>
|
|
184
55
|
</section>
|
|
185
56
|
<section class="example-2">
|
|
186
57
|
<marquee-content
|
|
187
|
-
data-mc-
|
|
188
|
-
data-mc-speed="70"
|
|
58
|
+
data-mc-speed="60"
|
|
189
59
|
data-mc-direction="ltr"
|
|
190
60
|
role="marquee">
|
|
191
61
|
<ul>
|
|
@@ -203,12 +73,11 @@
|
|
|
203
73
|
</marquee-content>
|
|
204
74
|
</section>
|
|
205
75
|
<section class="data-code">
|
|
206
|
-
<strong>data-mc-
|
|
76
|
+
<strong>data-mc-speed="60" data-mc-direction="auto"</strong>
|
|
207
77
|
<p><code>data-mc-direction="auto"</code> — automatically changes the scrolling direction of the component when scrolling the page</p>
|
|
208
78
|
</section>
|
|
209
79
|
<section class="example-3">
|
|
210
80
|
<marquee-content
|
|
211
|
-
data-mc-clone="3"
|
|
212
81
|
data-mc-speed="60"
|
|
213
82
|
data-mc-direction="auto"
|
|
214
83
|
role="marquee">
|
|
@@ -227,14 +96,13 @@
|
|
|
227
96
|
</marquee-content>
|
|
228
97
|
</section>
|
|
229
98
|
<section class="data-code">
|
|
230
|
-
<strong>data-mc-
|
|
231
|
-
<p><code>data-mc-skew="-
|
|
99
|
+
<strong>data-mc-speed="60" data-mc-skew="-4"</strong>
|
|
100
|
+
<p><code>data-mc-skew="-4"</code> — transforms the component by tilting it along the Y axis (it is acceptable to use a positive or negative value)</p>
|
|
232
101
|
</section>
|
|
233
102
|
<section class="example-4">
|
|
234
103
|
<marquee-content
|
|
235
|
-
data-mc-clone="3"
|
|
236
104
|
data-mc-speed="60"
|
|
237
|
-
data-mc-skew="-
|
|
105
|
+
data-mc-skew="-4"
|
|
238
106
|
role="marquee">
|
|
239
107
|
<ul class="font pt">
|
|
240
108
|
<li>Monarch</li>
|
|
@@ -251,50 +119,30 @@
|
|
|
251
119
|
</marquee-content>
|
|
252
120
|
</section>
|
|
253
121
|
<section class="data-code">
|
|
254
|
-
<strong>data-mc-
|
|
255
|
-
<p><code>data-mc-min="
|
|
122
|
+
<strong>data-mc-speed="5" data-mc-min="800"</strong>
|
|
123
|
+
<p><code>data-mc-min="800"</code> — sets the minimum screen width at which the animation will be played (when the breakpoint intersects, the cloned elements will be removed and the component styles will be cleared)</p>
|
|
256
124
|
</section>
|
|
257
125
|
<section class="example-5">
|
|
258
126
|
<marquee-content
|
|
259
|
-
data-mc-
|
|
260
|
-
data-mc-
|
|
261
|
-
data-mc-min="1200"
|
|
127
|
+
data-mc-speed="5"
|
|
128
|
+
data-mc-min="800"
|
|
262
129
|
role="marquee">
|
|
263
130
|
<ul class="font pt">
|
|
264
|
-
<li>Monarch</li>
|
|
265
|
-
<li>Benassi</li>
|
|
266
|
-
<li>Air Max</li>
|
|
267
|
-
<li>Cortez</li>
|
|
268
131
|
<li>Jordan</li>
|
|
269
|
-
<li>Presto</li>
|
|
270
|
-
<li>Roshe</li>
|
|
271
|
-
<li>Tempo</li>
|
|
272
|
-
<li>Vomero</li>
|
|
273
|
-
<li>Pegasus</li>
|
|
274
132
|
</ul>
|
|
275
133
|
</marquee-content>
|
|
276
134
|
</section>
|
|
277
135
|
<section class="data-code">
|
|
278
|
-
<strong>data-mc-
|
|
279
|
-
<p><code>data-mc-max="
|
|
136
|
+
<strong>data-mc-speed="5" data-mc-max="800"</strong>
|
|
137
|
+
<p><code>data-mc-max="800"</code> — sets the maximum screen width at which the animation will be played (when the breakpoint intersects, the cloned elements will be removed and the component styles will be cleared)</p>
|
|
280
138
|
</section>
|
|
281
139
|
<section class="example-6">
|
|
282
140
|
<marquee-content
|
|
283
|
-
data-mc-
|
|
284
|
-
data-mc-
|
|
285
|
-
data-mc-max="1200"
|
|
141
|
+
data-mc-speed="5"
|
|
142
|
+
data-mc-max="800"
|
|
286
143
|
role="marquee">
|
|
287
144
|
<ul class="font pt">
|
|
288
|
-
<li>Monarch</li>
|
|
289
|
-
<li>Benassi</li>
|
|
290
|
-
<li>Air Max</li>
|
|
291
|
-
<li>Cortez</li>
|
|
292
145
|
<li>Jordan</li>
|
|
293
|
-
<li>Presto</li>
|
|
294
|
-
<li>Roshe</li>
|
|
295
|
-
<li>Tempo</li>
|
|
296
|
-
<li>Vomero</li>
|
|
297
|
-
<li>Pegasus</li>
|
|
298
146
|
</ul>
|
|
299
147
|
</marquee-content>
|
|
300
148
|
</section>
|
|
@@ -5,9 +5,7 @@ export class MarqueeContent extends HTMLElement {
|
|
|
5
5
|
this.mm = gsap.matchMedia()
|
|
6
6
|
this.tl = gsap.timeline()
|
|
7
7
|
this.speed = this.dataset.mcSpeed || 20
|
|
8
|
-
this.clone = this.dataset.mcClone
|
|
9
8
|
this.skew = this.dataset.mcSkew
|
|
10
|
-
this.abs = (this.skew < 0) ? this.skew * -1 : this.skew
|
|
11
9
|
this.max = this.dataset.mcMax
|
|
12
10
|
this.min = this.dataset.mcMin
|
|
13
11
|
this.dir = this.dataset.mcDirection
|
|
@@ -16,7 +14,9 @@ export class MarqueeContent extends HTMLElement {
|
|
|
16
14
|
this.cloning()
|
|
17
15
|
this.skewed()
|
|
18
16
|
this.marquee()
|
|
19
|
-
this.
|
|
17
|
+
this.scrollReverse()
|
|
18
|
+
this.debounce()
|
|
19
|
+
this.resizing()
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
breakpoints() {
|
|
@@ -34,18 +34,18 @@ export class MarqueeContent extends HTMLElement {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
cloning() {
|
|
37
|
-
|
|
37
|
+
while (this.children.length > 1) {
|
|
38
|
+
this.removeChild(this.lastChild)
|
|
39
|
+
}
|
|
38
40
|
|
|
39
41
|
this.mm.add(this.breakpoint, () => {
|
|
40
|
-
|
|
41
|
-
let
|
|
42
|
-
let clone = item.cloneNode(true)
|
|
43
|
-
item.after(clone)
|
|
44
|
-
}
|
|
42
|
+
if (this.hasChildNodes()) {
|
|
43
|
+
let requiredQuantity = (this.clientWidth / this.firstElementChild.clientWidth + 2).toFixed(0)
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
for (let i = 0; i < requiredQuantity; i++) {
|
|
46
|
+
let item = this.firstElementChild
|
|
47
|
+
let clone = item.cloneNode(true)
|
|
48
|
+
item.after(clone)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
})
|
|
@@ -55,20 +55,24 @@ export class MarqueeContent extends HTMLElement {
|
|
|
55
55
|
if(!this.skew) { return }
|
|
56
56
|
|
|
57
57
|
this.mm.add(this.breakpoint, () => {
|
|
58
|
-
|
|
58
|
+
let abs = (this.skew < 0) ? this.skew * -1 : this.skew
|
|
59
|
+
|
|
59
60
|
this.style.transformOrigin = `center center`
|
|
60
61
|
this.style.transform = `skew(0deg, ${this.skew}deg)`
|
|
62
|
+
this.style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
|
|
61
63
|
|
|
62
64
|
return () => {
|
|
63
|
-
this.style.removeProperty('min-height')
|
|
64
65
|
this.style.removeProperty('transform-origin')
|
|
65
66
|
this.style.removeProperty('transform')
|
|
67
|
+
this.style.removeProperty('min-height')
|
|
66
68
|
}
|
|
67
69
|
})
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
marquee() {
|
|
71
73
|
this.mm.add(this.breakpoint, () => {
|
|
74
|
+
this.tl = gsap.timeline()
|
|
75
|
+
|
|
72
76
|
gsap.config({
|
|
73
77
|
nullTargetWarn: false
|
|
74
78
|
})
|
|
@@ -98,7 +102,7 @@ export class MarqueeContent extends HTMLElement {
|
|
|
98
102
|
})
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
|
|
105
|
+
scrollReverse() {
|
|
102
106
|
if(this.dir !== 'auto') { return }
|
|
103
107
|
|
|
104
108
|
this.mm.add(this.breakpoint, () => {
|
|
@@ -121,6 +125,25 @@ export class MarqueeContent extends HTMLElement {
|
|
|
121
125
|
})
|
|
122
126
|
})
|
|
123
127
|
}
|
|
128
|
+
|
|
129
|
+
debounce(fn, delay) {
|
|
130
|
+
let timer
|
|
131
|
+
|
|
132
|
+
return (...args) => {
|
|
133
|
+
if (timer) clearTimeout(timer)
|
|
134
|
+
timer = setTimeout(() => fn(...args), delay)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
resizing() {
|
|
139
|
+
window.addEventListener('resize', this.debounce(() => {
|
|
140
|
+
this.tl.pause()
|
|
141
|
+
gsap.set(this.children, { clearProps: true })
|
|
142
|
+
|
|
143
|
+
this.cloning()
|
|
144
|
+
this.marquee()
|
|
145
|
+
}, 250))
|
|
146
|
+
}
|
|
124
147
|
}
|
|
125
148
|
|
|
126
149
|
customElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)
|