marquee-content 1.8.0 → 1.9.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/src/index.html DELETED
@@ -1,146 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="ru">
3
- <head>
4
- <title>marquee-content</title>
5
- <meta name="robots" content="none">
6
- <meta charset="UTF-8">
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
8
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
9
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css">
10
- <link rel="preconnect" href="https://fonts.googleapis.com">
11
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
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
- <style type="text/css">
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}
15
- </style>
16
- </head>
17
- <body>
18
- <section class="data-code">
19
- <strong>data-mc-duration=&quot;60&quot;</strong>
20
- <p>The basic version, with scrolling content from right to left</p>
21
- </section>
22
- <section class="example-1">
23
- <div class="marquee-content"
24
- data-mc-duration="60"
25
- role="marquee">
26
- <ul class="font alkatra">
27
- <li>Monarch</li>
28
- <li>Benassi</li>
29
- <li>Air Max</li>
30
- <li>Cortez</li>
31
- <li>Jordan</li>
32
- <li>Presto</li>
33
- <li>Vomero</li>
34
- <li>Pegasus</li>
35
- </ul>
36
- </div>
37
- </section>
38
- <section class="example-7">
39
- <div class="marquee-content"
40
- data-mc-duration="20"
41
- role="marquee">
42
- <ul>
43
- <li><img src="//fastly.picsum.photos/id/634/180/100.jpg?hmac=qB-PFAiiEVuXFwVxRbYUzImrQ4RZ2np6oWeK-XHPnXk" alt></li>
44
- <li><img src="//fastly.picsum.photos/id/719/180/100.jpg?hmac=_Toti9aQVjjnNHabofyq_la4a0kIFSDp3o65zxnvtRY" alt></li>
45
- <li><img src="//fastly.picsum.photos/id/235/180/100.jpg?hmac=5KlYbDb93R7me0GThn6FFoK_OZ8ziPn-fb98FHIMb5c" alt></li>
46
- <li><img src="//fastly.picsum.photos/id/1050/180/100.jpg?hmac=f9i0nGYKBetkohJors44GETXmUhSbLcXMUlSvMCluJY" alt></li>
47
- </ul>
48
- </div>
49
- </section>
50
- <section class="data-code">
51
- <strong>data-mc-duration=&quot;60&quot; data-mc-direction=&quot;ltr&quot;</strong>
52
- <p><code>data-mc-direction="ltr"</code> &mdash; changes the scroll direction from left to right</p>
53
- </section>
54
- <section class="example-2">
55
- <div class="marquee-content"
56
- data-mc-duration="60"
57
- data-mc-direction="ltr"
58
- role="marquee">
59
- <ul>
60
- <li><span class="font anton">Monarch</span></li>
61
- <li><span class="font pt">Benassi</span></li>
62
- <li><span class="font lobster">Air Max</span></li>
63
- <li><span class="font prompt">Cortez</span></li>
64
- <li><span class="font anton">Jordan</span></li>
65
- <li><span class="font pt">Presto</span></li>
66
- <li><span class="font prompt">Tempo</span></li>
67
- <li><span class="font anton">Vomero</span></li>
68
- <li><span class="font pt">Pegasus</span></li>
69
- </ul>
70
- </div>
71
- </section>
72
- <section class="data-code">
73
- <strong>data-mc-duration=&quot;60&quot; data-mc-direction=&quot;auto&quot;</strong>
74
- <p><code>data-mc-direction="auto"</code> &mdash; automatically changes the scrolling direction of the component when scrolling the page</p>
75
- </section>
76
- <section class="example-3">
77
- <div class="marquee-content"
78
- data-mc-duration="60"
79
- data-mc-direction="auto"
80
- role="marquee">
81
- <ul class="font lobster">
82
- <li>Monarch</li>
83
- <li>Benassi</li>
84
- <li>Air Max</li>
85
- <li>Cortez</li>
86
- <li>Jordan</li>
87
- <li>Presto</li>
88
- <li>Tempo</li>
89
- <li>Vomero</li>
90
- <li>Pegasus</li>
91
- </ul>
92
- </div>
93
- </section>
94
- <section class="data-code">
95
- <strong>data-mc-duration=&quot;60&quot; data-mc-skew=&quot;-4&quot;</strong>
96
- <p><code>data-mc-skew="-4"</code> &mdash; transforms the component by tilting it along the Y axis (it is acceptable to use a positive or negative value)</p>
97
- </section>
98
- <section class="example-4">
99
- <div class="marquee-content"
100
- data-mc-duration="60"
101
- data-mc-skew="-4"
102
- role="marquee">
103
- <ul class="font pt">
104
- <li>Monarch</li>
105
- <li>Benassi</li>
106
- <li>Air Max</li>
107
- <li>Cortez</li>
108
- <li>Jordan</li>
109
- <li>Presto</li>
110
- <li>Tempo</li>
111
- <li>Vomero</li>
112
- <li>Pegasus</li>
113
- </ul>
114
- </div>
115
- </section>
116
- <section class="data-code">
117
- <strong>data-mc-duration=&quot;5&quot; data-mc-max=&quot;992&quot;</strong>
118
- <p><code>data-mc-max="992"</code> &mdash; 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>
119
- </section>
120
- <section class="example-6">
121
- <div class="marquee-content"
122
- data-mc-duration="5"
123
- data-mc-max="560"
124
- role="marquee">
125
- <ul class="font pt">
126
- <li>Jordan</li>
127
- </ul>
128
- </div>
129
- </section>
130
- <section class="data-code">
131
- <strong>data-mc-duration=&quot;5&quot; data-mc-min=&quot;992&quot;</strong>
132
- <p><code>data-mc-min="992"</code> &mdash; 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>
133
- </section>
134
- <section class="example-5">
135
- <div class="marquee-content"
136
- data-mc-duration="5"
137
- data-mc-min="560"
138
- role="marquee">
139
- <ul class="font pt">
140
- <li>Jordan</li>
141
- </ul>
142
- </div>
143
- </section>
144
- <script src="js/marquee-content.min.js"></script>
145
- </body>
146
- </html>
package/src/js/index.js DELETED
@@ -1,3 +0,0 @@
1
- import { MarqueeContent } from './marquee-content.js'
2
-
3
- MarqueeContent()
@@ -1,181 +0,0 @@
1
- import gsap from 'gsap'
2
- import ScrollTrigger from 'gsap/ScrollTrigger.js'
3
-
4
- gsap.registerPlugin(ScrollTrigger)
5
-
6
- const MarqueeContent = () => {
7
- const marquees = document.querySelectorAll('.marquee-content')
8
-
9
- for (const marquee of marquees) {
10
- let matchMedia = gsap.matchMedia(),
11
- dataSkew = marquee.dataset.mcSkew,
12
- dataDuration = marquee.dataset.mcDuration || 20,
13
- dataDirection = marquee.dataset.mcDirection,
14
- dataMaxWidth = marquee.dataset.mcMax,
15
- dataMinWidth = marquee.dataset.mcMin,
16
- breakpoint
17
-
18
- const
19
-
20
- debounce = (fn, delay) => {
21
- let timer
22
-
23
- return (...args) => {
24
- if (timer) clearTimeout(timer)
25
- timer = setTimeout(() => fn(...args), delay)
26
- }
27
- },
28
-
29
- breakpoints = () => {
30
- breakpoint = dataMaxWidth ?
31
- `(max-width: ${dataMaxWidth - 0.02}px)` : dataMinWidth ?
32
- `(min-width: ${dataMinWidth}px)` : ``
33
- },
34
-
35
- templates = () => {
36
- marquee.innerHTML = `
37
- <div class="marquee-wrapper">
38
- <div class="marquee-inner" style="display: inline-block; white-space: nowrap;">${marquee.innerHTML}</div>
39
- </div>
40
- `
41
- },
42
-
43
- cloning = () => {
44
- const removingClones = () => {
45
- while (marquee.childElementCount > 1) {
46
- marquee.removeChild(marquee.lastChild)
47
- }
48
- }
49
-
50
- removingClones()
51
-
52
- matchMedia.add(breakpoint, () => {
53
- let requiredQuantity = Math.ceil((marquee.scrollWidth / marquee.firstElementChild.clientWidth) + 2)
54
-
55
- if (marquee.childElementCount < requiredQuantity) {
56
- for (let i = 1; i < (requiredQuantity); i++) {
57
- let cloned = marquee.firstElementChild
58
- let clone = cloned.cloneNode(true)
59
- cloned.parentNode.append(clone)
60
- }
61
- }
62
-
63
- return () => {
64
- removingClones()
65
- }
66
- })
67
- },
68
-
69
- skewed = () => {
70
- if(!dataSkew) return
71
-
72
- matchMedia.add(breakpoint, () => {
73
- let abs = (dataSkew < 0) ? dataSkew * -1 : dataSkew
74
-
75
- marquee.style.transformOrigin = 'center center'
76
- marquee.style.transform = `skew(0deg, ${dataSkew}deg)`
77
- marquee.style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
78
-
79
- return () => {
80
- marquee.style.removeProperty('transform-origin')
81
- marquee.style.removeProperty('transform')
82
- marquee.style.removeProperty('min-height')
83
- }
84
- })
85
- },
86
-
87
- animation = () => {
88
- let timeLine = gsap.timeline()
89
-
90
- timeLine.kill()
91
- timeLine = null
92
-
93
- gsap.set(marquee.children, { clearProps: true })
94
-
95
- matchMedia.add(breakpoint, () => {
96
- gsap.set(marquee.children, { 'will-change': 'transform' })
97
-
98
- const tween = gsap.to(marquee.children, {
99
- duration: dataDuration,
100
- x: '-100%',
101
- ease: 'none',
102
- repeat: -1,
103
- scrollTrigger: {
104
- trigger: marquee,
105
- start: '-=50% bottom',
106
- end: 'bottom top',
107
- toggleActions: 'resume pause resume pause'
108
- },
109
- }).totalProgress(0.5)
110
-
111
- const ltrDirection = () => {
112
- gsap.to(tween, {
113
- timeScale: -1,
114
- overwrite: true
115
- })
116
- }
117
-
118
- const autoDirection = () => {
119
- let previousScrollPosition = 0
120
-
121
- const isScrollingDown = () => {
122
- let scrollPosition = window.pageYOffset || document.documentElement.scrollTop
123
-
124
- let direction = false
125
-
126
- if (scrollPosition > previousScrollPosition) {
127
- direction = true
128
- }
129
-
130
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
131
-
132
- gsap.to(tween, {
133
- timeScale: direction ? -1 : 1,
134
- overwrite: true
135
- })
136
- }
137
-
138
- addEventListener('scroll', isScrollingDown, {
139
- capture: true,
140
- passive: true
141
- })
142
- }
143
-
144
- if(dataDirection === 'ltr') {
145
- ltrDirection()
146
- } else if(dataDirection === 'auto') {
147
- autoDirection()
148
- }
149
- })
150
- },
151
-
152
- update = () => {
153
- skewed()
154
- cloning()
155
- animation()
156
- },
157
-
158
- init = () => {
159
- breakpoints()
160
- templates()
161
-
162
- matchMedia.add('(any-pointer: coarse)', () => {
163
- addEventListener('orientationchange', debounce(() => update(), 250))
164
- }).add('(any-pointer: fine)', () => {
165
- addEventListener('resize', debounce(() => update(), 250))
166
- })
167
-
168
- document.fonts.ready.then(() => {
169
- update()
170
- }).catch(() => {
171
- update()
172
- })
173
- }
174
-
175
- init()
176
- }
177
- }
178
-
179
- export {
180
- MarqueeContent
181
- }