marquee-content 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,10 +32,6 @@ import MarqueeContent from 'marquee-content';
32
32
 
33
33
  gsap.registerPlugin(ScrollTrigger);
34
34
  MarqueeContent.registerGSAP(gsap);
35
-
36
- const marqueeContent = new MarqueeContent();
37
-
38
- marqueeContent.init();
39
35
  ```
40
36
  <br>
41
37
 
package/dist/index.js CHANGED
@@ -21,11 +21,6 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
21
21
  static registerGSAP(gsap) {
22
22
  $4fa36e821943b400$export$2e2bcd8739ae039.gsap = gsap;
23
23
  }
24
- breakpoints() {
25
- this.breakpoint = "";
26
- if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
27
- else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
28
- }
29
24
  debounce(fn, delay) {
30
25
  this.timer = null;
31
26
  return (...args)=>{
@@ -33,6 +28,11 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
33
28
  this.timer = setTimeout(()=>fn(...args), delay);
34
29
  };
35
30
  }
31
+ breakpoints() {
32
+ this.breakpoint = "";
33
+ if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
34
+ else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
35
+ }
36
36
  templates() {
37
37
  const wrapper = document.createElement("div");
38
38
  wrapper.classList.add("marquee-wrapper");
package/dist/index.js.map CHANGED
@@ -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,WAAW;QACh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B,IAAI,gBAAgB;gBACpB,IAAI,kBAAkB;gBAEtB,MAAM,eAAe;oBACjB,MAAM,cAAc,AAAC,OAAO,UAAU,gBAAiB,IAAI;oBAE3D,IAAI,gBAAgB,iBAAiB;wBACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU;4BACxB,WAAW;4BACX,WAAW;wBACf;wBAEA,kBAAkB;oBACtB;oBAEA,gBAAgB,OAAO;gBAC3B;gBAEA,OAAO,iBAAiB,UAAU,cAAc;oBAAE,SAAS;oBAAM,SAAS;gBAAK;YACnF;YAEA,IAAI,IAAI,CAAC,QAAQ,gBAAgB,OAC7B;iBACG,IAAI,IAAI,CAAC,QAAQ,gBAAgB,QACpC;YAGJ,OAAO;gBACH,IAAI,IAAI,CAAC,UAAU;oBACf,IAAI,CAAC,SAAS;oBACd,IAAI,CAAC,WAAW;gBACpB;gBAEA,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,OAAO;QACH,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,oBAAoB;QAChB,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,SAAS;YACd,IAAI,CAAC,WAAW;QACpB;IACJ;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.timeline = null;\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 breakpoints() {\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\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\n this.gsap.set(this.children, { clearProps: true });\n\n this.MM.add(this.breakpoint, () => {\n this.timeline = 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(this.timeline, {\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(this.timeline, {\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\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 init() {\n this.breakpoints();\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n }\n}\n\nif (!customElements.get('marquee-content')) {\n customElements.define('marquee-content', MarqueeContent);\n}\n"],"names":[],"version":3,"file":"index.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,OAAO,yCAAe,QAAQ,OA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CAAC,UAAU;oBACxB,WAAW;oBACX,WAAW;gBACf;YACJ;YAEA,MAAM,gBAAgB;gBAClB,IAAI,gBAAgB;gBACpB,IAAI,kBAAkB;gBAEtB,MAAM,eAAe;oBACjB,MAAM,cAAc,AAAC,OAAO,UAAU,gBAAiB,IAAI;oBAE3D,IAAI,gBAAgB,iBAAiB;wBACjC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU;4BACxB,WAAW;4BACX,WAAW;wBACf;wBAEA,kBAAkB;oBACtB;oBAEA,gBAAgB,OAAO;gBAC3B;gBAEA,OAAO,iBAAiB,UAAU,cAAc;oBAAE,SAAS;oBAAM,SAAS;gBAAK;YACnF;YAEA,IAAI,IAAI,CAAC,QAAQ,gBAAgB,OAC7B;iBACG,IAAI,IAAI,CAAC,QAAQ,gBAAgB,QACpC;YAGJ,OAAO;gBACH,IAAI,IAAI,CAAC,UAAU;oBACf,IAAI,CAAC,SAAS;oBACd,IAAI,CAAC,WAAW;gBACpB;gBAEA,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,OAAO;QACH,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,oBAAoB;QAChB,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,SAAS;YACd,IAAI,CAAC,WAAW;QACpB;IACJ;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.timeline = null;\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 breakpoints() {\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\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\n this.gsap.set(this.children, { clearProps: true });\n\n this.MM.add(this.breakpoint, () => {\n this.timeline = 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(this.timeline, {\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(this.timeline, {\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\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 init() {\n this.breakpoints();\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n }\n}\n\nif (!customElements.get('marquee-content')) {\n customElements.define('marquee-content', MarqueeContent);\n}\n"],"names":[],"version":3,"file":"index.js.map"}
@@ -11,11 +11,6 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
11
11
  static registerGSAP(gsap) {
12
12
  $cf838c15c8b009ba$export$2e2bcd8739ae039.gsap = gsap;
13
13
  }
14
- breakpoints() {
15
- this.breakpoint = "";
16
- if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
17
- else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
18
- }
19
14
  debounce(fn, delay) {
20
15
  this.timer = null;
21
16
  return (...args)=>{
@@ -23,6 +18,11 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
23
18
  this.timer = setTimeout(()=>fn(...args), delay);
24
19
  };
25
20
  }
21
+ breakpoints() {
22
+ this.breakpoint = "";
23
+ if (this.dataset.mcMax) this.breakpoint = `(max-width: ${this.dataset.mcMax - 0.02}px)`;
24
+ else if (this.dataset.mcMin) this.breakpoint = `(min-width: ${this.dataset.mcMin}px)`;
25
+ }
26
26
  templates() {
27
27
  const wrapper = document.createElement("div");
28
28
  wrapper.classList.add("marquee-wrapper");
@@ -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,WAAW;QAChB,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,cAAc;QACV,IAAI,CAAC,aAAa;QAElB,IAAI,IAAI,CAAC,QAAQ,OACb,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,QAAQ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AQ,gBAAgB,OAC7B;iBACG,IAAI,IAAI,CAAC,QAAQ,gBAAgB,QACpC;YAGJ,OAAO;gBACH,IAAI,IAAI,CAAC,UAAU;oBACf,IAAI,CAAC,SAAS;oBACd,IAAI,CAAC,WAAW;gBACpB;gBAEA,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,OAAO;QACH,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,oBAAoB;QAChB,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,SAAS;YACd,IAAI,CAAC,WAAW;QACpB;IACJ;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.timeline = null;\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 breakpoints() {\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\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\n this.gsap.set(this.children, { clearProps: true });\n\n this.MM.add(this.breakpoint, () => {\n this.timeline = 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(this.timeline, {\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(this.timeline, {\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\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 init() {\n this.breakpoints();\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n }\n}\n\nif (!customElements.get('marquee-content')) {\n customElements.define('marquee-content', MarqueeContent);\n}\n"],"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,WAAW;QAChB,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;QAE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oBAAE,SAAS;oBAAM,SAAS;gBAAK;YACnF;YAEA,IAAI,IAAI,CAAC,QAAQ,gBAAgB,OAC7B;iBACG,IAAI,IAAI,CAAC,QAAQ,gBAAgB,QACpC;YAGJ,OAAO;gBACH,IAAI,IAAI,CAAC,UAAU;oBACf,IAAI,CAAC,SAAS;oBACd,IAAI,CAAC,WAAW;gBACpB;gBAEA,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,OAAO;QACH,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;QACL,IAAI,CAAC;IACT;IAEA,oBAAoB;QAChB,IAAI,CAAC;IACT;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC;QAE1B,IAAI,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,SAAS;YACd,IAAI,CAAC,WAAW;QACpB;IACJ;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.timeline = null;\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 breakpoints() {\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\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\n this.gsap.set(this.children, { clearProps: true });\n\n this.MM.add(this.breakpoint, () => {\n this.timeline = 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(this.timeline, {\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(this.timeline, {\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\n\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 init() {\n this.breakpoints();\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 if (this.timeline) {\n this.timeline.kill();\n this.timeline = null;\n }\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,6 +1,6 @@
1
1
  {
2
2
  "name": "marquee-content",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
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",
package/src/index.js CHANGED
@@ -14,6 +14,15 @@ export default class MarqueeContent extends HTMLElement {
14
14
  MarqueeContent.gsap = gsap;
15
15
  }
16
16
 
17
+ debounce(fn, delay) {
18
+ this.timer = null;
19
+
20
+ return (...args) => {
21
+ if (this.timer) clearTimeout(this.timer);
22
+ this.timer = setTimeout(() => fn(...args), delay);
23
+ };
24
+ }
25
+
17
26
  breakpoints() {
18
27
  this.breakpoint = '';
19
28
 
@@ -24,15 +33,6 @@ export default class MarqueeContent extends HTMLElement {
24
33
  }
25
34
  }
26
35
 
27
- debounce(fn, delay) {
28
- this.timer = null;
29
-
30
- return (...args) => {
31
- if (this.timer) clearTimeout(this.timer);
32
- this.timer = setTimeout(() => fn(...args), delay);
33
- };
34
- }
35
-
36
36
  templates() {
37
37
  const wrapper = document.createElement('div');
38
38
  wrapper.classList.add('marquee-wrapper');