marquee-content 1.9.5 → 1.9.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/dist/index.js CHANGED
@@ -1,17 +1,27 @@
1
- class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
1
+ function $parcel$defineInteropFlag(a) {
2
+ Object.defineProperty(a, '__esModule', {value: true, configurable: true});
3
+ }
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$defineInteropFlag(module.exports);
9
+
10
+ $parcel$export(module.exports, "default", () => $4fa36e821943b400$export$2e2bcd8739ae039);
11
+ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
2
12
  static registerGSAP(gsap) {
3
- $4fa36e821943b400$var$MarqueeContent.gsap = gsap;
13
+ $4fa36e821943b400$export$2e2bcd8739ae039.gsap = gsap;
4
14
  }
5
15
  constructor(query){
6
16
  super();
7
- this.gsap = $4fa36e821943b400$var$MarqueeContent.gsap || window.gsap;
17
+ this.gsap = $4fa36e821943b400$export$2e2bcd8739ae039.gsap || window.gsap;
18
+ this.MM = this.gsap.matchMedia(query);
8
19
  this.dataSkew = this.dataset.mcSkew;
9
20
  this.dataDuration = this.dataset.mcDuration || 20;
10
21
  this.dataDirection = this.dataset.mcDirection;
11
22
  this.dataMaxWidth = this.dataset.mcMax;
12
23
  this.dataMinWidth = this.dataset.mcMin;
13
24
  this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
14
- this.debounce();
15
25
  }
16
26
  debounce(fn, delay) {
17
27
  let timer;
@@ -32,30 +42,30 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
32
42
  while(this.childElementCount > 1)this.removeChild(this.lastChild);
33
43
  };
34
44
  removingClones();
35
- // gsap.matchMedia().add(this.breakpoint, () => {
36
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
37
- if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
38
- let cloned = this.firstElementChild;
39
- let clone = cloned.cloneNode(true);
40
- cloned.parentNode.append(clone);
41
- }
42
- return ()=>{
43
- removingClones();
44
- };
45
- // })
45
+ this.MM.add(this.breakpoint, ()=>{
46
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
47
+ if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
48
+ let cloned = this.firstElementChild;
49
+ let clone = cloned.cloneNode(true);
50
+ cloned.parentNode.append(clone);
51
+ }
52
+ return ()=>{
53
+ removingClones();
54
+ };
55
+ });
46
56
  }
47
57
  skewed() {
48
58
  if (!this.dataSkew) return;
49
59
  const abs = Math.abs(parseInt(this.dataSkew));
50
60
  const style = this.style;
51
- // gsap.matchMedia().add(this.breakpoint, () => {
52
- style.transformOrigin = "center center";
53
- style.transform = `skew(0deg, ${this.dataSkew}deg)`;
54
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
55
- return ()=>{
56
- style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
57
- };
58
- // })
61
+ this.MM.add(this.breakpoint, ()=>{
62
+ style.transformOrigin = "center center";
63
+ style.transform = `skew(0deg, ${this.dataSkew}deg)`;
64
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
65
+ return ()=>{
66
+ style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
67
+ };
68
+ });
59
69
  }
60
70
  animation() {
61
71
  let timeLine = this.gsap.timeline();
@@ -64,57 +74,57 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
64
74
  this.gsap.set(this.children, {
65
75
  clearProps: true
66
76
  });
67
- // gsap.matchMedia().add(this.breakpoint, () => {
68
- this.gsap.set(this.children, {
69
- "will-change": "transform"
70
- });
71
- const tween = this.gsap.to(this.children, {
72
- duration: this.dataDuration,
73
- x: "-100%",
74
- ease: "none",
75
- repeat: -1,
76
- scrollTrigger: {
77
- trigger: this,
78
- start: "-=50% bottom",
79
- end: "bottom top",
80
- toggleActions: "resume pause resume pause"
81
- }
82
- }).totalProgress(0.5);
83
- const ltrDirection = ()=>{
84
- this.gsap.to(tween, {
85
- timeScale: -1,
86
- overwrite: true
77
+ this.MM.add(this.breakpoint, ()=>{
78
+ this.gsap.set(this.children, {
79
+ "will-change": "transform"
87
80
  });
88
- };
89
- const autoDirection = ()=>{
90
- let previousScrollPosition = 0;
91
- const isScrollingDown = ()=>{
92
- const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
93
- let direction = false;
94
- if (scrollPosition > previousScrollPosition) direction = true;
95
- else if (scrollPosition < previousScrollPosition) direction = false;
96
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
97
- return direction;
98
- };
99
- addEventListener("scroll", this.debounce(()=>{
100
- const scrollDirection = isScrollingDown();
81
+ const tween = this.gsap.to(this.children, {
82
+ duration: this.dataDuration,
83
+ x: "-100%",
84
+ ease: "none",
85
+ repeat: -1,
86
+ scrollTrigger: {
87
+ trigger: this,
88
+ start: "-=50% bottom",
89
+ end: "bottom top",
90
+ toggleActions: "resume pause resume pause"
91
+ }
92
+ }).totalProgress(0.5);
93
+ const ltrDirection = ()=>{
101
94
  this.gsap.to(tween, {
102
- timeScale: scrollDirection ? 1 : -1,
95
+ timeScale: -1,
103
96
  overwrite: true
104
97
  });
105
- }, 50), {
106
- capture: true,
107
- passive: true
108
- });
109
- };
110
- if (this.dataDirection === "ltr") ltrDirection();
111
- else if (this.dataDirection === "auto") autoDirection();
112
- return ()=>{
113
- this.gsap.set(this.children, {
114
- clearProps: true
115
- });
116
- };
117
- // })
98
+ };
99
+ const autoDirection = ()=>{
100
+ let previousScrollPosition = 0;
101
+ const isScrollingDown = ()=>{
102
+ const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
103
+ let direction = false;
104
+ if (scrollPosition > previousScrollPosition) direction = true;
105
+ else if (scrollPosition < previousScrollPosition) direction = false;
106
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
107
+ return direction;
108
+ };
109
+ addEventListener("scroll", this.debounce(()=>{
110
+ const scrollDirection = isScrollingDown();
111
+ this.gsap.to(tween, {
112
+ timeScale: scrollDirection ? 1 : -1,
113
+ overwrite: true
114
+ });
115
+ }, 50), {
116
+ capture: true,
117
+ passive: true
118
+ });
119
+ };
120
+ if (this.dataDirection === "ltr") ltrDirection();
121
+ else if (this.dataDirection === "auto") autoDirection();
122
+ return ()=>{
123
+ this.gsap.set(this.children, {
124
+ clearProps: true
125
+ });
126
+ };
127
+ });
118
128
  }
119
129
  onResize() {
120
130
  cancelAnimationFrame(this.af);
@@ -136,11 +146,11 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
136
146
  this.onUpdate();
137
147
  }
138
148
  disconnectedCallback() {
139
- // gsap.matchMedia().remove()
149
+ this.MM.remove();
140
150
  document.fonts.removeEventListener("loadingdone", this.onUpdate);
141
151
  }
142
152
  }
143
- customElements.define("marquee-content", $4fa36e821943b400$var$MarqueeContent);
153
+ customElements.get("marquee-content") || customElements.define("marquee-content", $4fa36e821943b400$export$2e2bcd8739ae039);
144
154
 
145
155
 
146
156
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,YAAY,KAAK,CAAE;QACf,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,qCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,C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AAuB;QACnB,6BAA6B;QAE7B,SAAS,KAAK,CAAC,mBAAmB,CAAC,eAAe,IAAI,CAAC,QAAQ;IACnE;AACJ;AAEA,eAAe,MAAM,CAAC,mBAAmB","sources":["src/index.js"],"sourcesContent":["class MarqueeContent extends HTMLElement {\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n constructor(query) {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.dataSkew = this.dataset.mcSkew\n this.dataDuration = this.dataset.mcDuration || 20\n this.dataDirection = this.dataset.mcDirection\n this.dataMaxWidth = this.dataset.mcMax\n this.dataMinWidth = this.dataset.mcMin\n this.breakpoint = this.dataMaxWidth\n ? `(max-width: ${this.dataMaxWidth - 0.02}px)`\n : this.dataMinWidth\n ? `(min-width: ${this.dataMinWidth}px)`\n : ''\n this.debounce()\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 div = document.createElement('div')\n\n div.style.display = 'inline-block'\n div.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n div.appendChild(this.firstChild)\n }\n\n this.appendChild(div)\n }\n\n cloning() {\n const removingClones = () => {\n while (this.childElementCount > 1) {\n this.removeChild(this.lastChild)\n }\n }\n\n removingClones()\n\n // gsap.matchMedia().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.dataSkew) return\n\n const abs = Math.abs(parseInt(this.dataSkew))\n const style = this.style\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n style.transformOrigin = 'center center'\n style.transform = `skew(0deg, ${this.dataSkew}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 // gsap.matchMedia().add(this.breakpoint, () => {\n this.gsap.set(this.children, { 'will-change': 'transform' })\n\n const tween = this.gsap.to(this.children, {\n duration: this.dataDuration,\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 previousScrollPosition = 0\n\n const isScrollingDown = () => {\n const scrollPosition = window.pageYOffset || document.documentElement.scrollTop\n\n let direction = false\n\n if (scrollPosition > previousScrollPosition) {\n direction = true\n } else if (scrollPosition < previousScrollPosition) {\n direction = false\n }\n\n previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition\n\n return direction\n }\n\n addEventListener('scroll', this.debounce(() => {\n const scrollDirection = isScrollingDown()\n\n this.gsap.to(tween, {\n timeScale: scrollDirection ? 1 : -1,\n overwrite: true,\n })\n }, 50), {\n capture: true, passive: true\n })\n }\n\n if (this.dataDirection === 'ltr') {\n ltrDirection()\n } else if (this.dataDirection === 'auto') {\n autoDirection()\n }\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n // })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n\n onUpdate() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n\n this.onResize = this.onResize.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n connectedCallback() {\n this.onUpdate()\n }\n\n disconnectedCallback() {\n // gsap.matchMedia().remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAe,uDAA6B;IACxC,OAAO,aAAa,IAAI,EAAE;QACtB,yCAAe,IAAI,GAAG;IAC1B;IAEA,YAAY,KAAK,CAAE;QACf,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,yCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK;QACtC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,GAC7B,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,GAAG,KAAK,GAAG,CAAC,GAC5C,IAAI,CAAC,YAAY,GACb,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GACrC,EAAE;IAChB;IAEA,SAAS,EAAE,EAAE,KAAK,EAAE;QAChB,IAAI;QAEJ,OAAO,CAAC,GAAG,OAAS;YAChB,IAAI,OAAO,aAAa;YACxB,QAAQ,WAAW,IAAM,MAAM,OAAO;QAC1C;IACJ;IAEA,YAAY;QACR,MAAM,MAAM,SAAS,aAAa,CAAC;QAEnC,IAAI,KAAK,CAAC,OAAO,GAAG;QACpB,IAAI,KAAK,CAAC,UAAU,GAAG;QAEvB,MAAO,IAAI,CAA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,KAAK,OACvB;iBACG,IAAI,IAAI,CAAC,aAAa,KAAK,QAC9B;YAGJ,OAAO,IAAM;gBACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAAE,YAAY,IAAI;gBAAC;YACpD;QACJ;IACJ;IAEA,WAAW;QACP,qBAAqB,IAAI,CAAC,EAAE;QAE5B,IAAI,CAAC,EAAE,GAAG,sBAAsB,IAAM;YAClC,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,SAAS;QAClB;IACJ;IAEA,WAAW;QACP,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,SAAS;QAEd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI;QACvC,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG;QACjF,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI;IACpC;IAEA,oBAAoB;QAChB,IAAI,CAAC,QAAQ;IACjB;IAEA,uBAAuB;QACnB,IAAI,CAAC,EAAE,CAAC,MAAM;QAEd,SAAS,KAAK,CAAC,mBAAmB,CAAC,eAAe,IAAI,CAAC,QAAQ;IACnE;AACJ;AAEA,eAAe,GAAG,CAAC,sBAAsB,eAAe,MAAM,CAAC,mBAAmB","sources":["src/index.js"],"sourcesContent":["export default class MarqueeContent extends HTMLElement {\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n constructor(query) {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.MM = this.gsap.matchMedia(query)\n this.dataSkew = this.dataset.mcSkew\n this.dataDuration = this.dataset.mcDuration || 20\n this.dataDirection = this.dataset.mcDirection\n this.dataMaxWidth = this.dataset.mcMax\n this.dataMinWidth = this.dataset.mcMin\n this.breakpoint = this.dataMaxWidth\n ? `(max-width: ${this.dataMaxWidth - 0.02}px)`\n : this.dataMinWidth\n ? `(min-width: ${this.dataMinWidth}px)`\n : ''\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 div = document.createElement('div')\n\n div.style.display = 'inline-block'\n div.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n div.appendChild(this.firstChild)\n }\n\n this.appendChild(div)\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.dataSkew) return\n\n const abs = Math.abs(parseInt(this.dataSkew))\n const style = this.style\n\n this.MM.add(this.breakpoint, () => {\n style.transformOrigin = 'center center'\n style.transform = `skew(0deg, ${this.dataSkew}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.dataDuration,\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 previousScrollPosition = 0\n\n const isScrollingDown = () => {\n const scrollPosition = window.pageYOffset || document.documentElement.scrollTop\n\n let direction = false\n\n if (scrollPosition > previousScrollPosition) {\n direction = true\n } else if (scrollPosition < previousScrollPosition) {\n direction = false\n }\n\n previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition\n\n return direction\n }\n\n addEventListener('scroll', this.debounce(() => {\n const scrollDirection = isScrollingDown()\n\n this.gsap.to(tween, {\n timeScale: scrollDirection ? 1 : -1,\n overwrite: true,\n })\n }, 50), {\n capture: true, passive: true\n })\n }\n\n if (this.dataDirection === 'ltr') {\n ltrDirection()\n } else if (this.dataDirection === 'auto') {\n autoDirection()\n }\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n\n onUpdate() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n\n this.onResize = this.onResize.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n connectedCallback() {\n this.onUpdate()\n }\n\n disconnectedCallback() {\n this.MM.remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.js.map"}
@@ -1,18 +1,17 @@
1
- var $cf838c15c8b009ba$exports = {};
2
- class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
1
+ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
3
2
  static registerGSAP(gsap) {
4
- $cf838c15c8b009ba$var$MarqueeContent.gsap = gsap;
3
+ $cf838c15c8b009ba$export$2e2bcd8739ae039.gsap = gsap;
5
4
  }
6
5
  constructor(query){
7
6
  super();
8
- this.gsap = $cf838c15c8b009ba$var$MarqueeContent.gsap || window.gsap;
7
+ this.gsap = $cf838c15c8b009ba$export$2e2bcd8739ae039.gsap || window.gsap;
8
+ this.MM = this.gsap.matchMedia(query);
9
9
  this.dataSkew = this.dataset.mcSkew;
10
10
  this.dataDuration = this.dataset.mcDuration || 20;
11
11
  this.dataDirection = this.dataset.mcDirection;
12
12
  this.dataMaxWidth = this.dataset.mcMax;
13
13
  this.dataMinWidth = this.dataset.mcMin;
14
14
  this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
15
- this.debounce();
16
15
  }
17
16
  debounce(fn, delay) {
18
17
  let timer;
@@ -33,30 +32,30 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
33
32
  while(this.childElementCount > 1)this.removeChild(this.lastChild);
34
33
  };
35
34
  removingClones();
36
- // gsap.matchMedia().add(this.breakpoint, () => {
37
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
38
- if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
39
- let cloned = this.firstElementChild;
40
- let clone = cloned.cloneNode(true);
41
- cloned.parentNode.append(clone);
42
- }
43
- return ()=>{
44
- removingClones();
45
- };
46
- // })
35
+ this.MM.add(this.breakpoint, ()=>{
36
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
37
+ if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
38
+ let cloned = this.firstElementChild;
39
+ let clone = cloned.cloneNode(true);
40
+ cloned.parentNode.append(clone);
41
+ }
42
+ return ()=>{
43
+ removingClones();
44
+ };
45
+ });
47
46
  }
48
47
  skewed() {
49
48
  if (!this.dataSkew) return;
50
49
  const abs = Math.abs(parseInt(this.dataSkew));
51
50
  const style = this.style;
52
- // gsap.matchMedia().add(this.breakpoint, () => {
53
- style.transformOrigin = "center center";
54
- style.transform = `skew(0deg, ${this.dataSkew}deg)`;
55
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
56
- return ()=>{
57
- style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
58
- };
59
- // })
51
+ this.MM.add(this.breakpoint, ()=>{
52
+ style.transformOrigin = "center center";
53
+ style.transform = `skew(0deg, ${this.dataSkew}deg)`;
54
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
55
+ return ()=>{
56
+ style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
57
+ };
58
+ });
60
59
  }
61
60
  animation() {
62
61
  let timeLine = this.gsap.timeline();
@@ -65,57 +64,57 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
65
64
  this.gsap.set(this.children, {
66
65
  clearProps: true
67
66
  });
68
- // gsap.matchMedia().add(this.breakpoint, () => {
69
- this.gsap.set(this.children, {
70
- "will-change": "transform"
71
- });
72
- const tween = this.gsap.to(this.children, {
73
- duration: this.dataDuration,
74
- x: "-100%",
75
- ease: "none",
76
- repeat: -1,
77
- scrollTrigger: {
78
- trigger: this,
79
- start: "-=50% bottom",
80
- end: "bottom top",
81
- toggleActions: "resume pause resume pause"
82
- }
83
- }).totalProgress(0.5);
84
- const ltrDirection = ()=>{
85
- this.gsap.to(tween, {
86
- timeScale: -1,
87
- overwrite: true
67
+ this.MM.add(this.breakpoint, ()=>{
68
+ this.gsap.set(this.children, {
69
+ "will-change": "transform"
88
70
  });
89
- };
90
- const autoDirection = ()=>{
91
- let previousScrollPosition = 0;
92
- const isScrollingDown = ()=>{
93
- const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
94
- let direction = false;
95
- if (scrollPosition > previousScrollPosition) direction = true;
96
- else if (scrollPosition < previousScrollPosition) direction = false;
97
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
98
- return direction;
99
- };
100
- addEventListener("scroll", this.debounce(()=>{
101
- const scrollDirection = isScrollingDown();
71
+ const tween = this.gsap.to(this.children, {
72
+ duration: this.dataDuration,
73
+ x: "-100%",
74
+ ease: "none",
75
+ repeat: -1,
76
+ scrollTrigger: {
77
+ trigger: this,
78
+ start: "-=50% bottom",
79
+ end: "bottom top",
80
+ toggleActions: "resume pause resume pause"
81
+ }
82
+ }).totalProgress(0.5);
83
+ const ltrDirection = ()=>{
102
84
  this.gsap.to(tween, {
103
- timeScale: scrollDirection ? 1 : -1,
85
+ timeScale: -1,
104
86
  overwrite: true
105
87
  });
106
- }, 50), {
107
- capture: true,
108
- passive: true
109
- });
110
- };
111
- if (this.dataDirection === "ltr") ltrDirection();
112
- else if (this.dataDirection === "auto") autoDirection();
113
- return ()=>{
114
- this.gsap.set(this.children, {
115
- clearProps: true
116
- });
117
- };
118
- // })
88
+ };
89
+ const autoDirection = ()=>{
90
+ let previousScrollPosition = 0;
91
+ const isScrollingDown = ()=>{
92
+ const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
93
+ let direction = false;
94
+ if (scrollPosition > previousScrollPosition) direction = true;
95
+ else if (scrollPosition < previousScrollPosition) direction = false;
96
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
97
+ return direction;
98
+ };
99
+ addEventListener("scroll", this.debounce(()=>{
100
+ const scrollDirection = isScrollingDown();
101
+ this.gsap.to(tween, {
102
+ timeScale: scrollDirection ? 1 : -1,
103
+ overwrite: true
104
+ });
105
+ }, 50), {
106
+ capture: true,
107
+ passive: true
108
+ });
109
+ };
110
+ if (this.dataDirection === "ltr") ltrDirection();
111
+ else if (this.dataDirection === "auto") autoDirection();
112
+ return ()=>{
113
+ this.gsap.set(this.children, {
114
+ clearProps: true
115
+ });
116
+ };
117
+ });
119
118
  }
120
119
  onResize() {
121
120
  cancelAnimationFrame(this.af);
@@ -137,12 +136,12 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
137
136
  this.onUpdate();
138
137
  }
139
138
  disconnectedCallback() {
140
- // gsap.matchMedia().remove()
139
+ this.MM.remove();
141
140
  document.fonts.removeEventListener("loadingdone", this.onUpdate);
142
141
  }
143
142
  }
144
- customElements.define("marquee-content", $cf838c15c8b009ba$var$MarqueeContent);
143
+ customElements.get("marquee-content") || customElements.define("marquee-content", $cf838c15c8b009ba$export$2e2bcd8739ae039);
145
144
 
146
145
 
147
- export {$cf838c15c8b009ba$exports as default};
146
+ export {$cf838c15c8b009ba$export$2e2bcd8739ae039 as default};
148
147
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"mappings":";AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,YAAY,KAAK,CAAE;QACf,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,qCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK;QACtC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,GAC7B,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,GAAG,KAAK,GAAG,CAAC,GAC5C,IAAI,CAAC,YAAY,GACb,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GACrC,EAAE;QACZ,IAAI,CAAC,QAAQ;IACjB;IAEA,SAAS,EAAE,EAAE,KAAK,EAAE;QAChB,IAAI;QAEJ,OAAO,CAAC,GAAG,OAAS;YAChB,IAAI,OAAO,aAAa;YACxB,QAAQ,WAAW,IAAM,MAAM,OAAO;QAC1C;IACJ;IAEA,YAAY;QACR,MAAM,MA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ACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAAE,YAAY,IAAI;YAAC;QACpD;IACA,KAAK;IACT;IAEA,WAAW;QACP,qBAAqB,IAAI,CAAC,EAAE;QAE5B,IAAI,CAAC,EAAE,GAAG,sBAAsB,IAAM;YAClC,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,SAAS;QAClB;IACJ;IAEA,WAAW;QACP,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,SAAS;QAEd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI;QACvC,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG;QACjF,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI;IACpC;IAEA,oBAAoB;QAChB,IAAI,CAAC,QAAQ;IACjB;IAEA,uBAAuB;QACnB,6BAA6B;QAE7B,SAAS,KAAK,CAAC,mBAAmB,CAAC,eAAe,IAAI,CAAC,QAAQ;IACnE;AACJ;AAEA,eAAe,MAAM,CAAC,mBAAmB","sources":["src/index.js"],"sourcesContent":["class MarqueeContent extends HTMLElement {\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n constructor(query) {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.dataSkew = this.dataset.mcSkew\n this.dataDuration = this.dataset.mcDuration || 20\n this.dataDirection = this.dataset.mcDirection\n this.dataMaxWidth = this.dataset.mcMax\n this.dataMinWidth = this.dataset.mcMin\n this.breakpoint = this.dataMaxWidth\n ? `(max-width: ${this.dataMaxWidth - 0.02}px)`\n : this.dataMinWidth\n ? `(min-width: ${this.dataMinWidth}px)`\n : ''\n this.debounce()\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 div = document.createElement('div')\n\n div.style.display = 'inline-block'\n div.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n div.appendChild(this.firstChild)\n }\n\n this.appendChild(div)\n }\n\n cloning() {\n const removingClones = () => {\n while (this.childElementCount > 1) {\n this.removeChild(this.lastChild)\n }\n }\n\n removingClones()\n\n // gsap.matchMedia().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.dataSkew) return\n\n const abs = Math.abs(parseInt(this.dataSkew))\n const style = this.style\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n style.transformOrigin = 'center center'\n style.transform = `skew(0deg, ${this.dataSkew}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 // gsap.matchMedia().add(this.breakpoint, () => {\n this.gsap.set(this.children, { 'will-change': 'transform' })\n\n const tween = this.gsap.to(this.children, {\n duration: this.dataDuration,\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 previousScrollPosition = 0\n\n const isScrollingDown = () => {\n const scrollPosition = window.pageYOffset || document.documentElement.scrollTop\n\n let direction = false\n\n if (scrollPosition > previousScrollPosition) {\n direction = true\n } else if (scrollPosition < previousScrollPosition) {\n direction = false\n }\n\n previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition\n\n return direction\n }\n\n addEventListener('scroll', this.debounce(() => {\n const scrollDirection = isScrollingDown()\n\n this.gsap.to(tween, {\n timeScale: scrollDirection ? 1 : -1,\n overwrite: true,\n })\n }, 50), {\n capture: true, passive: true\n })\n }\n\n if (this.dataDirection === 'ltr') {\n ltrDirection()\n } else if (this.dataDirection === 'auto') {\n autoDirection()\n }\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n // })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n\n onUpdate() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n\n this.onResize = this.onResize.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n connectedCallback() {\n this.onUpdate()\n }\n\n disconnectedCallback() {\n // gsap.matchMedia().remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.module.js.map"}
1
+ {"mappings":"AAAe,uDAA6B;IACxC,OAAO,aAAa,IAAI,EAAE;QACtB,yCAAe,IAAI,GAAG;IAC1B;IAEA,YAAY,KAAK,CAAE;QACf,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,yCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAA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,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG;QACjF,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI;IACpC;IAEA,oBAAoB;QAChB,IAAI,CAAC,QAAQ;IACjB;IAEA,uBAAuB;QACnB,IAAI,CAAC,EAAE,CAAC,MAAM;QAEd,SAAS,KAAK,CAAC,mBAAmB,CAAC,eAAe,IAAI,CAAC,QAAQ;IACnE;AACJ;AAEA,eAAe,GAAG,CAAC,sBAAsB,eAAe,MAAM,CAAC,mBAAmB","sources":["src/index.js"],"sourcesContent":["export default class MarqueeContent extends HTMLElement {\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n constructor(query) {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.MM = this.gsap.matchMedia(query)\n this.dataSkew = this.dataset.mcSkew\n this.dataDuration = this.dataset.mcDuration || 20\n this.dataDirection = this.dataset.mcDirection\n this.dataMaxWidth = this.dataset.mcMax\n this.dataMinWidth = this.dataset.mcMin\n this.breakpoint = this.dataMaxWidth\n ? `(max-width: ${this.dataMaxWidth - 0.02}px)`\n : this.dataMinWidth\n ? `(min-width: ${this.dataMinWidth}px)`\n : ''\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 div = document.createElement('div')\n\n div.style.display = 'inline-block'\n div.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n div.appendChild(this.firstChild)\n }\n\n this.appendChild(div)\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.dataSkew) return\n\n const abs = Math.abs(parseInt(this.dataSkew))\n const style = this.style\n\n this.MM.add(this.breakpoint, () => {\n style.transformOrigin = 'center center'\n style.transform = `skew(0deg, ${this.dataSkew}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.dataDuration,\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 previousScrollPosition = 0\n\n const isScrollingDown = () => {\n const scrollPosition = window.pageYOffset || document.documentElement.scrollTop\n\n let direction = false\n\n if (scrollPosition > previousScrollPosition) {\n direction = true\n } else if (scrollPosition < previousScrollPosition) {\n direction = false\n }\n\n previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition\n\n return direction\n }\n\n addEventListener('scroll', this.debounce(() => {\n const scrollDirection = isScrollingDown()\n\n this.gsap.to(tween, {\n timeScale: scrollDirection ? 1 : -1,\n overwrite: true,\n })\n }, 50), {\n capture: true, passive: true\n })\n }\n\n if (this.dataDirection === 'ltr') {\n ltrDirection()\n } else if (this.dataDirection === 'auto') {\n autoDirection()\n }\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n\n onUpdate() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n\n this.onResize = this.onResize.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n connectedCallback() {\n this.onUpdate()\n }\n\n disconnectedCallback() {\n this.MM.remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marquee-content",
3
- "version": "1.9.5",
3
+ "version": "1.9.7",
4
4
  "description": "Infinite marquee animation with GSAP",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- class MarqueeContent extends HTMLElement {
1
+ export default class MarqueeContent extends HTMLElement {
2
2
  static registerGSAP(gsap) {
3
3
  MarqueeContent.gsap = gsap
4
4
  }
@@ -7,6 +7,7 @@ class MarqueeContent extends HTMLElement {
7
7
  super()
8
8
 
9
9
  this.gsap = MarqueeContent.gsap || window.gsap
10
+ this.MM = this.gsap.matchMedia(query)
10
11
  this.dataSkew = this.dataset.mcSkew
11
12
  this.dataDuration = this.dataset.mcDuration || 20
12
13
  this.dataDirection = this.dataset.mcDirection
@@ -17,7 +18,6 @@ class MarqueeContent extends HTMLElement {
17
18
  : this.dataMinWidth
18
19
  ? `(min-width: ${this.dataMinWidth}px)`
19
20
  : ''
20
- this.debounce()
21
21
  }
22
22
 
23
23
  debounce(fn, delay) {
@@ -51,21 +51,21 @@ class MarqueeContent extends HTMLElement {
51
51
 
52
52
  removingClones()
53
53
 
54
- // gsap.matchMedia().add(this.breakpoint, () => {
55
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
54
+ this.MM.add(this.breakpoint, () => {
55
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
56
56
 
57
- if (this.childElementCount < requiredQuantity) {
58
- for (let i = 1; i < requiredQuantity; i++) {
59
- let cloned = this.firstElementChild
60
- let clone = cloned.cloneNode(true)
61
- cloned.parentNode.append(clone)
57
+ if (this.childElementCount < requiredQuantity) {
58
+ for (let i = 1; i < requiredQuantity; i++) {
59
+ let cloned = this.firstElementChild
60
+ let clone = cloned.cloneNode(true)
61
+ cloned.parentNode.append(clone)
62
+ }
62
63
  }
63
- }
64
64
 
65
- return () => {
66
- removingClones()
67
- }
68
- // })
65
+ return () => {
66
+ removingClones()
67
+ }
68
+ })
69
69
  }
70
70
 
71
71
  skewed() {
@@ -74,15 +74,15 @@ class MarqueeContent extends HTMLElement {
74
74
  const abs = Math.abs(parseInt(this.dataSkew))
75
75
  const style = this.style
76
76
 
77
- // gsap.matchMedia().add(this.breakpoint, () => {
78
- style.transformOrigin = 'center center'
79
- style.transform = `skew(0deg, ${this.dataSkew}deg)`
80
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
77
+ this.MM.add(this.breakpoint, () => {
78
+ style.transformOrigin = 'center center'
79
+ style.transform = `skew(0deg, ${this.dataSkew}deg)`
80
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
81
81
 
82
- return () => {
83
- style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
84
- }
85
- // })
82
+ return () => {
83
+ style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
84
+ }
85
+ })
86
86
  }
87
87
 
88
88
  animation() {
@@ -93,70 +93,70 @@ class MarqueeContent extends HTMLElement {
93
93
 
94
94
  this.gsap.set(this.children, { clearProps: true })
95
95
 
96
- // gsap.matchMedia().add(this.breakpoint, () => {
97
- this.gsap.set(this.children, { 'will-change': 'transform' })
98
-
99
- const tween = this.gsap.to(this.children, {
100
- duration: this.dataDuration,
101
- x: '-100%',
102
- ease: 'none',
103
- repeat: -1,
104
- scrollTrigger: {
105
- trigger: this,
106
- start: '-=50% bottom',
107
- end: 'bottom top',
108
- toggleActions: 'resume pause resume pause',
109
- },
110
- }).totalProgress(0.5)
111
-
112
- const ltrDirection = () => {
113
- this.gsap.to(tween, {
114
- timeScale: -1,
115
- overwrite: true
116
- })
117
- }
96
+ this.MM.add(this.breakpoint, () => {
97
+ this.gsap.set(this.children, { 'will-change': 'transform' })
98
+
99
+ const tween = this.gsap.to(this.children, {
100
+ duration: this.dataDuration,
101
+ x: '-100%',
102
+ ease: 'none',
103
+ repeat: -1,
104
+ scrollTrigger: {
105
+ trigger: this,
106
+ start: '-=50% bottom',
107
+ end: 'bottom top',
108
+ toggleActions: 'resume pause resume pause',
109
+ },
110
+ }).totalProgress(0.5)
111
+
112
+ const ltrDirection = () => {
113
+ this.gsap.to(tween, {
114
+ timeScale: -1,
115
+ overwrite: true
116
+ })
117
+ }
118
118
 
119
- const autoDirection = () => {
120
- let previousScrollPosition = 0
119
+ const autoDirection = () => {
120
+ let previousScrollPosition = 0
121
121
 
122
- const isScrollingDown = () => {
123
- const scrollPosition = window.pageYOffset || document.documentElement.scrollTop
122
+ const isScrollingDown = () => {
123
+ const scrollPosition = window.pageYOffset || document.documentElement.scrollTop
124
124
 
125
- let direction = false
125
+ let direction = false
126
126
 
127
- if (scrollPosition > previousScrollPosition) {
128
- direction = true
129
- } else if (scrollPosition < previousScrollPosition) {
130
- direction = false
131
- }
127
+ if (scrollPosition > previousScrollPosition) {
128
+ direction = true
129
+ } else if (scrollPosition < previousScrollPosition) {
130
+ direction = false
131
+ }
132
132
 
133
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
133
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
134
134
 
135
- return direction
136
- }
135
+ return direction
136
+ }
137
137
 
138
- addEventListener('scroll', this.debounce(() => {
139
- const scrollDirection = isScrollingDown()
138
+ addEventListener('scroll', this.debounce(() => {
139
+ const scrollDirection = isScrollingDown()
140
140
 
141
- this.gsap.to(tween, {
142
- timeScale: scrollDirection ? 1 : -1,
143
- overwrite: true,
141
+ this.gsap.to(tween, {
142
+ timeScale: scrollDirection ? 1 : -1,
143
+ overwrite: true,
144
+ })
145
+ }, 50), {
146
+ capture: true, passive: true
144
147
  })
145
- }, 50), {
146
- capture: true, passive: true
147
- })
148
- }
148
+ }
149
149
 
150
- if (this.dataDirection === 'ltr') {
151
- ltrDirection()
152
- } else if (this.dataDirection === 'auto') {
153
- autoDirection()
154
- }
150
+ if (this.dataDirection === 'ltr') {
151
+ ltrDirection()
152
+ } else if (this.dataDirection === 'auto') {
153
+ autoDirection()
154
+ }
155
155
 
156
- return () => {
157
- this.gsap.set(this.children, { clearProps: true })
158
- }
159
- // })
156
+ return () => {
157
+ this.gsap.set(this.children, { clearProps: true })
158
+ }
159
+ })
160
160
  }
161
161
 
162
162
  onResize() {
@@ -184,10 +184,10 @@ class MarqueeContent extends HTMLElement {
184
184
  }
185
185
 
186
186
  disconnectedCallback() {
187
- // gsap.matchMedia().remove()
187
+ this.MM.remove()
188
188
 
189
189
  document.fonts.removeEventListener('loadingdone', this.onUpdate)
190
190
  }
191
191
  }
192
192
 
193
- customElements.define('marquee-content', MarqueeContent)
193
+ customElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)