marquee-content 1.9.1 → 1.9.3
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 +2 -2
- package/dist/index.js +25 -14
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +25 -14
- package/dist/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +36 -21
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](https://github.com/ux-ui-pro/marquee-content)
|
|
10
10
|
[](https://www.npmjs.org/package/marquee-content)
|
|
11
11
|
|
|
12
|
-
<h3><a href="https://codepen.io/ux-ui/
|
|
12
|
+
<h3><a href="https://codepen.io/ux-ui/full/dygzqYm">Demo</a></h3>
|
|
13
13
|
|
|
14
14
|
</div>
|
|
15
15
|
<br>
|
|
@@ -35,7 +35,7 @@ import MarqueeContent from 'marquee-content'
|
|
|
35
35
|
gsap.registerPlugin(ScrollTrigger)
|
|
36
36
|
MarqueeContent.registerGSAP(gsap)
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
new MarqueeContent()
|
|
39
39
|
```
|
|
40
40
|
<br>
|
|
41
41
|
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
2
2
|
static registerGSAP(gsap) {
|
|
3
3
|
$4fa36e821943b400$var$MarqueeContent.gsap = gsap;
|
|
4
4
|
}
|
|
5
|
-
constructor(){
|
|
5
|
+
constructor(query){
|
|
6
6
|
super();
|
|
7
7
|
this.gsap = $4fa36e821943b400$var$MarqueeContent.gsap || window.gsap;
|
|
8
|
-
this.
|
|
8
|
+
this.MM = this.gsap.matchMedia(query);
|
|
9
9
|
this.dataSkew = this.dataset.mcSkew;
|
|
10
10
|
this.dataDuration = this.dataset.mcDuration || 20;
|
|
11
11
|
this.dataDirection = this.dataset.mcDirection;
|
|
@@ -13,6 +13,13 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
13
13
|
this.dataMinWidth = this.dataset.mcMin;
|
|
14
14
|
this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
|
|
15
15
|
this.debounce();
|
|
16
|
+
window.matchMedia = window.matchMedia || function() {
|
|
17
|
+
return {
|
|
18
|
+
matches: false,
|
|
19
|
+
addListener: function() {},
|
|
20
|
+
removeListener: function() {}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
16
23
|
}
|
|
17
24
|
debounce(fn, delay) {
|
|
18
25
|
let timer;
|
|
@@ -22,14 +29,18 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
22
29
|
};
|
|
23
30
|
}
|
|
24
31
|
templates() {
|
|
25
|
-
|
|
32
|
+
const div = document.createElement("div");
|
|
33
|
+
div.style.display = "inline-block";
|
|
34
|
+
div.style.whiteSpace = "nowrap";
|
|
35
|
+
while(this.firstChild)div.appendChild(this.firstChild);
|
|
36
|
+
this.appendChild(div);
|
|
26
37
|
}
|
|
27
38
|
cloning() {
|
|
28
39
|
const removingClones = ()=>{
|
|
29
40
|
while(this.childElementCount > 1)this.removeChild(this.lastChild);
|
|
30
41
|
};
|
|
31
42
|
removingClones();
|
|
32
|
-
this.
|
|
43
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
33
44
|
let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
|
|
34
45
|
if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
|
|
35
46
|
let cloned = this.firstElementChild;
|
|
@@ -43,9 +54,9 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
43
54
|
}
|
|
44
55
|
skewed() {
|
|
45
56
|
if (!this.dataSkew) return;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.
|
|
57
|
+
const abs = Math.abs(parseInt(this.dataSkew));
|
|
58
|
+
const style = this.style;
|
|
59
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
49
60
|
style.transformOrigin = "center center";
|
|
50
61
|
style.transform = `skew(0deg, ${this.dataSkew}deg)`;
|
|
51
62
|
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
@@ -61,7 +72,7 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
61
72
|
this.gsap.set(this.children, {
|
|
62
73
|
clearProps: true
|
|
63
74
|
});
|
|
64
|
-
this.
|
|
75
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
65
76
|
this.gsap.set(this.children, {
|
|
66
77
|
"will-change": "transform"
|
|
67
78
|
});
|
|
@@ -86,18 +97,17 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
86
97
|
const autoDirection = ()=>{
|
|
87
98
|
let previousScrollPosition = 0;
|
|
88
99
|
const isScrollingDown = ()=>{
|
|
89
|
-
|
|
100
|
+
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
90
101
|
let direction = false;
|
|
91
102
|
if (scrollPosition > previousScrollPosition) direction = true;
|
|
92
103
|
else if (scrollPosition < previousScrollPosition) direction = false;
|
|
93
104
|
previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
|
|
94
105
|
return direction;
|
|
95
106
|
};
|
|
96
|
-
let scrollTimer;
|
|
97
107
|
addEventListener("scroll", this.debounce(()=>{
|
|
98
|
-
|
|
108
|
+
const scrollDirection = isScrollingDown();
|
|
99
109
|
this.gsap.to(tween, {
|
|
100
|
-
timeScale: scrollDirection ?
|
|
110
|
+
timeScale: scrollDirection ? 1 : -1,
|
|
101
111
|
overwrite: true
|
|
102
112
|
});
|
|
103
113
|
}, 50), {
|
|
@@ -105,7 +115,8 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
105
115
|
passive: true
|
|
106
116
|
});
|
|
107
117
|
};
|
|
108
|
-
this.dataDirection === "ltr"
|
|
118
|
+
if (this.dataDirection === "ltr") ltrDirection();
|
|
119
|
+
else if (this.dataDirection === "auto") autoDirection();
|
|
109
120
|
return ()=>{
|
|
110
121
|
this.gsap.set(this.children, {
|
|
111
122
|
clearProps: true
|
|
@@ -133,7 +144,7 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
133
144
|
this.onUpdate();
|
|
134
145
|
}
|
|
135
146
|
disconnectedCallback() {
|
|
136
|
-
this.
|
|
147
|
+
this.MM.remove();
|
|
137
148
|
document.fonts.removeEventListener("loadingdone", this.onUpdate);
|
|
138
149
|
}
|
|
139
150
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,
|
|
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,IAA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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.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -3,10 +3,10 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
3
3
|
static registerGSAP(gsap) {
|
|
4
4
|
$cf838c15c8b009ba$var$MarqueeContent.gsap = gsap;
|
|
5
5
|
}
|
|
6
|
-
constructor(){
|
|
6
|
+
constructor(query){
|
|
7
7
|
super();
|
|
8
8
|
this.gsap = $cf838c15c8b009ba$var$MarqueeContent.gsap || window.gsap;
|
|
9
|
-
this.
|
|
9
|
+
this.MM = this.gsap.matchMedia(query);
|
|
10
10
|
this.dataSkew = this.dataset.mcSkew;
|
|
11
11
|
this.dataDuration = this.dataset.mcDuration || 20;
|
|
12
12
|
this.dataDirection = this.dataset.mcDirection;
|
|
@@ -14,6 +14,13 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
14
14
|
this.dataMinWidth = this.dataset.mcMin;
|
|
15
15
|
this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
|
|
16
16
|
this.debounce();
|
|
17
|
+
window.matchMedia = window.matchMedia || function() {
|
|
18
|
+
return {
|
|
19
|
+
matches: false,
|
|
20
|
+
addListener: function() {},
|
|
21
|
+
removeListener: function() {}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
17
24
|
}
|
|
18
25
|
debounce(fn, delay) {
|
|
19
26
|
let timer;
|
|
@@ -23,14 +30,18 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
23
30
|
};
|
|
24
31
|
}
|
|
25
32
|
templates() {
|
|
26
|
-
|
|
33
|
+
const div = document.createElement("div");
|
|
34
|
+
div.style.display = "inline-block";
|
|
35
|
+
div.style.whiteSpace = "nowrap";
|
|
36
|
+
while(this.firstChild)div.appendChild(this.firstChild);
|
|
37
|
+
this.appendChild(div);
|
|
27
38
|
}
|
|
28
39
|
cloning() {
|
|
29
40
|
const removingClones = ()=>{
|
|
30
41
|
while(this.childElementCount > 1)this.removeChild(this.lastChild);
|
|
31
42
|
};
|
|
32
43
|
removingClones();
|
|
33
|
-
this.
|
|
44
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
34
45
|
let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
|
|
35
46
|
if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
|
|
36
47
|
let cloned = this.firstElementChild;
|
|
@@ -44,9 +55,9 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
44
55
|
}
|
|
45
56
|
skewed() {
|
|
46
57
|
if (!this.dataSkew) return;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
58
|
+
const abs = Math.abs(parseInt(this.dataSkew));
|
|
59
|
+
const style = this.style;
|
|
60
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
50
61
|
style.transformOrigin = "center center";
|
|
51
62
|
style.transform = `skew(0deg, ${this.dataSkew}deg)`;
|
|
52
63
|
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
@@ -62,7 +73,7 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
62
73
|
this.gsap.set(this.children, {
|
|
63
74
|
clearProps: true
|
|
64
75
|
});
|
|
65
|
-
this.
|
|
76
|
+
this.MM.add(this.breakpoint, ()=>{
|
|
66
77
|
this.gsap.set(this.children, {
|
|
67
78
|
"will-change": "transform"
|
|
68
79
|
});
|
|
@@ -87,18 +98,17 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
87
98
|
const autoDirection = ()=>{
|
|
88
99
|
let previousScrollPosition = 0;
|
|
89
100
|
const isScrollingDown = ()=>{
|
|
90
|
-
|
|
101
|
+
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
91
102
|
let direction = false;
|
|
92
103
|
if (scrollPosition > previousScrollPosition) direction = true;
|
|
93
104
|
else if (scrollPosition < previousScrollPosition) direction = false;
|
|
94
105
|
previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
|
|
95
106
|
return direction;
|
|
96
107
|
};
|
|
97
|
-
let scrollTimer;
|
|
98
108
|
addEventListener("scroll", this.debounce(()=>{
|
|
99
|
-
|
|
109
|
+
const scrollDirection = isScrollingDown();
|
|
100
110
|
this.gsap.to(tween, {
|
|
101
|
-
timeScale: scrollDirection ?
|
|
111
|
+
timeScale: scrollDirection ? 1 : -1,
|
|
102
112
|
overwrite: true
|
|
103
113
|
});
|
|
104
114
|
}, 50), {
|
|
@@ -106,7 +116,8 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
106
116
|
passive: true
|
|
107
117
|
});
|
|
108
118
|
};
|
|
109
|
-
this.dataDirection === "ltr"
|
|
119
|
+
if (this.dataDirection === "ltr") ltrDirection();
|
|
120
|
+
else if (this.dataDirection === "auto") autoDirection();
|
|
110
121
|
return ()=>{
|
|
111
122
|
this.gsap.set(this.children, {
|
|
112
123
|
clearProps: true
|
|
@@ -134,7 +145,7 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
134
145
|
this.onUpdate();
|
|
135
146
|
}
|
|
136
147
|
disconnectedCallback() {
|
|
137
|
-
this.
|
|
148
|
+
this.MM.remove();
|
|
138
149
|
document.fonts.removeEventListener("loadingdone", this.onUpdate);
|
|
139
150
|
}
|
|
140
151
|
}
|
package/dist/index.module.js.map
CHANGED
|
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AChB,WAAW,kBAAkB,IAAI,EAAE;wBACnC,WAAW,IAAI;oBACnB;gBACJ,GAAG,KAAK;oBACJ,SAAS,IAAI;oBAAE,SAAS,IAAI;gBAChC;YACJ;YAEA,IAAI,IAAI,CAAC,aAAa,KAAK,OACvB;iBACG,IAAI,IAAI,CAAC,aAAa,KAAK,QAC9B;YAGJ,OAAO,IAAM;gBACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAAE,YAAY,IAAI;gBAAC;YACpD;QACJ;IACJ;IAEA,WAAW;QACP,qBAAqB,IAAI,CAAC,EAAE;QAE5B,IAAI,CAAC,EAAE,GAAG,sBAAsB,IAAM;YAClC,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,SAAS;QAClB;IACJ;IAEA,WAAW;QACP,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,SAAS;QAEd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI;QACvC,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG;QACjF,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI;IACpC;IAEA,oBAAoB;QAChB,IAAI,CAAC,QAAQ;IACjB;IAEA,uBAAuB;QACnB,IAAI,CAAC,EAAE,CAAC,MAAM;QAEd,SAAS,KAAK,CAAC,mBAAmB,CAAC,eAAe,IAAI,CAAC,QAAQ;IACnE;AACJ;AAEA,eAAe,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"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -3,11 +3,11 @@ class MarqueeContent extends HTMLElement {
|
|
|
3
3
|
MarqueeContent.gsap = gsap
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
constructor() {
|
|
6
|
+
constructor(query) {
|
|
7
7
|
super()
|
|
8
8
|
|
|
9
9
|
this.gsap = MarqueeContent.gsap || window.gsap
|
|
10
|
-
this.
|
|
10
|
+
this.MM = this.gsap.matchMedia(query)
|
|
11
11
|
this.dataSkew = this.dataset.mcSkew
|
|
12
12
|
this.dataDuration = this.dataset.mcDuration || 20
|
|
13
13
|
this.dataDirection = this.dataset.mcDirection
|
|
@@ -19,6 +19,14 @@ class MarqueeContent extends HTMLElement {
|
|
|
19
19
|
? `(min-width: ${this.dataMinWidth}px)`
|
|
20
20
|
: ''
|
|
21
21
|
this.debounce()
|
|
22
|
+
|
|
23
|
+
window.matchMedia = window.matchMedia || function() {
|
|
24
|
+
return {
|
|
25
|
+
matches : false,
|
|
26
|
+
addListener : function() {},
|
|
27
|
+
removeListener: function() {}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
debounce(fn, delay) {
|
|
@@ -31,7 +39,16 @@ class MarqueeContent extends HTMLElement {
|
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
templates() {
|
|
34
|
-
|
|
42
|
+
const div = document.createElement('div')
|
|
43
|
+
|
|
44
|
+
div.style.display = 'inline-block'
|
|
45
|
+
div.style.whiteSpace = 'nowrap'
|
|
46
|
+
|
|
47
|
+
while (this.firstChild) {
|
|
48
|
+
div.appendChild(this.firstChild)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.appendChild(div)
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
cloning() {
|
|
@@ -43,7 +60,7 @@ class MarqueeContent extends HTMLElement {
|
|
|
43
60
|
|
|
44
61
|
removingClones()
|
|
45
62
|
|
|
46
|
-
this.
|
|
63
|
+
this.MM.add(this.breakpoint, () => {
|
|
47
64
|
let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
|
|
48
65
|
|
|
49
66
|
if (this.childElementCount < requiredQuantity) {
|
|
@@ -63,10 +80,10 @@ class MarqueeContent extends HTMLElement {
|
|
|
63
80
|
skewed() {
|
|
64
81
|
if (!this.dataSkew) return
|
|
65
82
|
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
const abs = Math.abs(parseInt(this.dataSkew))
|
|
84
|
+
const style = this.style
|
|
68
85
|
|
|
69
|
-
this.
|
|
86
|
+
this.MM.add(this.breakpoint, () => {
|
|
70
87
|
style.transformOrigin = 'center center'
|
|
71
88
|
style.transform = `skew(0deg, ${this.dataSkew}deg)`
|
|
72
89
|
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
|
|
@@ -85,7 +102,7 @@ class MarqueeContent extends HTMLElement {
|
|
|
85
102
|
|
|
86
103
|
this.gsap.set(this.children, { clearProps: true })
|
|
87
104
|
|
|
88
|
-
this.
|
|
105
|
+
this.MM.add(this.breakpoint, () => {
|
|
89
106
|
this.gsap.set(this.children, { 'will-change': 'transform' })
|
|
90
107
|
|
|
91
108
|
const tween = this.gsap.to(this.children, {
|
|
@@ -104,7 +121,7 @@ class MarqueeContent extends HTMLElement {
|
|
|
104
121
|
const ltrDirection = () => {
|
|
105
122
|
this.gsap.to(tween, {
|
|
106
123
|
timeScale: -1,
|
|
107
|
-
overwrite: true
|
|
124
|
+
overwrite: true
|
|
108
125
|
})
|
|
109
126
|
}
|
|
110
127
|
|
|
@@ -112,7 +129,7 @@ class MarqueeContent extends HTMLElement {
|
|
|
112
129
|
let previousScrollPosition = 0
|
|
113
130
|
|
|
114
131
|
const isScrollingDown = () => {
|
|
115
|
-
|
|
132
|
+
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop
|
|
116
133
|
|
|
117
134
|
let direction = false
|
|
118
135
|
|
|
@@ -127,13 +144,11 @@ class MarqueeContent extends HTMLElement {
|
|
|
127
144
|
return direction
|
|
128
145
|
}
|
|
129
146
|
|
|
130
|
-
let scrollTimer
|
|
131
|
-
|
|
132
147
|
addEventListener('scroll', this.debounce(() => {
|
|
133
|
-
|
|
148
|
+
const scrollDirection = isScrollingDown()
|
|
134
149
|
|
|
135
150
|
this.gsap.to(tween, {
|
|
136
|
-
timeScale: scrollDirection ?
|
|
151
|
+
timeScale: scrollDirection ? 1 : -1,
|
|
137
152
|
overwrite: true,
|
|
138
153
|
})
|
|
139
154
|
}, 50), {
|
|
@@ -141,11 +156,11 @@ class MarqueeContent extends HTMLElement {
|
|
|
141
156
|
})
|
|
142
157
|
}
|
|
143
158
|
|
|
144
|
-
this.dataDirection === 'ltr'
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
if (this.dataDirection === 'ltr') {
|
|
160
|
+
ltrDirection()
|
|
161
|
+
} else if (this.dataDirection === 'auto') {
|
|
162
|
+
autoDirection()
|
|
163
|
+
}
|
|
149
164
|
|
|
150
165
|
return () => {
|
|
151
166
|
this.gsap.set(this.children, { clearProps: true })
|
|
@@ -178,10 +193,10 @@ class MarqueeContent extends HTMLElement {
|
|
|
178
193
|
}
|
|
179
194
|
|
|
180
195
|
disconnectedCallback() {
|
|
181
|
-
this.
|
|
196
|
+
this.MM.remove()
|
|
182
197
|
|
|
183
198
|
document.fonts.removeEventListener('loadingdone', this.onUpdate)
|
|
184
199
|
}
|
|
185
200
|
}
|
|
186
201
|
|
|
187
|
-
customElements.define('marquee-content', MarqueeContent)
|
|
202
|
+
customElements.define('marquee-content', MarqueeContent)
|