marquee-content 2.1.1 → 2.2.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
@@ -1,42 +1,46 @@
1
- <div align="center">
2
1
  <br>
2
+ <p align="center"><strong>marquee-content</strong></p>
3
3
 
4
- <h1>marquee-content</h1>
5
- <p><sup>Infinite marquee animation with <a href="https://www.npmjs.com/package/gsap">GSAP</a></sup></p>
6
-
4
+ <div align="center">
7
5
 
8
6
  [![npm](https://img.shields.io/npm/v/marquee-content.svg?colorB=brightgreen)](https://www.npmjs.com/package/marquee-content)
9
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)
10
8
  [![NPM Downloads](https://img.shields.io/npm/dm/marquee-content.svg?style=flat)](https://www.npmjs.org/package/marquee-content)
11
9
 
12
- <sup>1.2kB gzipped</sup>
13
- <h3><a href="https://codepen.io/ux-ui/full/dygzqYm">Demo</a></h3>
14
-
15
10
  </div>
11
+
12
+ <p align="center">A class for creating the running content effect, also known as a marquee or ticker.<br>Uses GSAP and Resize Observer for best performance.</p>
13
+ <p align="center"><sup>1.2kB gzipped</sup></p>
14
+ <p align="center"><a href="https://codepen.io/ux-ui/full/dygzqYm">Demo</a></p>
16
15
  <br>
17
16
 
18
- ### Installation
17
+ &#10148; **Install**
18
+
19
19
  ```
20
- $ yarn add gsap
21
- $ yarn add marquee-content
20
+ yarn add gsap
21
+ yarn add marquee-content
22
22
  ```
23
23
 
24
24
  <br>
25
25
 
26
- ### Import
26
+ &#10148; **Import**
27
+
27
28
  ```javascript
28
- import { gsap } from 'gsap'
29
- import { ScrollTrigger } from 'gsap/ScrollTrigger'
30
- import MarqueeContent from 'marquee-content'
29
+ import gsap from 'gsap';
30
+ import { ScrollTrigger } from 'gsap/ScrollTrigger';
31
+ import MarqueeContent from 'marquee-content';
32
+
33
+ gsap.registerPlugin(ScrollTrigger);
34
+ MarqueeContent.registerGSAP(gsap);
31
35
 
32
- gsap.registerPlugin(ScrollTrigger)
33
- MarqueeContent.registerGSAP(gsap)
36
+ const marqueeContent = new MarqueeContent();
34
37
 
35
- new MarqueeContent()
38
+ marqueeContent.init();
36
39
  ```
37
40
  <br>
38
41
 
39
- ### Usage
42
+ &#10148; **Usage**
43
+
40
44
  ```HTML
41
45
  <marquee-content data-mc-duration="30" role="marquee">
42
46
  content
@@ -44,17 +48,18 @@ new MarqueeContent()
44
48
  ```
45
49
  <br>
46
50
 
47
- ### Settings
51
+ &#10148; **Settings**
48
52
 
49
- | 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 |
50
- | --- | --- | --- |
51
- | `data-mc-duration` | `20` | Sets the duration of content scrolling in seconds. It is acceptable to use decimals. |
52
- | `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. |
53
- | `data-mc-skew` | `null` | Transforms the component by tilting it along the Y axis (it is acceptable to use a positive or negative value). |
54
- | `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). |
55
- | `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). |
53
+ | data- | Default | Description |
54
+ |:--------------------|:-------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
55
+ | `data-mc-duration` | `20` | Sets the duration of content scrolling in seconds. It is acceptable to use decimals. |
56
+ | `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. |
57
+ | `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
+ | `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
+ | `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). |
56
60
 
57
61
  <br>
58
62
 
59
- ### License
60
- Marquee-content is released under MIT license.
63
+ &#10148; **License**
64
+
65
+ marquee-content is released under MIT license.
package/dist/index.js CHANGED
@@ -13,7 +13,9 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
13
13
  super();
14
14
  this.gsap = $4fa36e821943b400$export$2e2bcd8739ae039.gsap || window.gsap;
15
15
  this.MM = this.gsap.matchMedia();
16
- this.breakpoint = this.dataset.mcMax ? `(max-width: ${this.dataset.mcMax - 0.02}px)` : this.dataset.mcMin ? `(min-width: ${this.dataset.mcMin}px)` : "";
16
+ this.breakpoint = "";
17
+ if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
18
+ else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
17
19
  this.update = this.update.bind(this);
18
20
  this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150));
19
21
  this.resizeObserver.observe(this);
@@ -22,10 +24,10 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
22
24
  $4fa36e821943b400$export$2e2bcd8739ae039.gsap = gsap;
23
25
  }
24
26
  debounce(fn, delay) {
25
- let timer;
27
+ this.timer = null;
26
28
  return (...args)=>{
27
- if (timer) clearTimeout(timer);
28
- timer = setTimeout(()=>fn(...args), delay);
29
+ if (this.timer) clearTimeout(this.timer);
30
+ this.timer = setTimeout(()=>fn(...args), delay);
29
31
  };
30
32
  }
31
33
  templates() {
@@ -45,10 +47,10 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
45
47
  };
46
48
  removingClones();
47
49
  this.MM.add(this.breakpoint, ()=>{
48
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
49
- if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
50
- let cloned = this.firstElementChild;
51
- let clone = cloned.cloneNode(true);
50
+ const requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
51
+ if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i += 1){
52
+ const cloned = this.firstElementChild;
53
+ const clone = cloned.cloneNode(true);
52
54
  cloned.parentNode.append(clone);
53
55
  }
54
56
  return ()=>{
@@ -58,8 +60,8 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
58
60
  }
59
61
  skewed() {
60
62
  if (!this.dataset.mcSkew) return;
61
- const abs = Math.abs(parseInt(this.dataset.mcSkew));
62
- const style = this.style;
63
+ const abs = Math.abs(parseInt(this.dataset.mcSkew, 10));
64
+ const { style: style } = this;
63
65
  this.MM.add(this.breakpoint, ()=>{
64
66
  style.transformOrigin = "center center";
65
67
  style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
@@ -70,16 +72,10 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
70
72
  });
71
73
  }
72
74
  animation() {
73
- let timeLine = this.gsap.timeline();
74
- timeLine.kill();
75
- timeLine = null;
76
75
  this.gsap.set(this.children, {
77
76
  clearProps: true
78
77
  });
79
78
  this.MM.add(this.breakpoint, ()=>{
80
- this.gsap.set(this.children, {
81
- "will-change": "transform"
82
- });
83
79
  const tween = this.gsap.to(this.children, {
84
80
  duration: this.dataset.mcDuration || 20,
85
81
  x: "-100%",
@@ -99,9 +95,10 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
99
95
  });
100
96
  };
101
97
  const autoDirection = ()=>{
102
- let currentScroll = 0, scrollDirection = 1;
98
+ let currentScroll = 0;
99
+ let scrollDirection = 1;
103
100
  const handleScroll = ()=>{
104
- let orientation = window.pageYOffset > currentScroll ? 1 : -1;
101
+ const orientation = window.scrollY > currentScroll ? 1 : -1;
105
102
  if (orientation !== scrollDirection) {
106
103
  this.gsap.to(tween, {
107
104
  timeScale: orientation,
@@ -109,16 +106,15 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
109
106
  });
110
107
  scrollDirection = orientation;
111
108
  }
112
- currentScroll = window.pageYOffset;
109
+ currentScroll = window.scrollY;
113
110
  };
114
- addEventListener("scroll", ()=>{
115
- handleScroll();
116
- }, {
111
+ window.addEventListener("scroll", handleScroll, {
117
112
  capture: true,
118
113
  passive: true
119
114
  });
120
115
  };
121
- this.dataset.mcDirection === "ltr" ? ltrDirection() : this.dataset.mcDirection === "auto" && autoDirection();
116
+ if (this.dataset.mcDirection === "ltr") ltrDirection();
117
+ else if (this.dataset.mcDirection === "auto") autoDirection();
122
118
  return ()=>{
123
119
  this.gsap.set(this.children, {
124
120
  clearProps: true
@@ -133,17 +129,20 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
133
129
  this.animation();
134
130
  });
135
131
  }
136
- connectedCallback() {
132
+ init() {
137
133
  this.templates();
138
134
  this.skewed();
139
135
  this.cloning();
140
136
  this.animation();
141
137
  }
138
+ connectedCallback() {
139
+ this.init();
140
+ }
142
141
  disconnectedCallback() {
143
142
  cancelAnimationFrame(this.af);
144
143
  }
145
144
  }
146
- customElements.get("marquee-content") || customElements.define("marquee-content", $4fa36e821943b400$export$2e2bcd8739ae039);
145
+ if (!customElements.get("marquee-content")) customElements.define("marquee-content", $4fa36e821943b400$export$2e2bcd8739ae039);
147
146
 
148
147
 
149
148
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QA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ChB,kBAAkB;gBAEtB,MAAM,eAAe;oBACjB,IAAI,cAAc,AAAC,OAAO,cAAc,gBAAiB,IAAI;oBAE7D,IAAI,gBAAgB,iBAAiB;wBACjC,IAAI,CAAC,KAAK,GAAG,OAAO;4BAChB,WAAW;4BACX,WAAW;wBACf;wBAEA,kBAAkB;oBACtB;oBAEA,gBAAgB,OAAO;gBAC3B;gBAEA,iBAAiB,UAAU;oBACvB;gBACJ,GAAG;oBAAE,SAAS;oBAAM,SAAS;gBAAK;YACtC;YAEA,IAAI,CAAC,QAAQ,gBAAgB,QAAQ,iBACjC,IAAI,CAAC,QAAQ,gBAAgB,UAAS;YAG1C,OAAO;gBACH,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU;oBAAE,YAAY;gBAAK;YACpD;QACJ;IACJ;IAEA,SAAS;QACL,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,mBACL,IAAI,CAAC,KAAK,sBAAsB;YAC5B,IAAI,CAAC;YACL,IAAI,CAAC;QACT;IAER;IAEA,oBAAoB;QAChB,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;IAC9B;AACJ;AAEA,eAAe,IAAI,sBAAsB,eAAe,OAAO,mBAAmB","sources":["src/index.js"],"sourcesContent":["export 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.breakpoint = this.dataset.mcMax\n ? `(max-width: ${this.dataset.mcMax - 0.02}px)`\n : this.dataset.mcMin\n ? `(min-width: ${this.dataset.mcMin}px)`\n : ''\n\n this.update = this.update.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n debounce(fn, delay) {\n let timer\n\n return (...args) => {\n if (timer) clearTimeout(timer)\n timer = setTimeout(() => fn(...args), delay)\n }\n }\n\n templates() {\n const wrapper = document.createElement('div')\n wrapper.classList.add('marquee-wrapper')\n\n const inner = document.createElement('div')\n inner.classList.add('marquee-inner')\n inner.style.display = 'inline-block'\n inner.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n inner.appendChild(this.firstChild)\n }\n\n wrapper.appendChild(inner)\n this.appendChild(wrapper)\n }\n\n 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 let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)\n\n if (this.childElementCount < requiredQuantity) {\n for (let i = 1; i < requiredQuantity; i++) {\n let cloned = this.firstElementChild\n let clone = cloned.cloneNode(true)\n cloned.parentNode.append(clone)\n }\n }\n\n return () => {\n removingClones()\n }\n })\n }\n\n skewed() {\n if (!this.dataset.mcSkew) return\n\n const abs = Math.abs(parseInt(this.dataset.mcSkew))\n const style = this.style\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\n animation() {\n let timeLine = this.gsap.timeline()\n\n timeLine.kill()\n timeLine = null\n\n this.gsap.set(this.children, { clearProps: true })\n\n this.MM.add(this.breakpoint, () => {\n this.gsap.set(this.children, { 'will-change': 'transform' })\n\n const tween = this.gsap.to(this.children, {\n duration: this.dataset.mcDuration || 20,\n x: '-100%',\n ease: 'none',\n repeat: -1,\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause'\n },\n }).totalProgress(0.5)\n\n const ltrDirection = () => {\n this.gsap.to(tween, {\n timeScale: -1,\n overwrite: true\n })\n }\n\n const autoDirection = () => {\n let currentScroll = 0,\n scrollDirection = 1\n\n const handleScroll = () => {\n let orientation = (window.pageYOffset > currentScroll) ? 1 : -1\n\n if (orientation !== scrollDirection) {\n this.gsap.to(tween, {\n timeScale: orientation,\n overwrite: true\n })\n\n scrollDirection = orientation\n }\n\n currentScroll = window.pageYOffset\n }\n\n addEventListener('scroll', () => {\n handleScroll()\n }, { capture: true, passive: true })\n }\n\n this.dataset.mcDirection === 'ltr' ? ltrDirection() :\n this.dataset.mcDirection === 'auto' ? autoDirection() :\n null\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n })\n }\n\n update() {\n cancelAnimationFrame(this.af)\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n }\n\n connectedCallback() {\n this.templates()\n this.skewed()\n this.cloning()\n this.animation()\n }\n\n disconnectedCallback() {\n cancelAnimationFrame(this.af)\n }\n}\n\ncustomElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,OAAO,yCAAe,QAAQ,OAAO;QAC1C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK;QACpB,IAAI,CAAC,aAAa;QAElB,IAAI,IAAI,CAAC,QAAQ,OACb,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,QAAQ,KAAK,GAAG,CAAC;aAC5D,IAAI,IAAI,CAAC,QAAQ,OACpB,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,MAAM,GAAG,CAAC;QAG5D,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,KAAK,IAAI;QACnC,IAAI,CAAC,iBAAiB,IAAI,eAAe,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,KAAK,IAAI,GAAG;QAC/E,IAAI,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J;IAEA,SAAS;QACL,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,mBACL,IAAI,CAAC,KAAK,sBAAsB;YAC5B,IAAI,CAAC;YACL,IAAI,CAAC;QACT;IAER;IAEA,OAAO;QACH,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,oBAAoB;QAChB,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;IAC9B;AACJ;AAEA,IAAI,CAAC,eAAe,IAAI,oBACpB,eAAe,OAAO,mBAAmB","sources":["src/index.js"],"sourcesContent":["export 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.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 this.update = this.update.bind(this);\n this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150));\n this.resizeObserver.observe(this);\n }\n\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap;\n }\n\n debounce(fn, delay) {\n this.timer = null;\n\n return (...args) => {\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => fn(...args), delay);\n };\n }\n\n templates() {\n const wrapper = document.createElement('div');\n wrapper.classList.add('marquee-wrapper');\n\n const inner = document.createElement('div');\n inner.classList.add('marquee-inner');\n inner.style.display = 'inline-block';\n inner.style.whiteSpace = 'nowrap';\n\n while (this.firstChild) {\n inner.appendChild(this.firstChild);\n }\n\n wrapper.appendChild(inner);\n this.appendChild(wrapper);\n }\n\n 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 for (let i = 1; i < requiredQuantity; i += 1) {\n const cloned = this.firstElementChild;\n const clone = cloned.cloneNode(true);\n cloned.parentNode.append(clone);\n }\n }\n\n return () => {\n removingClones();\n };\n });\n }\n\n 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\n animation() {\n this.gsap.set(this.children, { clearProps: true });\n\n this.MM.add(this.breakpoint, () => {\n const tween = this.gsap.to(this.children, {\n duration: this.dataset.mcDuration || 20,\n x: '-100%',\n ease: 'none',\n repeat: -1,\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause',\n },\n }).totalProgress(0.5);\n\n const ltrDirection = () => {\n this.gsap.to(tween, {\n timeScale: -1,\n overwrite: true,\n });\n };\n\n const autoDirection = () => {\n let currentScroll = 0;\n let scrollDirection = 1;\n\n const handleScroll = () => {\n const orientation = (window.scrollY > currentScroll) ? 1 : -1;\n\n if (orientation !== scrollDirection) {\n this.gsap.to(tween, {\n timeScale: orientation,\n overwrite: true,\n });\n\n scrollDirection = orientation;\n }\n\n currentScroll = window.scrollY;\n };\n\n window.addEventListener('scroll', handleScroll, { capture: true, passive: true });\n };\n\n if (this.dataset.mcDirection === 'ltr') {\n ltrDirection();\n } else if (this.dataset.mcDirection === 'auto') {\n autoDirection();\n }\n\n return () => {\n this.gsap.set(this.children, {\n clearProps: true,\n });\n };\n });\n }\n\n update() {\n cancelAnimationFrame(this.af);\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n this.cloning();\n this.animation();\n });\n }\n }\n\n init() {\n this.templates();\n this.skewed();\n this.cloning();\n this.animation();\n }\n\n connectedCallback() {\n this.init();\n }\n\n disconnectedCallback() {\n cancelAnimationFrame(this.af);\n }\n}\n\nif (!customElements.get('marquee-content')) {\n customElements.define('marquee-content', MarqueeContent);\n}\n"],"names":[],"version":3,"file":"index.js.map"}
@@ -3,7 +3,9 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
3
3
  super();
4
4
  this.gsap = $cf838c15c8b009ba$export$2e2bcd8739ae039.gsap || window.gsap;
5
5
  this.MM = this.gsap.matchMedia();
6
- this.breakpoint = this.dataset.mcMax ? `(max-width: ${this.dataset.mcMax - 0.02}px)` : this.dataset.mcMin ? `(min-width: ${this.dataset.mcMin}px)` : "";
6
+ this.breakpoint = "";
7
+ if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
8
+ else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
7
9
  this.update = this.update.bind(this);
8
10
  this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150));
9
11
  this.resizeObserver.observe(this);
@@ -12,10 +14,10 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
12
14
  $cf838c15c8b009ba$export$2e2bcd8739ae039.gsap = gsap;
13
15
  }
14
16
  debounce(fn, delay) {
15
- let timer;
17
+ this.timer = null;
16
18
  return (...args)=>{
17
- if (timer) clearTimeout(timer);
18
- timer = setTimeout(()=>fn(...args), delay);
19
+ if (this.timer) clearTimeout(this.timer);
20
+ this.timer = setTimeout(()=>fn(...args), delay);
19
21
  };
20
22
  }
21
23
  templates() {
@@ -35,10 +37,10 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
35
37
  };
36
38
  removingClones();
37
39
  this.MM.add(this.breakpoint, ()=>{
38
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
39
- if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
40
- let cloned = this.firstElementChild;
41
- let clone = cloned.cloneNode(true);
40
+ const requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
41
+ if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i += 1){
42
+ const cloned = this.firstElementChild;
43
+ const clone = cloned.cloneNode(true);
42
44
  cloned.parentNode.append(clone);
43
45
  }
44
46
  return ()=>{
@@ -48,8 +50,8 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
48
50
  }
49
51
  skewed() {
50
52
  if (!this.dataset.mcSkew) return;
51
- const abs = Math.abs(parseInt(this.dataset.mcSkew));
52
- const style = this.style;
53
+ const abs = Math.abs(parseInt(this.dataset.mcSkew, 10));
54
+ const { style: style } = this;
53
55
  this.MM.add(this.breakpoint, ()=>{
54
56
  style.transformOrigin = "center center";
55
57
  style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
@@ -60,16 +62,10 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
60
62
  });
61
63
  }
62
64
  animation() {
63
- let timeLine = this.gsap.timeline();
64
- timeLine.kill();
65
- timeLine = null;
66
65
  this.gsap.set(this.children, {
67
66
  clearProps: true
68
67
  });
69
68
  this.MM.add(this.breakpoint, ()=>{
70
- this.gsap.set(this.children, {
71
- "will-change": "transform"
72
- });
73
69
  const tween = this.gsap.to(this.children, {
74
70
  duration: this.dataset.mcDuration || 20,
75
71
  x: "-100%",
@@ -89,9 +85,10 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
89
85
  });
90
86
  };
91
87
  const autoDirection = ()=>{
92
- let currentScroll = 0, scrollDirection = 1;
88
+ let currentScroll = 0;
89
+ let scrollDirection = 1;
93
90
  const handleScroll = ()=>{
94
- let orientation = window.pageYOffset > currentScroll ? 1 : -1;
91
+ const orientation = window.scrollY > currentScroll ? 1 : -1;
95
92
  if (orientation !== scrollDirection) {
96
93
  this.gsap.to(tween, {
97
94
  timeScale: orientation,
@@ -99,16 +96,15 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
99
96
  });
100
97
  scrollDirection = orientation;
101
98
  }
102
- currentScroll = window.pageYOffset;
99
+ currentScroll = window.scrollY;
103
100
  };
104
- addEventListener("scroll", ()=>{
105
- handleScroll();
106
- }, {
101
+ window.addEventListener("scroll", handleScroll, {
107
102
  capture: true,
108
103
  passive: true
109
104
  });
110
105
  };
111
- this.dataset.mcDirection === "ltr" ? ltrDirection() : this.dataset.mcDirection === "auto" && autoDirection();
106
+ if (this.dataset.mcDirection === "ltr") ltrDirection();
107
+ else if (this.dataset.mcDirection === "auto") autoDirection();
112
108
  return ()=>{
113
109
  this.gsap.set(this.children, {
114
110
  clearProps: true
@@ -123,17 +119,20 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
123
119
  this.animation();
124
120
  });
125
121
  }
126
- connectedCallback() {
122
+ init() {
127
123
  this.templates();
128
124
  this.skewed();
129
125
  this.cloning();
130
126
  this.animation();
131
127
  }
128
+ connectedCallback() {
129
+ this.init();
130
+ }
132
131
  disconnectedCallback() {
133
132
  cancelAnimationFrame(this.af);
134
133
  }
135
134
  }
136
- customElements.get("marquee-content") || customElements.define("marquee-content", $cf838c15c8b009ba$export$2e2bcd8739ae039);
135
+ if (!customElements.get("marquee-content")) customElements.define("marquee-content", $cf838c15c8b009ba$export$2e2bcd8739ae039);
137
136
 
138
137
 
139
138
  export {$cf838c15c8b009ba$export$2e2bcd8739ae039 as default};
@@ -1 +1 @@
1
- {"mappings":"AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,OAAO,yCAAe,QAAQ,OAAO;QAC1C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK;QACpB,IAAI,CAAC,aAAa,IAAI,CAAC,QAAQ,QACzB,CAAC,YAAY,EAAE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;4BAChB,WAAW;4BACX,WAAW;wBACf;wBAEA,kBAAkB;oBACtB;oBAEA,gBAAgB,OAAO;gBAC3B;gBAEA,iBAAiB,UAAU;oBACvB;gBACJ,GAAG;oBAAE,SAAS;oBAAM,SAAS;gBAAK;YACtC;YAEA,IAAI,CAAC,QAAQ,gBAAgB,QAAQ,iBACjC,IAAI,CAAC,QAAQ,gBAAgB,UAAS;YAG1C,OAAO;gBACH,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU;oBAAE,YAAY;gBAAK;YACpD;QACJ;IACJ;IAEA,SAAS;QACL,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,mBACL,IAAI,CAAC,KAAK,sBAAsB;YAC5B,IAAI,CAAC;YACL,IAAI,CAAC;QACT;IAER;IAEA,oBAAoB;QAChB,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;IAC9B;AACJ;AAEA,eAAe,IAAI,sBAAsB,eAAe,OAAO,mBAAmB","sources":["src/index.js"],"sourcesContent":["export 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.breakpoint = this.dataset.mcMax\n ? `(max-width: ${this.dataset.mcMax - 0.02}px)`\n : this.dataset.mcMin\n ? `(min-width: ${this.dataset.mcMin}px)`\n : ''\n\n this.update = this.update.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n debounce(fn, delay) {\n let timer\n\n return (...args) => {\n if (timer) clearTimeout(timer)\n timer = setTimeout(() => fn(...args), delay)\n }\n }\n\n templates() {\n const wrapper = document.createElement('div')\n wrapper.classList.add('marquee-wrapper')\n\n const inner = document.createElement('div')\n inner.classList.add('marquee-inner')\n inner.style.display = 'inline-block'\n inner.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n inner.appendChild(this.firstChild)\n }\n\n wrapper.appendChild(inner)\n this.appendChild(wrapper)\n }\n\n 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 let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)\n\n if (this.childElementCount < requiredQuantity) {\n for (let i = 1; i < requiredQuantity; i++) {\n let cloned = this.firstElementChild\n let clone = cloned.cloneNode(true)\n cloned.parentNode.append(clone)\n }\n }\n\n return () => {\n removingClones()\n }\n })\n }\n\n skewed() {\n if (!this.dataset.mcSkew) return\n\n const abs = Math.abs(parseInt(this.dataset.mcSkew))\n const style = this.style\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\n animation() {\n let timeLine = this.gsap.timeline()\n\n timeLine.kill()\n timeLine = null\n\n this.gsap.set(this.children, { clearProps: true })\n\n this.MM.add(this.breakpoint, () => {\n this.gsap.set(this.children, { 'will-change': 'transform' })\n\n const tween = this.gsap.to(this.children, {\n duration: this.dataset.mcDuration || 20,\n x: '-100%',\n ease: 'none',\n repeat: -1,\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause'\n },\n }).totalProgress(0.5)\n\n const ltrDirection = () => {\n this.gsap.to(tween, {\n timeScale: -1,\n overwrite: true\n })\n }\n\n const autoDirection = () => {\n let currentScroll = 0,\n scrollDirection = 1\n\n const handleScroll = () => {\n let orientation = (window.pageYOffset > currentScroll) ? 1 : -1\n\n if (orientation !== scrollDirection) {\n this.gsap.to(tween, {\n timeScale: orientation,\n overwrite: true\n })\n\n scrollDirection = orientation\n }\n\n currentScroll = window.pageYOffset\n }\n\n addEventListener('scroll', () => {\n handleScroll()\n }, { capture: true, passive: true })\n }\n\n this.dataset.mcDirection === 'ltr' ? ltrDirection() :\n this.dataset.mcDirection === 'auto' ? autoDirection() :\n null\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n })\n }\n\n update() {\n cancelAnimationFrame(this.af)\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n }\n\n connectedCallback() {\n this.templates()\n this.skewed()\n this.cloning()\n this.animation()\n }\n\n disconnectedCallback() {\n cancelAnimationFrame(this.af)\n }\n}\n\ncustomElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":"AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,OAAO,yCAAe,QAAQ,OAAO;QAC1C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK;QACpB,IAAI,CAAC,aAAa;QAElB,IAAI,IAAI,CAAC,QAAQ,OACb,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,QAAQ,KAAK,GAAG,CAAC;aAC5D,IAAI,IAAI,CAAC,QAAQ,OACpB,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,MAAM,GAAG,CAAC;QAG5D,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,KAAK,IAAI;QACnC,IAAI,CAAC,iBAAiB,IAAI,eAAe,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,KAAK,IAAI,GAAG;QAC/E,IAAI,CAAC,eAAe,QAAQ,IAAI;IACpC;IAEA,OAAO,aAAa,IAAI,EAAE;QACtB,yCAAe,OAAO;IAC1B;IAEA,SAAS,EAAE,EAAE,KAAK,EAAE;QAChB,IAAI,CAAC,QAAQ;QAEb,OAAO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,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,oBAAoB;QAChB,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;IAC9B;AACJ;AAEA,IAAI,CAAC,eAAe,IAAI,oBACpB,eAAe,OAAO,mBAAmB","sources":["src/index.js"],"sourcesContent":["export 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.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 this.update = this.update.bind(this);\n this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150));\n this.resizeObserver.observe(this);\n }\n\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap;\n }\n\n debounce(fn, delay) {\n this.timer = null;\n\n return (...args) => {\n if (this.timer) clearTimeout(this.timer);\n this.timer = setTimeout(() => fn(...args), delay);\n };\n }\n\n templates() {\n const wrapper = document.createElement('div');\n wrapper.classList.add('marquee-wrapper');\n\n const inner = document.createElement('div');\n inner.classList.add('marquee-inner');\n inner.style.display = 'inline-block';\n inner.style.whiteSpace = 'nowrap';\n\n while (this.firstChild) {\n inner.appendChild(this.firstChild);\n }\n\n wrapper.appendChild(inner);\n this.appendChild(wrapper);\n }\n\n 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 for (let i = 1; i < requiredQuantity; i += 1) {\n const cloned = this.firstElementChild;\n const clone = cloned.cloneNode(true);\n cloned.parentNode.append(clone);\n }\n }\n\n return () => {\n removingClones();\n };\n });\n }\n\n 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\n animation() {\n this.gsap.set(this.children, { clearProps: true });\n\n this.MM.add(this.breakpoint, () => {\n const tween = this.gsap.to(this.children, {\n duration: this.dataset.mcDuration || 20,\n x: '-100%',\n ease: 'none',\n repeat: -1,\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause',\n },\n }).totalProgress(0.5);\n\n const ltrDirection = () => {\n this.gsap.to(tween, {\n timeScale: -1,\n overwrite: true,\n });\n };\n\n const autoDirection = () => {\n let currentScroll = 0;\n let scrollDirection = 1;\n\n const handleScroll = () => {\n const orientation = (window.scrollY > currentScroll) ? 1 : -1;\n\n if (orientation !== scrollDirection) {\n this.gsap.to(tween, {\n timeScale: orientation,\n overwrite: true,\n });\n\n scrollDirection = orientation;\n }\n\n currentScroll = window.scrollY;\n };\n\n window.addEventListener('scroll', handleScroll, { capture: true, passive: true });\n };\n\n if (this.dataset.mcDirection === 'ltr') {\n ltrDirection();\n } else if (this.dataset.mcDirection === 'auto') {\n autoDirection();\n }\n\n return () => {\n this.gsap.set(this.children, {\n clearProps: true,\n });\n };\n });\n }\n\n update() {\n cancelAnimationFrame(this.af);\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n this.cloning();\n this.animation();\n });\n }\n }\n\n init() {\n this.templates();\n this.skewed();\n this.cloning();\n this.animation();\n }\n\n connectedCallback() {\n this.init();\n }\n\n disconnectedCallback() {\n cancelAnimationFrame(this.af);\n }\n}\n\nif (!customElements.get('marquee-content')) {\n customElements.define('marquee-content', MarqueeContent);\n}\n"],"names":[],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "marquee-content",
3
- "version": "2.1.1",
4
- "description": "Infinite marquee animation with GSAP",
3
+ "version": "2.2.0",
4
+ "description": "Class for creating the running content effect, also known as a marquee or ticker.",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "clean": "rm -rf dist .parcel-cache"
21
21
  },
22
22
  "devDependencies": {
23
- "parcel": "~2.9.2"
23
+ "parcel": "~2.9.3"
24
24
  },
25
25
  "keywords": [
26
26
  "marquee",
package/src/index.js CHANGED
@@ -1,104 +1,99 @@
1
1
  export default class MarqueeContent extends HTMLElement {
2
2
  constructor() {
3
- super()
4
-
5
- this.gsap = MarqueeContent.gsap || window.gsap
6
- this.MM = this.gsap.matchMedia()
7
- this.breakpoint = this.dataset.mcMax
8
- ? `(max-width: ${this.dataset.mcMax - 0.02}px)`
9
- : this.dataset.mcMin
10
- ? `(min-width: ${this.dataset.mcMin}px)`
11
- : ''
12
-
13
- this.update = this.update.bind(this)
14
- this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150))
15
- this.resizeObserver.observe(this)
3
+ super();
4
+
5
+ this.gsap = MarqueeContent.gsap || window.gsap;
6
+ this.MM = this.gsap.matchMedia();
7
+ this.breakpoint = '';
8
+
9
+ if (this.dataset.mcMax) {
10
+ this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
11
+ } else if (this.dataset.mcMin) {
12
+ this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
13
+ }
14
+
15
+ this.update = this.update.bind(this);
16
+ this.resizeObserver = new ResizeObserver(this.debounce(this.update.bind(this), 150));
17
+ this.resizeObserver.observe(this);
16
18
  }
17
19
 
18
20
  static registerGSAP(gsap) {
19
- MarqueeContent.gsap = gsap
21
+ MarqueeContent.gsap = gsap;
20
22
  }
21
23
 
22
24
  debounce(fn, delay) {
23
- let timer
25
+ this.timer = null;
24
26
 
25
27
  return (...args) => {
26
- if (timer) clearTimeout(timer)
27
- timer = setTimeout(() => fn(...args), delay)
28
- }
28
+ if (this.timer) clearTimeout(this.timer);
29
+ this.timer = setTimeout(() => fn(...args), delay);
30
+ };
29
31
  }
30
32
 
31
33
  templates() {
32
- const wrapper = document.createElement('div')
33
- wrapper.classList.add('marquee-wrapper')
34
+ const wrapper = document.createElement('div');
35
+ wrapper.classList.add('marquee-wrapper');
34
36
 
35
- const inner = document.createElement('div')
36
- inner.classList.add('marquee-inner')
37
- inner.style.display = 'inline-block'
38
- inner.style.whiteSpace = 'nowrap'
37
+ const inner = document.createElement('div');
38
+ inner.classList.add('marquee-inner');
39
+ inner.style.display = 'inline-block';
40
+ inner.style.whiteSpace = 'nowrap';
39
41
 
40
42
  while (this.firstChild) {
41
- inner.appendChild(this.firstChild)
43
+ inner.appendChild(this.firstChild);
42
44
  }
43
45
 
44
- wrapper.appendChild(inner)
45
- this.appendChild(wrapper)
46
+ wrapper.appendChild(inner);
47
+ this.appendChild(wrapper);
46
48
  }
47
49
 
48
50
  cloning() {
49
51
  const removingClones = () => {
50
52
  while (this.childElementCount > 1) {
51
- this.removeChild(this.lastChild)
53
+ this.removeChild(this.lastChild);
52
54
  }
53
- }
55
+ };
54
56
 
55
- removingClones()
57
+ removingClones();
56
58
 
57
59
  this.MM.add(this.breakpoint, () => {
58
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
60
+ const requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
59
61
 
60
62
  if (this.childElementCount < requiredQuantity) {
61
- for (let i = 1; i < requiredQuantity; i++) {
62
- let cloned = this.firstElementChild
63
- let clone = cloned.cloneNode(true)
64
- cloned.parentNode.append(clone)
63
+ for (let i = 1; i < requiredQuantity; i += 1) {
64
+ const cloned = this.firstElementChild;
65
+ const clone = cloned.cloneNode(true);
66
+ cloned.parentNode.append(clone);
65
67
  }
66
68
  }
67
69
 
68
70
  return () => {
69
- removingClones()
70
- }
71
- })
71
+ removingClones();
72
+ };
73
+ });
72
74
  }
73
75
 
74
76
  skewed() {
75
- if (!this.dataset.mcSkew) return
77
+ if (!this.dataset.mcSkew) return;
76
78
 
77
- const abs = Math.abs(parseInt(this.dataset.mcSkew))
78
- const style = this.style
79
+ const abs = Math.abs(parseInt(this.dataset.mcSkew, 10));
80
+ const { style } = this;
79
81
 
80
82
  this.MM.add(this.breakpoint, () => {
81
- style.transformOrigin = 'center center'
82
- style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`
83
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
83
+ style.transformOrigin = 'center center';
84
+ style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
85
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
84
86
 
85
87
  return () => {
86
- style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
87
- }
88
- })
88
+ style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;';
89
+ };
90
+ });
89
91
  }
90
92
 
91
93
  animation() {
92
- let timeLine = this.gsap.timeline()
93
-
94
- timeLine.kill()
95
- timeLine = null
96
-
97
- this.gsap.set(this.children, { clearProps: true })
94
+ this.gsap.set(this.children, { clearProps: true });
98
95
 
99
96
  this.MM.add(this.breakpoint, () => {
100
- this.gsap.set(this.children, { 'will-change': 'transform' })
101
-
102
97
  const tween = this.gsap.to(this.children, {
103
98
  duration: this.dataset.mcDuration || 20,
104
99
  x: '-100%',
@@ -108,72 +103,80 @@ export default class MarqueeContent extends HTMLElement {
108
103
  trigger: this,
109
104
  start: '-=50% bottom',
110
105
  end: 'bottom top',
111
- toggleActions: 'resume pause resume pause'
106
+ toggleActions: 'resume pause resume pause',
112
107
  },
113
- }).totalProgress(0.5)
108
+ }).totalProgress(0.5);
114
109
 
115
110
  const ltrDirection = () => {
116
111
  this.gsap.to(tween, {
117
112
  timeScale: -1,
118
- overwrite: true
119
- })
120
- }
113
+ overwrite: true,
114
+ });
115
+ };
121
116
 
122
117
  const autoDirection = () => {
123
- let currentScroll = 0,
124
- scrollDirection = 1
118
+ let currentScroll = 0;
119
+ let scrollDirection = 1;
125
120
 
126
121
  const handleScroll = () => {
127
- let orientation = (window.pageYOffset > currentScroll) ? 1 : -1
122
+ const orientation = (window.scrollY > currentScroll) ? 1 : -1;
128
123
 
129
124
  if (orientation !== scrollDirection) {
130
125
  this.gsap.to(tween, {
131
126
  timeScale: orientation,
132
- overwrite: true
133
- })
127
+ overwrite: true,
128
+ });
134
129
 
135
- scrollDirection = orientation
130
+ scrollDirection = orientation;
136
131
  }
137
132
 
138
- currentScroll = window.pageYOffset
139
- }
133
+ currentScroll = window.scrollY;
134
+ };
140
135
 
141
- addEventListener('scroll', () => {
142
- handleScroll()
143
- }, { capture: true, passive: true })
144
- }
136
+ window.addEventListener('scroll', handleScroll, { capture: true, passive: true });
137
+ };
145
138
 
146
- this.dataset.mcDirection === 'ltr' ? ltrDirection() :
147
- this.dataset.mcDirection === 'auto' ? autoDirection() :
148
- null
139
+ if (this.dataset.mcDirection === 'ltr') {
140
+ ltrDirection();
141
+ } else if (this.dataset.mcDirection === 'auto') {
142
+ autoDirection();
143
+ }
149
144
 
150
145
  return () => {
151
- this.gsap.set(this.children, { clearProps: true })
152
- }
153
- })
146
+ this.gsap.set(this.children, {
147
+ clearProps: true,
148
+ });
149
+ };
150
+ });
154
151
  }
155
152
 
156
153
  update() {
157
- cancelAnimationFrame(this.af)
154
+ cancelAnimationFrame(this.af);
158
155
 
159
156
  if (this.firstElementChild) {
160
157
  this.af = requestAnimationFrame(() => {
161
- this.cloning()
162
- this.animation()
163
- })
158
+ this.cloning();
159
+ this.animation();
160
+ });
164
161
  }
165
162
  }
166
163
 
164
+ init() {
165
+ this.templates();
166
+ this.skewed();
167
+ this.cloning();
168
+ this.animation();
169
+ }
170
+
167
171
  connectedCallback() {
168
- this.templates()
169
- this.skewed()
170
- this.cloning()
171
- this.animation()
172
+ this.init();
172
173
  }
173
174
 
174
175
  disconnectedCallback() {
175
- cancelAnimationFrame(this.af)
176
+ cancelAnimationFrame(this.af);
176
177
  }
177
178
  }
178
179
 
179
- customElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)
180
+ if (!customElements.get('marquee-content')) {
181
+ customElements.define('marquee-content', MarqueeContent);
182
+ }