marquee-content 1.9.3 → 1.9.5

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
@@ -5,7 +5,6 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
5
5
  constructor(query){
6
6
  super();
7
7
  this.gsap = $4fa36e821943b400$var$MarqueeContent.gsap || window.gsap;
8
- this.MM = this.gsap.matchMedia(query);
9
8
  this.dataSkew = this.dataset.mcSkew;
10
9
  this.dataDuration = this.dataset.mcDuration || 20;
11
10
  this.dataDirection = this.dataset.mcDirection;
@@ -13,13 +12,6 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
13
12
  this.dataMinWidth = this.dataset.mcMin;
14
13
  this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
15
14
  this.debounce();
16
- window.matchMedia = window.matchMedia || function() {
17
- return {
18
- matches: false,
19
- addListener: function() {},
20
- removeListener: function() {}
21
- };
22
- };
23
15
  }
24
16
  debounce(fn, delay) {
25
17
  let timer;
@@ -40,30 +32,30 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
40
32
  while(this.childElementCount > 1)this.removeChild(this.lastChild);
41
33
  };
42
34
  removingClones();
43
- this.MM.add(this.breakpoint, ()=>{
44
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
45
- if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
46
- let cloned = this.firstElementChild;
47
- let clone = cloned.cloneNode(true);
48
- cloned.parentNode.append(clone);
49
- }
50
- return ()=>{
51
- removingClones();
52
- };
53
- });
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
+ // })
54
46
  }
55
47
  skewed() {
56
48
  if (!this.dataSkew) return;
57
49
  const abs = Math.abs(parseInt(this.dataSkew));
58
50
  const style = this.style;
59
- this.MM.add(this.breakpoint, ()=>{
60
- style.transformOrigin = "center center";
61
- style.transform = `skew(0deg, ${this.dataSkew}deg)`;
62
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
63
- return ()=>{
64
- style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
65
- };
66
- });
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
+ // })
67
59
  }
68
60
  animation() {
69
61
  let timeLine = this.gsap.timeline();
@@ -72,57 +64,57 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
72
64
  this.gsap.set(this.children, {
73
65
  clearProps: true
74
66
  });
75
- this.MM.add(this.breakpoint, ()=>{
76
- this.gsap.set(this.children, {
77
- "will-change": "transform"
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
78
87
  });
79
- const tween = this.gsap.to(this.children, {
80
- duration: this.dataDuration,
81
- x: "-100%",
82
- ease: "none",
83
- repeat: -1,
84
- scrollTrigger: {
85
- trigger: this,
86
- start: "-=50% bottom",
87
- end: "bottom top",
88
- toggleActions: "resume pause resume pause"
89
- }
90
- }).totalProgress(0.5);
91
- const ltrDirection = ()=>{
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();
92
101
  this.gsap.to(tween, {
93
- timeScale: -1,
102
+ timeScale: scrollDirection ? 1 : -1,
94
103
  overwrite: true
95
104
  });
96
- };
97
- const autoDirection = ()=>{
98
- let previousScrollPosition = 0;
99
- const isScrollingDown = ()=>{
100
- const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
101
- let direction = false;
102
- if (scrollPosition > previousScrollPosition) direction = true;
103
- else if (scrollPosition < previousScrollPosition) direction = false;
104
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
105
- return direction;
106
- };
107
- addEventListener("scroll", this.debounce(()=>{
108
- const scrollDirection = isScrollingDown();
109
- this.gsap.to(tween, {
110
- timeScale: scrollDirection ? 1 : -1,
111
- overwrite: true
112
- });
113
- }, 50), {
114
- capture: true,
115
- passive: true
116
- });
117
- };
118
- if (this.dataDirection === "ltr") ltrDirection();
119
- else if (this.dataDirection === "auto") autoDirection();
120
- return ()=>{
121
- this.gsap.set(this.children, {
122
- clearProps: true
123
- });
124
- };
125
- });
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
+ // })
126
118
  }
127
119
  onResize() {
128
120
  cancelAnimationFrame(this.af);
@@ -144,7 +136,7 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
144
136
  this.onUpdate();
145
137
  }
146
138
  disconnectedCallback() {
147
- this.MM.remove();
139
+ // gsap.matchMedia().remove()
148
140
  document.fonts.removeEventListener("loadingdone", this.onUpdate);
149
141
  }
150
142
  }
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,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;QACZ,IAAI,CAAC,QAAQ;QAEb,OAAO,UAAU,GAAG,OAAO,UAAU,IAAI,WAAW;YAChD,OAAO;gBAC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nE;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.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 this.debounce()\n\n window.matchMedia = window.matchMedia || function() {\n return {\n matches : false,\n addListener : function() {},\n removeListener: function() {}\n }\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.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.js.map"}
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,MAAM,SAAS,aAAa,CAAC;QAEnC,IAAI,KAAK,CAAC,OAAO,GAAG;QACpB,IAAI,KAAK,CAAC,UAAU,GAAG;QAEvB,MAAO,IAAI,CAAC,UAAU,CAClB,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU;QAGnC,IAAI,CAAC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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.js.map"}
@@ -6,7 +6,6 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
6
6
  constructor(query){
7
7
  super();
8
8
  this.gsap = $cf838c15c8b009ba$var$MarqueeContent.gsap || window.gsap;
9
- this.MM = this.gsap.matchMedia(query);
10
9
  this.dataSkew = this.dataset.mcSkew;
11
10
  this.dataDuration = this.dataset.mcDuration || 20;
12
11
  this.dataDirection = this.dataset.mcDirection;
@@ -14,13 +13,6 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
14
13
  this.dataMinWidth = this.dataset.mcMin;
15
14
  this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
16
15
  this.debounce();
17
- window.matchMedia = window.matchMedia || function() {
18
- return {
19
- matches: false,
20
- addListener: function() {},
21
- removeListener: function() {}
22
- };
23
- };
24
16
  }
25
17
  debounce(fn, delay) {
26
18
  let timer;
@@ -41,30 +33,30 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
41
33
  while(this.childElementCount > 1)this.removeChild(this.lastChild);
42
34
  };
43
35
  removingClones();
44
- this.MM.add(this.breakpoint, ()=>{
45
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
46
- if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
47
- let cloned = this.firstElementChild;
48
- let clone = cloned.cloneNode(true);
49
- cloned.parentNode.append(clone);
50
- }
51
- return ()=>{
52
- removingClones();
53
- };
54
- });
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
+ // })
55
47
  }
56
48
  skewed() {
57
49
  if (!this.dataSkew) return;
58
50
  const abs = Math.abs(parseInt(this.dataSkew));
59
51
  const style = this.style;
60
- this.MM.add(this.breakpoint, ()=>{
61
- style.transformOrigin = "center center";
62
- style.transform = `skew(0deg, ${this.dataSkew}deg)`;
63
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
64
- return ()=>{
65
- style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
66
- };
67
- });
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
+ // })
68
60
  }
69
61
  animation() {
70
62
  let timeLine = this.gsap.timeline();
@@ -73,57 +65,57 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
73
65
  this.gsap.set(this.children, {
74
66
  clearProps: true
75
67
  });
76
- this.MM.add(this.breakpoint, ()=>{
77
- this.gsap.set(this.children, {
78
- "will-change": "transform"
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
79
88
  });
80
- const tween = this.gsap.to(this.children, {
81
- duration: this.dataDuration,
82
- x: "-100%",
83
- ease: "none",
84
- repeat: -1,
85
- scrollTrigger: {
86
- trigger: this,
87
- start: "-=50% bottom",
88
- end: "bottom top",
89
- toggleActions: "resume pause resume pause"
90
- }
91
- }).totalProgress(0.5);
92
- const ltrDirection = ()=>{
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();
93
102
  this.gsap.to(tween, {
94
- timeScale: -1,
103
+ timeScale: scrollDirection ? 1 : -1,
95
104
  overwrite: true
96
105
  });
97
- };
98
- const autoDirection = ()=>{
99
- let previousScrollPosition = 0;
100
- const isScrollingDown = ()=>{
101
- const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
102
- let direction = false;
103
- if (scrollPosition > previousScrollPosition) direction = true;
104
- else if (scrollPosition < previousScrollPosition) direction = false;
105
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
106
- return direction;
107
- };
108
- addEventListener("scroll", this.debounce(()=>{
109
- const scrollDirection = isScrollingDown();
110
- this.gsap.to(tween, {
111
- timeScale: scrollDirection ? 1 : -1,
112
- overwrite: true
113
- });
114
- }, 50), {
115
- capture: true,
116
- passive: true
117
- });
118
- };
119
- if (this.dataDirection === "ltr") ltrDirection();
120
- else if (this.dataDirection === "auto") autoDirection();
121
- return ()=>{
122
- this.gsap.set(this.children, {
123
- clearProps: true
124
- });
125
- };
126
- });
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
+ // })
127
119
  }
128
120
  onResize() {
129
121
  cancelAnimationFrame(this.af);
@@ -145,7 +137,7 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
145
137
  this.onUpdate();
146
138
  }
147
139
  disconnectedCallback() {
148
- this.MM.remove();
140
+ // gsap.matchMedia().remove()
149
141
  document.fonts.removeEventListener("loadingdone", this.onUpdate);
150
142
  }
151
143
  }
@@ -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,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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,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,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.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 this.debounce()\n\n window.matchMedia = window.matchMedia || function() {\n return {\n matches : false,\n addListener : function() {},\n removeListener: function() {}\n }\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.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.module.js.map"}
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,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;gBAC3C,MAAM,kBAAkB;gBAExB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO;oBAChB,WAAW,kBAAkB,IAAI,EAAE;oBACnC,WAAW,IAAI;gBACnB;YACJ,GAAG,KAAK;gBACJ,SAAS,IAAI;gBAAE,SAAS,IAAI;YAChC;QACJ;QAEA,IAAI,IAAI,CAAC,aAAa,KAAK,OACvB;aACG,IAAI,IAAI,CAAC,aAAa,KAAK,QAC9B;QAGJ,OAAO,IAAM;YACT,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marquee-content",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "description": "Infinite marquee animation with GSAP",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
package/src/index.js CHANGED
@@ -7,7 +7,6 @@ class MarqueeContent extends HTMLElement {
7
7
  super()
8
8
 
9
9
  this.gsap = MarqueeContent.gsap || window.gsap
10
- this.MM = this.gsap.matchMedia(query)
11
10
  this.dataSkew = this.dataset.mcSkew
12
11
  this.dataDuration = this.dataset.mcDuration || 20
13
12
  this.dataDirection = this.dataset.mcDirection
@@ -19,14 +18,6 @@ class MarqueeContent extends HTMLElement {
19
18
  ? `(min-width: ${this.dataMinWidth}px)`
20
19
  : ''
21
20
  this.debounce()
22
-
23
- window.matchMedia = window.matchMedia || function() {
24
- return {
25
- matches : false,
26
- addListener : function() {},
27
- removeListener: function() {}
28
- }
29
- }
30
21
  }
31
22
 
32
23
  debounce(fn, delay) {
@@ -60,21 +51,21 @@ class MarqueeContent extends HTMLElement {
60
51
 
61
52
  removingClones()
62
53
 
63
- this.MM.add(this.breakpoint, () => {
64
- let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
54
+ // gsap.matchMedia().add(this.breakpoint, () => {
55
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
65
56
 
66
- if (this.childElementCount < requiredQuantity) {
67
- for (let i = 1; i < requiredQuantity; i++) {
68
- let cloned = this.firstElementChild
69
- let clone = cloned.cloneNode(true)
70
- cloned.parentNode.append(clone)
71
- }
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)
72
62
  }
63
+ }
73
64
 
74
- return () => {
75
- removingClones()
76
- }
77
- })
65
+ return () => {
66
+ removingClones()
67
+ }
68
+ // })
78
69
  }
79
70
 
80
71
  skewed() {
@@ -83,15 +74,15 @@ class MarqueeContent extends HTMLElement {
83
74
  const abs = Math.abs(parseInt(this.dataSkew))
84
75
  const style = this.style
85
76
 
86
- this.MM.add(this.breakpoint, () => {
87
- style.transformOrigin = 'center center'
88
- style.transform = `skew(0deg, ${this.dataSkew}deg)`
89
- style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
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)`
90
81
 
91
- return () => {
92
- style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
93
- }
94
- })
82
+ return () => {
83
+ style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
84
+ }
85
+ // })
95
86
  }
96
87
 
97
88
  animation() {
@@ -102,70 +93,70 @@ class MarqueeContent extends HTMLElement {
102
93
 
103
94
  this.gsap.set(this.children, { clearProps: true })
104
95
 
105
- this.MM.add(this.breakpoint, () => {
106
- this.gsap.set(this.children, { 'will-change': 'transform' })
107
-
108
- const tween = this.gsap.to(this.children, {
109
- duration: this.dataDuration,
110
- x: '-100%',
111
- ease: 'none',
112
- repeat: -1,
113
- scrollTrigger: {
114
- trigger: this,
115
- start: '-=50% bottom',
116
- end: 'bottom top',
117
- toggleActions: 'resume pause resume pause',
118
- },
119
- }).totalProgress(0.5)
120
-
121
- const ltrDirection = () => {
122
- this.gsap.to(tween, {
123
- timeScale: -1,
124
- overwrite: true
125
- })
126
- }
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
+ }
127
118
 
128
- const autoDirection = () => {
129
- let previousScrollPosition = 0
119
+ const autoDirection = () => {
120
+ let previousScrollPosition = 0
130
121
 
131
- const isScrollingDown = () => {
132
- const scrollPosition = window.pageYOffset || document.documentElement.scrollTop
122
+ const isScrollingDown = () => {
123
+ const scrollPosition = window.pageYOffset || document.documentElement.scrollTop
133
124
 
134
- let direction = false
125
+ let direction = false
135
126
 
136
- if (scrollPosition > previousScrollPosition) {
137
- direction = true
138
- } else if (scrollPosition < previousScrollPosition) {
139
- direction = false
140
- }
127
+ if (scrollPosition > previousScrollPosition) {
128
+ direction = true
129
+ } else if (scrollPosition < previousScrollPosition) {
130
+ direction = false
131
+ }
141
132
 
142
- previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
133
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
143
134
 
144
- return direction
145
- }
135
+ return direction
136
+ }
146
137
 
147
- addEventListener('scroll', this.debounce(() => {
148
- const scrollDirection = isScrollingDown()
138
+ addEventListener('scroll', this.debounce(() => {
139
+ const scrollDirection = isScrollingDown()
149
140
 
150
- this.gsap.to(tween, {
151
- timeScale: scrollDirection ? 1 : -1,
152
- overwrite: true,
153
- })
154
- }, 50), {
155
- capture: true, passive: true
141
+ this.gsap.to(tween, {
142
+ timeScale: scrollDirection ? 1 : -1,
143
+ overwrite: true,
156
144
  })
157
- }
145
+ }, 50), {
146
+ capture: true, passive: true
147
+ })
148
+ }
158
149
 
159
- if (this.dataDirection === 'ltr') {
160
- ltrDirection()
161
- } else if (this.dataDirection === 'auto') {
162
- autoDirection()
163
- }
150
+ if (this.dataDirection === 'ltr') {
151
+ ltrDirection()
152
+ } else if (this.dataDirection === 'auto') {
153
+ autoDirection()
154
+ }
164
155
 
165
- return () => {
166
- this.gsap.set(this.children, { clearProps: true })
167
- }
168
- })
156
+ return () => {
157
+ this.gsap.set(this.children, { clearProps: true })
158
+ }
159
+ // })
169
160
  }
170
161
 
171
162
  onResize() {
@@ -193,7 +184,7 @@ class MarqueeContent extends HTMLElement {
193
184
  }
194
185
 
195
186
  disconnectedCallback() {
196
- this.MM.remove()
187
+ // gsap.matchMedia().remove()
197
188
 
198
189
  document.fonts.removeEventListener('loadingdone', this.onUpdate)
199
190
  }