marquee-content 0.0.7 → 1.0.0

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 CHANGED
@@ -7,7 +7,7 @@
7
7
  [![GitHub package version](https://img.shields.io/github/package-json/v/ux-ui-pro/marquee-content.svg)](https://github.com/ux-ui-pro/marquee-content)
8
8
  [![NPM Downloads](https://img.shields.io/npm/dm/marquee-content.svg?style=flat)](https://www.npmjs.org/package/marquee-content)
9
9
 
10
- <sup><a href="https://bundlephobia.com/package/marquee-content@0.0.2">1Kb gzipped</a></sup>
10
+ <sup><a href="https://bundlephobia.com/package/marquee-content">1Kb gzipped</a></sup>
11
11
 
12
12
  <h3><a href="https://ux-ui-pro.github.io/marquee-content/dist/">Demo</a></h3>
13
13
 
@@ -48,10 +48,10 @@ import { MarqueeContent } from 'marquee-content'
48
48
 
49
49
  ### Settings
50
50
 
51
- | data-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Default | Description |
51
+ | data-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Default | Description |
52
52
  | --- | --- | --- |
53
- | `data-mc-speed` | `20` | Sets the duration of content scrolling in seconds. It is acceptable to use decimals. |
54
- | `data-mc-direction` | `rtl` | `ltr` &mdash; changes the scroll direction from left to right.<br>`auto` &mdash; automatically changes the scrolling direction of the component when scrolling the page. |
53
+ | `data-mc-duration` | `20` | Sets the duration of content scrolling in seconds. It is acceptable to use decimals. |
54
+ | `data-mc-direction` | `rtl` | `rtl` &mdash; default value, no need to specify.<br>`ltr` &mdash; changes the scroll direction from left to right.<br>`auto` &mdash; automatically changes the direction of the animation when scrolling the page. |
55
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). |
56
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). |
57
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). |
package/dist/index.html CHANGED
@@ -16,12 +16,12 @@
16
16
  </head>
17
17
  <body>
18
18
  <section class="data-code">
19
- <strong>data-mc-speed=&quot;60&quot;</strong>
19
+ <strong>data-mc-duration=&quot;60&quot;</strong>
20
20
  <p>The basic version, with scrolling content from right to left</p>
21
21
  </section>
22
22
  <section class="example-1">
23
23
  <marquee-content
24
- data-mc-speed="60"
24
+ data-mc-duration="60"
25
25
  role="marquee">
26
26
  <ul class="font alkatra">
27
27
  <li>Monarch</li>
@@ -30,8 +30,6 @@
30
30
  <li>Cortez</li>
31
31
  <li>Jordan</li>
32
32
  <li>Presto</li>
33
- <li>Roshe</li>
34
- <li>Tempo</li>
35
33
  <li>Vomero</li>
36
34
  <li>Pegasus</li>
37
35
  </ul>
@@ -39,7 +37,7 @@
39
37
  </section>
40
38
  <section class="example-7">
41
39
  <marquee-content
42
- data-mc-speed="40"
40
+ data-mc-duration="20"
43
41
  role="marquee">
44
42
  <ul>
45
43
  <li><img src="//fastly.picsum.photos/id/634/180/100.jpg?hmac=qB-PFAiiEVuXFwVxRbYUzImrQ4RZ2np6oWeK-XHPnXk" alt></li>
@@ -50,12 +48,12 @@
50
48
  </marquee-content>
51
49
  </section>
52
50
  <section class="data-code">
53
- <strong>data-mc-speed=&quot;60&quot; data-mc-direction=&quot;ltr&quot;</strong>
51
+ <strong>data-mc-duration=&quot;60&quot; data-mc-direction=&quot;ltr&quot;</strong>
54
52
  <p><code>data-mc-direction="ltr"</code> &mdash; changes the scroll direction from left to right</p>
55
53
  </section>
56
54
  <section class="example-2">
57
55
  <marquee-content
58
- data-mc-speed="60"
56
+ data-mc-duration="60"
59
57
  data-mc-direction="ltr"
60
58
  role="marquee">
61
59
  <ul>
@@ -65,7 +63,6 @@
65
63
  <li><span class="font prompt">Cortez</span></li>
66
64
  <li><span class="font anton">Jordan</span></li>
67
65
  <li><span class="font pt">Presto</span></li>
68
- <li><span class="font lobster">Roshe</span></li>
69
66
  <li><span class="font prompt">Tempo</span></li>
70
67
  <li><span class="font anton">Vomero</span></li>
71
68
  <li><span class="font pt">Pegasus</span></li>
@@ -73,12 +70,12 @@
73
70
  </marquee-content>
74
71
  </section>
75
72
  <section class="data-code">
76
- <strong>data-mc-speed=&quot;60&quot; data-mc-direction=&quot;auto&quot;</strong>
73
+ <strong>data-mc-duration=&quot;60&quot; data-mc-direction=&quot;auto&quot;</strong>
77
74
  <p><code>data-mc-direction="auto"</code> &mdash; automatically changes the scrolling direction of the component when scrolling the page</p>
78
75
  </section>
79
76
  <section class="example-3">
80
77
  <marquee-content
81
- data-mc-speed="60"
78
+ data-mc-duration="60"
82
79
  data-mc-direction="auto"
83
80
  role="marquee">
84
81
  <ul class="font lobster">
@@ -88,7 +85,6 @@
88
85
  <li>Cortez</li>
89
86
  <li>Jordan</li>
90
87
  <li>Presto</li>
91
- <li>Roshe</li>
92
88
  <li>Tempo</li>
93
89
  <li>Vomero</li>
94
90
  <li>Pegasus</li>
@@ -96,12 +92,12 @@
96
92
  </marquee-content>
97
93
  </section>
98
94
  <section class="data-code">
99
- <strong>data-mc-speed=&quot;60&quot; data-mc-skew=&quot;-4&quot;</strong>
95
+ <strong>data-mc-duration=&quot;60&quot; data-mc-skew=&quot;-4&quot;</strong>
100
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>
101
97
  </section>
102
98
  <section class="example-4">
103
99
  <marquee-content
104
- data-mc-speed="60"
100
+ data-mc-duration="60"
105
101
  data-mc-skew="-4"
106
102
  role="marquee">
107
103
  <ul class="font pt">
@@ -111,7 +107,6 @@
111
107
  <li>Cortez</li>
112
108
  <li>Jordan</li>
113
109
  <li>Presto</li>
114
- <li>Roshe</li>
115
110
  <li>Tempo</li>
116
111
  <li>Vomero</li>
117
112
  <li>Pegasus</li>
@@ -119,13 +114,13 @@
119
114
  </marquee-content>
120
115
  </section>
121
116
  <section class="data-code">
122
- <strong>data-mc-speed=&quot;5&quot; data-mc-min=&quot;800&quot;</strong>
123
- <p><code>data-mc-min="800"</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>
117
+ <strong>data-mc-duration=&quot;5&quot; data-mc-min=&quot;992&quot;</strong>
118
+ <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>
124
119
  </section>
125
120
  <section class="example-5">
126
121
  <marquee-content
127
- data-mc-speed="5"
128
- data-mc-min="800"
122
+ data-mc-duration="5"
123
+ data-mc-min="992"
129
124
  role="marquee">
130
125
  <ul class="font pt">
131
126
  <li>Jordan</li>
@@ -133,16 +128,16 @@
133
128
  </marquee-content>
134
129
  </section>
135
130
  <section class="data-code">
136
- <strong>data-mc-speed=&quot;5&quot; data-mc-max=&quot;800&quot;</strong>
137
- <p><code>data-mc-max="800"</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>
131
+ <strong>data-mc-duration=&quot;5&quot; data-mc-max=&quot;992&quot;</strong>
132
+ <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>
138
133
  </section>
139
134
  <section class="example-6">
140
135
  <marquee-content
141
- data-mc-speed="5"
142
- data-mc-max="800"
136
+ data-mc-duration="5"
137
+ data-mc-max="992"
143
138
  role="marquee">
144
139
  <ul class="font pt">
145
- <li>Jordan</li>
140
+ <li>Presto</li>
146
141
  </ul>
147
142
  </marquee-content>
148
143
  </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.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})();
1
+ (()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.mm=gsap.matchMedia(),this.tl=gsap.timeline(),this.duration=this.dataset.mcDuration||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=""}cloning(){const t=()=>{for(;this.children.length>1;)this.removeChild(this.lastChild)};t(),this.mm.add(this.breakpoint,(()=>{if(this.hasChildNodes()){let t=(this.clientWidth/this.firstElementChild.clientWidth+3).toFixed(0);for(let e=1;e<t;e++){let t=this.firstElementChild,e=t.cloneNode(!0);t.parentNode.append(e)}}return()=>{t()}}))}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.duration,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(){const t=()=>{this.mm.add(this.breakpoint,(()=>{this.tl.kill(),this.tl=null,gsap.set(this.children,{clearProps:!0}),this.cloning(),this.marquee()}))};this.mm.add("(any-pointer: coarse)",(()=>{window.matchMedia("(orientation: portrait)").addEventListener("change",(e=>{e.matches||t()}))})),this.mm.add("(any-pointer: fine)",(()=>{window.addEventListener("resize",this.debounce((()=>{t()}),250))}))}}customElements.get("marquee-content")||customElements.define("marquee-content",t),new t})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marquee-content",
3
- "version": "0.0.7",
3
+ "version": "1.0.0",
4
4
  "description": "Marquee content with GSAP",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
package/src/index.html CHANGED
@@ -16,12 +16,12 @@
16
16
  </head>
17
17
  <body>
18
18
  <section class="data-code">
19
- <strong>data-mc-speed=&quot;60&quot;</strong>
19
+ <strong>data-mc-duration=&quot;60&quot;</strong>
20
20
  <p>The basic version, with scrolling content from right to left</p>
21
21
  </section>
22
22
  <section class="example-1">
23
23
  <marquee-content
24
- data-mc-speed="60"
24
+ data-mc-duration="60"
25
25
  role="marquee">
26
26
  <ul class="font alkatra">
27
27
  <li>Monarch</li>
@@ -30,8 +30,6 @@
30
30
  <li>Cortez</li>
31
31
  <li>Jordan</li>
32
32
  <li>Presto</li>
33
- <li>Roshe</li>
34
- <li>Tempo</li>
35
33
  <li>Vomero</li>
36
34
  <li>Pegasus</li>
37
35
  </ul>
@@ -39,7 +37,7 @@
39
37
  </section>
40
38
  <section class="example-7">
41
39
  <marquee-content
42
- data-mc-speed="40"
40
+ data-mc-duration="20"
43
41
  role="marquee">
44
42
  <ul>
45
43
  <li><img src="//fastly.picsum.photos/id/634/180/100.jpg?hmac=qB-PFAiiEVuXFwVxRbYUzImrQ4RZ2np6oWeK-XHPnXk" alt></li>
@@ -50,12 +48,12 @@
50
48
  </marquee-content>
51
49
  </section>
52
50
  <section class="data-code">
53
- <strong>data-mc-speed=&quot;60&quot; data-mc-direction=&quot;ltr&quot;</strong>
51
+ <strong>data-mc-duration=&quot;60&quot; data-mc-direction=&quot;ltr&quot;</strong>
54
52
  <p><code>data-mc-direction="ltr"</code> &mdash; changes the scroll direction from left to right</p>
55
53
  </section>
56
54
  <section class="example-2">
57
55
  <marquee-content
58
- data-mc-speed="60"
56
+ data-mc-duration="60"
59
57
  data-mc-direction="ltr"
60
58
  role="marquee">
61
59
  <ul>
@@ -65,7 +63,6 @@
65
63
  <li><span class="font prompt">Cortez</span></li>
66
64
  <li><span class="font anton">Jordan</span></li>
67
65
  <li><span class="font pt">Presto</span></li>
68
- <li><span class="font lobster">Roshe</span></li>
69
66
  <li><span class="font prompt">Tempo</span></li>
70
67
  <li><span class="font anton">Vomero</span></li>
71
68
  <li><span class="font pt">Pegasus</span></li>
@@ -73,12 +70,12 @@
73
70
  </marquee-content>
74
71
  </section>
75
72
  <section class="data-code">
76
- <strong>data-mc-speed=&quot;60&quot; data-mc-direction=&quot;auto&quot;</strong>
73
+ <strong>data-mc-duration=&quot;60&quot; data-mc-direction=&quot;auto&quot;</strong>
77
74
  <p><code>data-mc-direction="auto"</code> &mdash; automatically changes the scrolling direction of the component when scrolling the page</p>
78
75
  </section>
79
76
  <section class="example-3">
80
77
  <marquee-content
81
- data-mc-speed="60"
78
+ data-mc-duration="60"
82
79
  data-mc-direction="auto"
83
80
  role="marquee">
84
81
  <ul class="font lobster">
@@ -88,7 +85,6 @@
88
85
  <li>Cortez</li>
89
86
  <li>Jordan</li>
90
87
  <li>Presto</li>
91
- <li>Roshe</li>
92
88
  <li>Tempo</li>
93
89
  <li>Vomero</li>
94
90
  <li>Pegasus</li>
@@ -96,12 +92,12 @@
96
92
  </marquee-content>
97
93
  </section>
98
94
  <section class="data-code">
99
- <strong>data-mc-speed=&quot;60&quot; data-mc-skew=&quot;-4&quot;</strong>
95
+ <strong>data-mc-duration=&quot;60&quot; data-mc-skew=&quot;-4&quot;</strong>
100
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>
101
97
  </section>
102
98
  <section class="example-4">
103
99
  <marquee-content
104
- data-mc-speed="60"
100
+ data-mc-duration="60"
105
101
  data-mc-skew="-4"
106
102
  role="marquee">
107
103
  <ul class="font pt">
@@ -111,7 +107,6 @@
111
107
  <li>Cortez</li>
112
108
  <li>Jordan</li>
113
109
  <li>Presto</li>
114
- <li>Roshe</li>
115
110
  <li>Tempo</li>
116
111
  <li>Vomero</li>
117
112
  <li>Pegasus</li>
@@ -119,13 +114,13 @@
119
114
  </marquee-content>
120
115
  </section>
121
116
  <section class="data-code">
122
- <strong>data-mc-speed=&quot;5&quot; data-mc-min=&quot;800&quot;</strong>
123
- <p><code>data-mc-min="800"</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>
117
+ <strong>data-mc-duration=&quot;5&quot; data-mc-min=&quot;992&quot;</strong>
118
+ <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>
124
119
  </section>
125
120
  <section class="example-5">
126
121
  <marquee-content
127
- data-mc-speed="5"
128
- data-mc-min="800"
122
+ data-mc-duration="5"
123
+ data-mc-min="992"
129
124
  role="marquee">
130
125
  <ul class="font pt">
131
126
  <li>Jordan</li>
@@ -133,16 +128,16 @@
133
128
  </marquee-content>
134
129
  </section>
135
130
  <section class="data-code">
136
- <strong>data-mc-speed=&quot;5&quot; data-mc-max=&quot;800&quot;</strong>
137
- <p><code>data-mc-max="800"</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>
131
+ <strong>data-mc-duration=&quot;5&quot; data-mc-max=&quot;992&quot;</strong>
132
+ <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>
138
133
  </section>
139
134
  <section class="example-6">
140
135
  <marquee-content
141
- data-mc-speed="5"
142
- data-mc-max="800"
136
+ data-mc-duration="5"
137
+ data-mc-max="992"
143
138
  role="marquee">
144
139
  <ul class="font pt">
145
- <li>Jordan</li>
140
+ <li>Presto</li>
146
141
  </ul>
147
142
  </marquee-content>
148
143
  </section>
@@ -4,7 +4,7 @@ export class MarqueeContent extends HTMLElement {
4
4
 
5
5
  this.mm = gsap.matchMedia()
6
6
  this.tl = gsap.timeline()
7
- this.speed = this.dataset.mcSpeed || 20
7
+ this.duration = this.dataset.mcDuration || 20
8
8
  this.skew = this.dataset.mcSkew
9
9
  this.max = this.dataset.mcMax
10
10
  this.min = this.dataset.mcMin
@@ -29,25 +29,31 @@ export class MarqueeContent extends HTMLElement {
29
29
  this.breakpoint = `(min-width: ${this.min}px)`
30
30
  }
31
31
  } else {
32
- this.breakpoint = `(min-width: 100vw)`
32
+ this.breakpoint = ``
33
33
  }
34
34
  }
35
35
 
36
36
  cloning() {
37
- while (this.children.length > 1) {
38
- this.removeChild(this.lastChild)
37
+ const removingClones = () => {
38
+ while (this.children.length > 1) {
39
+ this.removeChild(this.lastChild)
40
+ }
39
41
  }
40
42
 
43
+ removingClones()
44
+
41
45
  this.mm.add(this.breakpoint, () => {
42
46
  if (this.hasChildNodes()) {
43
- let requiredQuantity = (this.clientWidth / this.firstElementChild.clientWidth + 2).toFixed(0)
47
+ let requiredQuantity = (this.clientWidth / this.firstElementChild.clientWidth + 3).toFixed(0)
44
48
 
45
- for (let i = 0; i < requiredQuantity; i++) {
49
+ for (let i = 1; i < requiredQuantity; i++) {
46
50
  let item = this.firstElementChild
47
51
  let clone = item.cloneNode(true)
48
- item.after(clone)
52
+ item.parentNode.append(clone)
49
53
  }
50
54
  }
55
+
56
+ return () => { removingClones() }
51
57
  })
52
58
  }
53
59
 
@@ -84,7 +90,7 @@ export class MarqueeContent extends HTMLElement {
84
90
  })
85
91
 
86
92
  this.tl.to(this.children, {
87
- duration: this.speed,
93
+ duration: this.duration,
88
94
  x: '-100%',
89
95
  ease: 'none',
90
96
  repeat: -1
@@ -136,13 +142,32 @@ export class MarqueeContent extends HTMLElement {
136
142
  }
137
143
 
138
144
  resizing() {
139
- window.addEventListener('resize', this.debounce(() => {
140
- this.tl.pause()
141
- gsap.set(this.children, { clearProps: true })
145
+ const resetAmin = () => {
146
+ this.mm.add(this.breakpoint, () => {
147
+ this.tl.kill()
148
+ this.tl = null
149
+ gsap.set(this.children, { clearProps: true })
150
+
151
+ this.cloning()
152
+ this.marquee()
153
+ })
154
+ }
155
+
156
+ this.mm.add('(any-pointer: coarse)', () => {
157
+ let portrait = window.matchMedia('(orientation: portrait)')
142
158
 
143
- this.cloning()
144
- this.marquee()
145
- }, 250))
159
+ portrait.addEventListener('change', (e) => {
160
+ if(!e.matches) {
161
+ resetAmin()
162
+ }
163
+ })
164
+ })
165
+
166
+ this.mm.add('(any-pointer: fine)', () => {
167
+ window.addEventListener('resize', this.debounce(() => {
168
+ resetAmin()
169
+ }, 250))
170
+ })
146
171
  }
147
172
  }
148
173