marquee-content 1.8.0 → 1.9.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
@@ -9,17 +9,19 @@
9
9
  [![GitHub package version](https://img.shields.io/github/package-json/v/ux-ui-pro/marquee-content.svg)](https://github.com/ux-ui-pro/marquee-content)
10
10
  [![NPM Downloads](https://img.shields.io/npm/dm/marquee-content.svg?style=flat)](https://www.npmjs.org/package/marquee-content)
11
11
 
12
- <h3><a href="https://ux-ui-pro.github.io/marquee-content/dist/">Demo</a></h3>
12
+ <h3><a href="https://codepen.io/ux-ui/pen/dygzqYm">Demo</a></h3>
13
13
 
14
14
  </div>
15
15
  <br>
16
16
 
17
17
  ### Installation
18
18
  ```javascript
19
+ $ yarn add gsap
19
20
  $ yarn add marquee-content
20
21
  ```
21
22
  <sup>or</sup>
22
23
  ```javascript
24
+ $ npm i gsap
23
25
  $ npm i marquee-content
24
26
  ```
25
27
 
@@ -27,15 +29,21 @@ $ npm i marquee-content
27
29
 
28
30
  ### Import
29
31
  ```javascript
30
- import { MarqueeContent } from 'marquee-content'
32
+ import gsap from 'gsap'
33
+ import MarqueeContent from 'marquee-content'
34
+
35
+ gsap.registerPlugin(ScrollTrigger)
36
+ MarqueeContent.registerGSAP(gsap)
37
+
38
+ const marquee = new MarqueeContent()
31
39
  ```
32
40
  <br>
33
41
 
34
42
  ### Usage
35
43
  ```HTML
36
- <div class="marquee-content" data-mc-duration="30" role="marquee">
37
- some content
38
- </div>
44
+ <marquee-content data-mc-duration="30" role="marquee">
45
+ content
46
+ </marquee-content>
39
47
  ```
40
48
  <br>
41
49
 
@@ -0,0 +1,37 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, ethnicity, level of experience, nationality, personal appearance, race, or religion.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+
16
+ Examples of unacceptable behavior by participants include:
17
+
18
+ * Trolling, insulting/derogatory comments, and personal or political attacks
19
+ * Public or private harassment
20
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
21
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
22
+
23
+ ## Our Responsibilities
24
+
25
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
26
+
27
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
28
+
29
+ ## Scope
30
+
31
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
32
+
33
+ ## Enforcement
34
+
35
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
36
+
37
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
package/dist/index.js ADDED
@@ -0,0 +1,143 @@
1
+ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
2
+ static registerGSAP(gsap) {
3
+ $4fa36e821943b400$var$MarqueeContent.gsap = gsap;
4
+ }
5
+ constructor(){
6
+ super();
7
+ this.gsap = $4fa36e821943b400$var$MarqueeContent.gsap || window.gsap;
8
+ this.matchMedia = this.gsap.matchMedia();
9
+ this.dataSkew = this.dataset.mcSkew;
10
+ this.dataDuration = this.dataset.mcDuration || 20;
11
+ this.dataDirection = this.dataset.mcDirection;
12
+ this.dataMaxWidth = this.dataset.mcMax;
13
+ this.dataMinWidth = this.dataset.mcMin;
14
+ this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
15
+ this.debounce();
16
+ }
17
+ debounce(fn, delay) {
18
+ let timer;
19
+ return (...args)=>{
20
+ if (timer) clearTimeout(timer);
21
+ timer = setTimeout(()=>fn(...args), delay);
22
+ };
23
+ }
24
+ templates() {
25
+ this.innerHTML = `<div class="marquee-wrapper"><div class="marquee-inner" style="display: inline-block; white-space: nowrap;">${this.innerHTML}</div></div>`;
26
+ }
27
+ cloning() {
28
+ const removingClones = ()=>{
29
+ while(this.childElementCount > 1)this.removeChild(this.lastChild);
30
+ };
31
+ removingClones();
32
+ this.matchMedia.add(this.breakpoint, ()=>{
33
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
34
+ if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
35
+ let cloned = this.firstElementChild;
36
+ let clone = cloned.cloneNode(true);
37
+ cloned.parentNode.append(clone);
38
+ }
39
+ return ()=>{
40
+ removingClones();
41
+ };
42
+ });
43
+ }
44
+ skewed() {
45
+ if (!this.dataSkew) return;
46
+ let abs = Math.abs(parseInt(this.dataSkew));
47
+ let style = this.style;
48
+ this.matchMedia.add(this.breakpoint, ()=>{
49
+ style.transformOrigin = "center center";
50
+ style.transform = `skew(0deg, ${this.dataSkew}deg)`;
51
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
52
+ return ()=>{
53
+ style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
54
+ };
55
+ });
56
+ }
57
+ animation() {
58
+ let timeLine = this.gsap.timeline();
59
+ timeLine.kill();
60
+ timeLine = null;
61
+ this.gsap.set(this.children, {
62
+ clearProps: true
63
+ });
64
+ this.matchMedia.add(this.breakpoint, ()=>{
65
+ this.gsap.set(this.children, {
66
+ "will-change": "transform"
67
+ });
68
+ const tween = this.gsap.to(this.children, {
69
+ duration: this.dataDuration,
70
+ x: "-100%",
71
+ ease: "none",
72
+ repeat: -1,
73
+ scrollTrigger: {
74
+ trigger: this,
75
+ start: "-=50% bottom",
76
+ end: "bottom top",
77
+ toggleActions: "resume pause resume pause"
78
+ }
79
+ }).totalProgress(0.5);
80
+ const ltrDirection = ()=>{
81
+ this.gsap.to(tween, {
82
+ timeScale: -1,
83
+ overwrite: true
84
+ });
85
+ };
86
+ const autoDirection = ()=>{
87
+ let previousScrollPosition = 0;
88
+ const isScrollingDown = ()=>{
89
+ let scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
90
+ let direction = false;
91
+ if (scrollPosition > previousScrollPosition) direction = true;
92
+ else if (scrollPosition < previousScrollPosition) direction = false;
93
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
94
+ return direction;
95
+ };
96
+ let scrollTimer;
97
+ addEventListener("scroll", this.debounce(()=>{
98
+ let scrollDirection = isScrollingDown();
99
+ this.gsap.to(tween, {
100
+ timeScale: scrollDirection ? -1 : 1,
101
+ overwrite: true
102
+ });
103
+ }, 50), {
104
+ capture: true,
105
+ passive: true
106
+ });
107
+ };
108
+ this.dataDirection === "ltr" ? ltrDirection() : this.dataDirection === "auto" && autoDirection();
109
+ return ()=>{
110
+ this.gsap.set(this.children, {
111
+ clearProps: true
112
+ });
113
+ };
114
+ });
115
+ }
116
+ onResize() {
117
+ cancelAnimationFrame(this.af);
118
+ this.af = requestAnimationFrame(()=>{
119
+ this.cloning();
120
+ this.animation();
121
+ });
122
+ }
123
+ onUpdate() {
124
+ this.templates();
125
+ this.cloning();
126
+ this.skewed();
127
+ this.animation();
128
+ this.onResize = this.onResize.bind(this);
129
+ this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150));
130
+ this.resizeObserver.observe(this);
131
+ }
132
+ connectedCallback() {
133
+ this.onUpdate();
134
+ }
135
+ disconnectedCallback() {
136
+ this.matchMedia.remove();
137
+ document.fonts.removeEventListener("loadingdone", this.onUpdate);
138
+ }
139
+ }
140
+ customElements.define("marquee-content", $4fa36e821943b400$var$MarqueeContent);
141
+
142
+
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,qCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU;QACtC,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,IAAI,CAAC,SAAS,GAAG,CAAC,4GAA4G,EAAE,IAAI,CAAC,SAAS,CAAC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AO,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,UAAU,CAAC,MAAM;QAEtB,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() {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.matchMedia = this.gsap.matchMedia()\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 this.innerHTML = `<div class=\"marquee-wrapper\"><div class=\"marquee-inner\" style=\"display: inline-block; white-space: nowrap;\">${this.innerHTML}</div></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.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 let abs = Math.abs(parseInt(this.dataSkew))\n let style = this.style\n\n this.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 this.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 let 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 let scrollTimer\n\n addEventListener('scroll', this.debounce(() => {\n let 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 this.dataDirection === 'ltr'\n ? ltrDirection()\n : this.dataDirection === 'auto'\n ? autoDirection()\n : null\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.matchMedia.remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.define('marquee-content', MarqueeContent)\n"],"names":[],"version":3,"file":"index.js.map"}
@@ -0,0 +1,145 @@
1
+ var $cf838c15c8b009ba$exports = {};
2
+ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
3
+ static registerGSAP(gsap) {
4
+ $cf838c15c8b009ba$var$MarqueeContent.gsap = gsap;
5
+ }
6
+ constructor(){
7
+ super();
8
+ this.gsap = $cf838c15c8b009ba$var$MarqueeContent.gsap || window.gsap;
9
+ this.matchMedia = this.gsap.matchMedia();
10
+ this.dataSkew = this.dataset.mcSkew;
11
+ this.dataDuration = this.dataset.mcDuration || 20;
12
+ this.dataDirection = this.dataset.mcDirection;
13
+ this.dataMaxWidth = this.dataset.mcMax;
14
+ this.dataMinWidth = this.dataset.mcMin;
15
+ this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
16
+ this.debounce();
17
+ }
18
+ debounce(fn, delay) {
19
+ let timer;
20
+ return (...args)=>{
21
+ if (timer) clearTimeout(timer);
22
+ timer = setTimeout(()=>fn(...args), delay);
23
+ };
24
+ }
25
+ templates() {
26
+ this.innerHTML = `<div class="marquee-wrapper"><div class="marquee-inner" style="display: inline-block; white-space: nowrap;">${this.innerHTML}</div></div>`;
27
+ }
28
+ cloning() {
29
+ const removingClones = ()=>{
30
+ while(this.childElementCount > 1)this.removeChild(this.lastChild);
31
+ };
32
+ removingClones();
33
+ this.matchMedia.add(this.breakpoint, ()=>{
34
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
35
+ if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
36
+ let cloned = this.firstElementChild;
37
+ let clone = cloned.cloneNode(true);
38
+ cloned.parentNode.append(clone);
39
+ }
40
+ return ()=>{
41
+ removingClones();
42
+ };
43
+ });
44
+ }
45
+ skewed() {
46
+ if (!this.dataSkew) return;
47
+ let abs = Math.abs(parseInt(this.dataSkew));
48
+ let style = this.style;
49
+ this.matchMedia.add(this.breakpoint, ()=>{
50
+ style.transformOrigin = "center center";
51
+ style.transform = `skew(0deg, ${this.dataSkew}deg)`;
52
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
53
+ return ()=>{
54
+ style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
55
+ };
56
+ });
57
+ }
58
+ animation() {
59
+ let timeLine = this.gsap.timeline();
60
+ timeLine.kill();
61
+ timeLine = null;
62
+ this.gsap.set(this.children, {
63
+ clearProps: true
64
+ });
65
+ this.matchMedia.add(this.breakpoint, ()=>{
66
+ this.gsap.set(this.children, {
67
+ "will-change": "transform"
68
+ });
69
+ const tween = this.gsap.to(this.children, {
70
+ duration: this.dataDuration,
71
+ x: "-100%",
72
+ ease: "none",
73
+ repeat: -1,
74
+ scrollTrigger: {
75
+ trigger: this,
76
+ start: "-=50% bottom",
77
+ end: "bottom top",
78
+ toggleActions: "resume pause resume pause"
79
+ }
80
+ }).totalProgress(0.5);
81
+ const ltrDirection = ()=>{
82
+ this.gsap.to(tween, {
83
+ timeScale: -1,
84
+ overwrite: true
85
+ });
86
+ };
87
+ const autoDirection = ()=>{
88
+ let previousScrollPosition = 0;
89
+ const isScrollingDown = ()=>{
90
+ let scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
91
+ let direction = false;
92
+ if (scrollPosition > previousScrollPosition) direction = true;
93
+ else if (scrollPosition < previousScrollPosition) direction = false;
94
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
95
+ return direction;
96
+ };
97
+ let scrollTimer;
98
+ addEventListener("scroll", this.debounce(()=>{
99
+ let scrollDirection = isScrollingDown();
100
+ this.gsap.to(tween, {
101
+ timeScale: scrollDirection ? -1 : 1,
102
+ overwrite: true
103
+ });
104
+ }, 50), {
105
+ capture: true,
106
+ passive: true
107
+ });
108
+ };
109
+ this.dataDirection === "ltr" ? ltrDirection() : this.dataDirection === "auto" && autoDirection();
110
+ return ()=>{
111
+ this.gsap.set(this.children, {
112
+ clearProps: true
113
+ });
114
+ };
115
+ });
116
+ }
117
+ onResize() {
118
+ cancelAnimationFrame(this.af);
119
+ this.af = requestAnimationFrame(()=>{
120
+ this.cloning();
121
+ this.animation();
122
+ });
123
+ }
124
+ onUpdate() {
125
+ this.templates();
126
+ this.cloning();
127
+ this.skewed();
128
+ this.animation();
129
+ this.onResize = this.onResize.bind(this);
130
+ this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150));
131
+ this.resizeObserver.observe(this);
132
+ }
133
+ connectedCallback() {
134
+ this.onUpdate();
135
+ }
136
+ disconnectedCallback() {
137
+ this.matchMedia.remove();
138
+ document.fonts.removeEventListener("loadingdone", this.onUpdate);
139
+ }
140
+ }
141
+ customElements.define("marquee-content", $cf838c15c8b009ba$var$MarqueeContent);
142
+
143
+
144
+ export {$cf838c15c8b009ba$exports as default};
145
+ //# sourceMappingURL=index.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,qCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU;QACtC,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,IAAI,CAAC,SAAS,GAAG,CAAC,4GAA4G,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;IAChK;IAEA,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C,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,UAAU,CAAC,MAAM;QAEtB,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() {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.matchMedia = this.gsap.matchMedia()\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 this.innerHTML = `<div class=\"marquee-wrapper\"><div class=\"marquee-inner\" style=\"display: inline-block; white-space: nowrap;\">${this.innerHTML}</div></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.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 let abs = Math.abs(parseInt(this.dataSkew))\n let style = this.style\n\n this.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 this.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 let 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 let scrollTimer\n\n addEventListener('scroll', this.debounce(() => {\n let 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 this.dataDirection === 'ltr'\n ? ltrDirection()\n : this.dataDirection === 'auto'\n ? autoDirection()\n : null\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.matchMedia.remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.define('marquee-content', MarqueeContent)\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": "1.8.0",
3
+ "version": "1.9.1",
4
4
  "description": "Infinite marquee animation with GSAP",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
@@ -8,35 +8,34 @@
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/ux-ui-pro/marquee-content.git"
10
10
  },
11
- "files": [
12
- "dist",
13
- "src"
14
- ],
15
- "main": "src/js/marquee-content.js",
16
11
  "bugs": {
17
12
  "url": "https://github.com/ux-ui-pro/marquee-content/issues"
18
13
  },
19
- "type": "module",
14
+ "source": "src/index.js",
15
+ "main": "dist/index.js",
16
+ "module": "dist/index.module.js",
20
17
  "scripts": {
21
- "serve": "gulp",
22
- "build": "gulp build --build"
23
- },
24
- "dependencies": {
25
- "gsap": "^3.11.5"
18
+ "serve": "parcel watch",
19
+ "build": "parcel build",
20
+ "clean": "rm -rf dist .parcel-cache"
26
21
  },
27
22
  "devDependencies": {
28
- "browser-sync": "^2.27.7",
29
- "del": "^6.0.0",
30
- "gulp": "^4.0.2",
31
- "gulp-file-include": "^2.3.0",
32
- "gulp-if": "^3.0.0",
33
- "gulp-newer": "^1.4.0",
34
- "gulp-rename": "^2.0.0",
35
- "gulp-replace": "^1.1.3",
36
- "webpack": "^5.69.1",
37
- "webpack-stream": "^7.0.0"
23
+ "parcel": "^2.8.3"
38
24
  },
39
25
  "keywords": [
40
- "marquee animation"
26
+ "marquee",
27
+ "scroller",
28
+ "animation",
29
+ "ticker",
30
+ "reel",
31
+ "running text",
32
+ "scrolling text",
33
+ "ui",
34
+ "custom",
35
+ "clones",
36
+ "filler",
37
+ "css",
38
+ "effects",
39
+ "gsap"
41
40
  ]
42
- }
41
+ }
package/src/index.js ADDED
@@ -0,0 +1,187 @@
1
+ class MarqueeContent extends HTMLElement {
2
+ static registerGSAP(gsap) {
3
+ MarqueeContent.gsap = gsap
4
+ }
5
+
6
+ constructor() {
7
+ super()
8
+
9
+ this.gsap = MarqueeContent.gsap || window.gsap
10
+ this.matchMedia = this.gsap.matchMedia()
11
+ this.dataSkew = this.dataset.mcSkew
12
+ this.dataDuration = this.dataset.mcDuration || 20
13
+ this.dataDirection = this.dataset.mcDirection
14
+ this.dataMaxWidth = this.dataset.mcMax
15
+ this.dataMinWidth = this.dataset.mcMin
16
+ this.breakpoint = this.dataMaxWidth
17
+ ? `(max-width: ${this.dataMaxWidth - 0.02}px)`
18
+ : this.dataMinWidth
19
+ ? `(min-width: ${this.dataMinWidth}px)`
20
+ : ''
21
+ this.debounce()
22
+ }
23
+
24
+ debounce(fn, delay) {
25
+ let timer
26
+
27
+ return (...args) => {
28
+ if (timer) clearTimeout(timer)
29
+ timer = setTimeout(() => fn(...args), delay)
30
+ }
31
+ }
32
+
33
+ templates() {
34
+ this.innerHTML = `<div class="marquee-wrapper"><div class="marquee-inner" style="display: inline-block; white-space: nowrap;">${this.innerHTML}</div></div>`
35
+ }
36
+
37
+ cloning() {
38
+ const removingClones = () => {
39
+ while (this.childElementCount > 1) {
40
+ this.removeChild(this.lastChild)
41
+ }
42
+ }
43
+
44
+ removingClones()
45
+
46
+ this.matchMedia.add(this.breakpoint, () => {
47
+ let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
48
+
49
+ if (this.childElementCount < requiredQuantity) {
50
+ for (let i = 1; i < requiredQuantity; i++) {
51
+ let cloned = this.firstElementChild
52
+ let clone = cloned.cloneNode(true)
53
+ cloned.parentNode.append(clone)
54
+ }
55
+ }
56
+
57
+ return () => {
58
+ removingClones()
59
+ }
60
+ })
61
+ }
62
+
63
+ skewed() {
64
+ if (!this.dataSkew) return
65
+
66
+ let abs = Math.abs(parseInt(this.dataSkew))
67
+ let style = this.style
68
+
69
+ this.matchMedia.add(this.breakpoint, () => {
70
+ style.transformOrigin = 'center center'
71
+ style.transform = `skew(0deg, ${this.dataSkew}deg)`
72
+ style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
73
+
74
+ return () => {
75
+ style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
76
+ }
77
+ })
78
+ }
79
+
80
+ animation() {
81
+ let timeLine = this.gsap.timeline()
82
+
83
+ timeLine.kill()
84
+ timeLine = null
85
+
86
+ this.gsap.set(this.children, { clearProps: true })
87
+
88
+ this.matchMedia.add(this.breakpoint, () => {
89
+ this.gsap.set(this.children, { 'will-change': 'transform' })
90
+
91
+ const tween = this.gsap.to(this.children, {
92
+ duration: this.dataDuration,
93
+ x: '-100%',
94
+ ease: 'none',
95
+ repeat: -1,
96
+ scrollTrigger: {
97
+ trigger: this,
98
+ start: '-=50% bottom',
99
+ end: 'bottom top',
100
+ toggleActions: 'resume pause resume pause',
101
+ },
102
+ }).totalProgress(0.5)
103
+
104
+ const ltrDirection = () => {
105
+ this.gsap.to(tween, {
106
+ timeScale: -1,
107
+ overwrite: true,
108
+ })
109
+ }
110
+
111
+ const autoDirection = () => {
112
+ let previousScrollPosition = 0
113
+
114
+ const isScrollingDown = () => {
115
+ let scrollPosition = window.pageYOffset || document.documentElement.scrollTop
116
+
117
+ let direction = false
118
+
119
+ if (scrollPosition > previousScrollPosition) {
120
+ direction = true
121
+ } else if (scrollPosition < previousScrollPosition) {
122
+ direction = false
123
+ }
124
+
125
+ previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
126
+
127
+ return direction
128
+ }
129
+
130
+ let scrollTimer
131
+
132
+ addEventListener('scroll', this.debounce(() => {
133
+ let scrollDirection = isScrollingDown()
134
+
135
+ this.gsap.to(tween, {
136
+ timeScale: scrollDirection ? -1 : 1,
137
+ overwrite: true,
138
+ })
139
+ }, 50), {
140
+ capture: true, passive: true
141
+ })
142
+ }
143
+
144
+ this.dataDirection === 'ltr'
145
+ ? ltrDirection()
146
+ : this.dataDirection === 'auto'
147
+ ? autoDirection()
148
+ : null
149
+
150
+ return () => {
151
+ this.gsap.set(this.children, { clearProps: true })
152
+ }
153
+ })
154
+ }
155
+
156
+ onResize() {
157
+ cancelAnimationFrame(this.af)
158
+
159
+ this.af = requestAnimationFrame(() => {
160
+ this.cloning()
161
+ this.animation()
162
+ })
163
+ }
164
+
165
+ onUpdate() {
166
+ this.templates()
167
+ this.cloning()
168
+ this.skewed()
169
+ this.animation()
170
+
171
+ this.onResize = this.onResize.bind(this)
172
+ this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))
173
+ this.resizeObserver.observe(this)
174
+ }
175
+
176
+ connectedCallback() {
177
+ this.onUpdate()
178
+ }
179
+
180
+ disconnectedCallback() {
181
+ this.matchMedia.remove()
182
+
183
+ document.fonts.removeEventListener('loadingdone', this.onUpdate)
184
+ }
185
+ }
186
+
187
+ customElements.define('marquee-content', MarqueeContent)