marquee-content 1.9.10 → 2.0.0
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 +39 -44
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +39 -44
- package/dist/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +50 -60
package/dist/index.js
CHANGED
|
@@ -9,16 +9,14 @@ $parcel$defineInteropFlag(module.exports);
|
|
|
9
9
|
|
|
10
10
|
$parcel$export(module.exports, "default", () => $4fa36e821943b400$export$2e2bcd8739ae039);
|
|
11
11
|
class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
12
|
-
constructor(
|
|
12
|
+
constructor(){
|
|
13
13
|
super();
|
|
14
14
|
this.gsap = $4fa36e821943b400$export$2e2bcd8739ae039.gsap || window.gsap;
|
|
15
|
-
this.MM = this.gsap.matchMedia(
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.dataMinWidth = this.dataset.mcMin;
|
|
21
|
-
this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
|
|
15
|
+
this.MM = this.gsap.matchMedia();
|
|
16
|
+
this.breakpoint = this.dataset.mcMax ? `(max-width: ${this.dataset.mcMax - 0.02}px)` : this.dataset.mcMin ? `(min-width: ${this.dataset.mcMin}px)` : "";
|
|
17
|
+
this.onResize = this.onResize.bind(this);
|
|
18
|
+
this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150));
|
|
19
|
+
this.resizeObserver.observe(this);
|
|
22
20
|
}
|
|
23
21
|
static registerGSAP(gsap) {
|
|
24
22
|
$4fa36e821943b400$export$2e2bcd8739ae039.gsap = gsap;
|
|
@@ -31,11 +29,15 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
templates() {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const wrapper = document.createElement("div");
|
|
33
|
+
wrapper.classList.add("marquee-wrapper");
|
|
34
|
+
const inner = document.createElement("div");
|
|
35
|
+
inner.classList.add("marquee-inner");
|
|
36
|
+
inner.style.display = "inline-block";
|
|
37
|
+
inner.style.whiteSpace = "nowrap";
|
|
38
|
+
while(this.firstChild)inner.appendChild(this.firstChild);
|
|
39
|
+
wrapper.appendChild(inner);
|
|
40
|
+
this.appendChild(wrapper);
|
|
39
41
|
}
|
|
40
42
|
cloning() {
|
|
41
43
|
const removingClones = ()=>{
|
|
@@ -55,12 +57,12 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
55
57
|
});
|
|
56
58
|
}
|
|
57
59
|
skewed() {
|
|
58
|
-
if (!this.
|
|
59
|
-
const abs = Math.abs(parseInt(this.
|
|
60
|
+
if (!this.dataset.mcSkew) return;
|
|
61
|
+
const abs = Math.abs(parseInt(this.dataset.mcSkew));
|
|
60
62
|
const style = this.style;
|
|
61
63
|
this.MM.add(this.breakpoint, ()=>{
|
|
62
64
|
style.transformOrigin = "center center";
|
|
63
|
-
style.transform = `skew(0deg, ${this.
|
|
65
|
+
style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
|
|
64
66
|
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
65
67
|
return ()=>{
|
|
66
68
|
style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
|
|
@@ -79,7 +81,7 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
79
81
|
"will-change": "transform"
|
|
80
82
|
});
|
|
81
83
|
const tween = this.gsap.to(this.children, {
|
|
82
|
-
duration: this.
|
|
84
|
+
duration: this.dataset.mcDuration || 20,
|
|
83
85
|
x: "-100%",
|
|
84
86
|
ease: "none",
|
|
85
87
|
repeat: -1,
|
|
@@ -97,28 +99,27 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
97
99
|
});
|
|
98
100
|
};
|
|
99
101
|
const autoDirection = ()=>{
|
|
100
|
-
let
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
let currentScroll = 0, scrollDirection = 1;
|
|
103
|
+
const handleScroll = ()=>{
|
|
104
|
+
let orientation = window.pageYOffset > currentScroll ? 1 : -1;
|
|
105
|
+
if (orientation !== scrollDirection) {
|
|
106
|
+
this.gsap.to(tween, {
|
|
107
|
+
timeScale: orientation,
|
|
108
|
+
overwrite: true
|
|
109
|
+
});
|
|
110
|
+
scrollDirection = orientation;
|
|
111
|
+
}
|
|
112
|
+
currentScroll = window.pageYOffset;
|
|
108
113
|
};
|
|
109
|
-
addEventListener("scroll",
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
timeScale: scrollDirection ? 1 : -1,
|
|
113
|
-
overwrite: true
|
|
114
|
-
});
|
|
115
|
-
}, 50), {
|
|
114
|
+
addEventListener("scroll", ()=>{
|
|
115
|
+
handleScroll();
|
|
116
|
+
}, {
|
|
116
117
|
capture: true,
|
|
117
118
|
passive: true
|
|
118
119
|
});
|
|
119
120
|
};
|
|
120
|
-
if (this.
|
|
121
|
-
else if (this.
|
|
121
|
+
if (this.dataset.mcDirection === "ltr") ltrDirection();
|
|
122
|
+
else if (this.dataset.mcDirection === "auto") autoDirection();
|
|
122
123
|
return ()=>{
|
|
123
124
|
this.gsap.set(this.children, {
|
|
124
125
|
clearProps: true
|
|
@@ -128,28 +129,22 @@ class $4fa36e821943b400$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
128
129
|
}
|
|
129
130
|
onResize() {
|
|
130
131
|
cancelAnimationFrame(this.af);
|
|
131
|
-
this.af = requestAnimationFrame(()=>{
|
|
132
|
+
if (this.firstElementChild) this.af = requestAnimationFrame(()=>{
|
|
132
133
|
this.cloning();
|
|
133
134
|
this.animation();
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
|
-
|
|
137
|
+
connectedCallback() {
|
|
137
138
|
this.templates();
|
|
138
139
|
this.cloning();
|
|
139
140
|
this.skewed();
|
|
140
141
|
this.animation();
|
|
141
|
-
this.onResize = this.onResize.bind(this);
|
|
142
|
-
this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150));
|
|
143
|
-
this.resizeObserver.observe(this);
|
|
144
|
-
}
|
|
145
|
-
connectedCallback() {
|
|
146
|
-
this.onUpdate();
|
|
147
142
|
}
|
|
148
143
|
disconnectedCallback() {
|
|
149
|
-
|
|
144
|
+
cancelAnimationFrame(this.af);
|
|
150
145
|
}
|
|
151
146
|
}
|
|
152
|
-
customElements.define("marquee-content", $4fa36e821943b400$export$2e2bcd8739ae039);
|
|
147
|
+
customElements.get("marquee-content") || customElements.define("marquee-content", $4fa36e821943b400$export$2e2bcd8739ae039);
|
|
153
148
|
|
|
154
149
|
|
|
155
150
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAe,uDAA6B;IACxC,
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,yCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,GAC9B,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,GAC7C,IAAI,CAAC,OAAO,CAAC,KAAK,GAClB,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GACtC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,eAAe,GAAG,CAAC,sBAAsB,eAAe,MAAM,CAAC,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.breakpoint = this.dataset.mcMax\n ? `(max-width: ${this.dataset.mcMax - 0.02}px)`\n : this.dataset.mcMin\n ? `(min-width: ${this.dataset.mcMin}px)`\n : ''\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 static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\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 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 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.dataset.mcSkew) return\n\n const abs = Math.abs(parseInt(this.dataset.mcSkew))\n const style = this.style\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 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.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(tween, {\n timeScale: -1,\n overwrite: true\n })\n }\n\n const autoDirection = () => {\n let currentScroll = 0,\n scrollDirection = 1\n\n const handleScroll = () => {\n let orientation = (window.pageYOffset > currentScroll) ? 1 : -1\n\n if (orientation !== scrollDirection) {\n this.gsap.to(tween, {\n timeScale: orientation,\n overwrite: true\n })\n\n scrollDirection = orientation\n }\n\n currentScroll = window.pageYOffset\n }\n\n addEventListener('scroll', () => {\n handleScroll()\n }, { 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 this.gsap.set(this.children, { clearProps: true })\n }\n })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n }\n\n connectedCallback() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n }\n\n disconnectedCallback() {\n cancelAnimationFrame(this.af)\n }\n}\n\ncustomElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
|
|
2
|
-
constructor(
|
|
2
|
+
constructor(){
|
|
3
3
|
super();
|
|
4
4
|
this.gsap = $cf838c15c8b009ba$export$2e2bcd8739ae039.gsap || window.gsap;
|
|
5
|
-
this.MM = this.gsap.matchMedia(
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.dataMinWidth = this.dataset.mcMin;
|
|
11
|
-
this.breakpoint = this.dataMaxWidth ? `(max-width: ${this.dataMaxWidth - 0.02}px)` : this.dataMinWidth ? `(min-width: ${this.dataMinWidth}px)` : "";
|
|
5
|
+
this.MM = this.gsap.matchMedia();
|
|
6
|
+
this.breakpoint = this.dataset.mcMax ? `(max-width: ${this.dataset.mcMax - 0.02}px)` : this.dataset.mcMin ? `(min-width: ${this.dataset.mcMin}px)` : "";
|
|
7
|
+
this.onResize = this.onResize.bind(this);
|
|
8
|
+
this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150));
|
|
9
|
+
this.resizeObserver.observe(this);
|
|
12
10
|
}
|
|
13
11
|
static registerGSAP(gsap) {
|
|
14
12
|
$cf838c15c8b009ba$export$2e2bcd8739ae039.gsap = gsap;
|
|
@@ -21,11 +19,15 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
templates() {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const wrapper = document.createElement("div");
|
|
23
|
+
wrapper.classList.add("marquee-wrapper");
|
|
24
|
+
const inner = document.createElement("div");
|
|
25
|
+
inner.classList.add("marquee-inner");
|
|
26
|
+
inner.style.display = "inline-block";
|
|
27
|
+
inner.style.whiteSpace = "nowrap";
|
|
28
|
+
while(this.firstChild)inner.appendChild(this.firstChild);
|
|
29
|
+
wrapper.appendChild(inner);
|
|
30
|
+
this.appendChild(wrapper);
|
|
29
31
|
}
|
|
30
32
|
cloning() {
|
|
31
33
|
const removingClones = ()=>{
|
|
@@ -45,12 +47,12 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
skewed() {
|
|
48
|
-
if (!this.
|
|
49
|
-
const abs = Math.abs(parseInt(this.
|
|
50
|
+
if (!this.dataset.mcSkew) return;
|
|
51
|
+
const abs = Math.abs(parseInt(this.dataset.mcSkew));
|
|
50
52
|
const style = this.style;
|
|
51
53
|
this.MM.add(this.breakpoint, ()=>{
|
|
52
54
|
style.transformOrigin = "center center";
|
|
53
|
-
style.transform = `skew(0deg, ${this.
|
|
55
|
+
style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`;
|
|
54
56
|
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
55
57
|
return ()=>{
|
|
56
58
|
style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
|
|
@@ -69,7 +71,7 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
69
71
|
"will-change": "transform"
|
|
70
72
|
});
|
|
71
73
|
const tween = this.gsap.to(this.children, {
|
|
72
|
-
duration: this.
|
|
74
|
+
duration: this.dataset.mcDuration || 20,
|
|
73
75
|
x: "-100%",
|
|
74
76
|
ease: "none",
|
|
75
77
|
repeat: -1,
|
|
@@ -87,28 +89,27 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
87
89
|
});
|
|
88
90
|
};
|
|
89
91
|
const autoDirection = ()=>{
|
|
90
|
-
let
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
let currentScroll = 0, scrollDirection = 1;
|
|
93
|
+
const handleScroll = ()=>{
|
|
94
|
+
let orientation = window.pageYOffset > currentScroll ? 1 : -1;
|
|
95
|
+
if (orientation !== scrollDirection) {
|
|
96
|
+
this.gsap.to(tween, {
|
|
97
|
+
timeScale: orientation,
|
|
98
|
+
overwrite: true
|
|
99
|
+
});
|
|
100
|
+
scrollDirection = orientation;
|
|
101
|
+
}
|
|
102
|
+
currentScroll = window.pageYOffset;
|
|
98
103
|
};
|
|
99
|
-
addEventListener("scroll",
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
timeScale: scrollDirection ? 1 : -1,
|
|
103
|
-
overwrite: true
|
|
104
|
-
});
|
|
105
|
-
}, 50), {
|
|
104
|
+
addEventListener("scroll", ()=>{
|
|
105
|
+
handleScroll();
|
|
106
|
+
}, {
|
|
106
107
|
capture: true,
|
|
107
108
|
passive: true
|
|
108
109
|
});
|
|
109
110
|
};
|
|
110
|
-
if (this.
|
|
111
|
-
else if (this.
|
|
111
|
+
if (this.dataset.mcDirection === "ltr") ltrDirection();
|
|
112
|
+
else if (this.dataset.mcDirection === "auto") autoDirection();
|
|
112
113
|
return ()=>{
|
|
113
114
|
this.gsap.set(this.children, {
|
|
114
115
|
clearProps: true
|
|
@@ -118,28 +119,22 @@ class $cf838c15c8b009ba$export$2e2bcd8739ae039 extends HTMLElement {
|
|
|
118
119
|
}
|
|
119
120
|
onResize() {
|
|
120
121
|
cancelAnimationFrame(this.af);
|
|
121
|
-
this.af = requestAnimationFrame(()=>{
|
|
122
|
+
if (this.firstElementChild) this.af = requestAnimationFrame(()=>{
|
|
122
123
|
this.cloning();
|
|
123
124
|
this.animation();
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
|
-
|
|
127
|
+
connectedCallback() {
|
|
127
128
|
this.templates();
|
|
128
129
|
this.cloning();
|
|
129
130
|
this.skewed();
|
|
130
131
|
this.animation();
|
|
131
|
-
this.onResize = this.onResize.bind(this);
|
|
132
|
-
this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150));
|
|
133
|
-
this.resizeObserver.observe(this);
|
|
134
|
-
}
|
|
135
|
-
connectedCallback() {
|
|
136
|
-
this.onUpdate();
|
|
137
132
|
}
|
|
138
133
|
disconnectedCallback() {
|
|
139
|
-
|
|
134
|
+
cancelAnimationFrame(this.af);
|
|
140
135
|
}
|
|
141
136
|
}
|
|
142
|
-
customElements.define("marquee-content", $cf838c15c8b009ba$export$2e2bcd8739ae039);
|
|
137
|
+
customElements.get("marquee-content") || customElements.define("marquee-content", $cf838c15c8b009ba$export$2e2bcd8739ae039);
|
|
143
138
|
|
|
144
139
|
|
|
145
140
|
export {$cf838c15c8b009ba$export$2e2bcd8739ae039 as default};
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAe,uDAA6B;IACxC,
|
|
1
|
+
{"mappings":"AAAe,uDAA6B;IACxC,aAAc;QACV,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,yCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,GAC9B,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,GAC7C,IAAI,CAAC,OAAO,CAAC,KAAK,GAClB,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GACtC,EAAE;QAER,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,OAAO,aAAa,IAAI,EAAE;QACtB,yCAAe,IAAI,GAAG;IAC1B;IAEA,SAAS,EAAE,EAAE,KAAK,EAAE;QAChB,IAAI;QAEJ,OAAO,CAAC,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wBACjC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO;4BAChB,WAAW;4BACX,WAAW,IAAI;wBACnB;wBAEA,kBAAkB;oBACtB,CAAC;oBAED,gBAAgB,OAAO,WAAW;gBACtC;gBAEA,iBAAiB,UAAU,IAAM;oBAC7B;gBACJ,GAAG;oBAAE,SAAS,IAAI;oBAAE,SAAS,IAAI;gBAAC;YACtC;YAEA,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,OAC7B;iBACG,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,QACpC;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,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,EAAE,GAAG,sBAAsB,IAAM;YAClC,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,SAAS;QAClB;IAER;IAEA,oBAAoB;QAChB,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,SAAS;IAClB;IAEA,uBAAuB;QACnB,qBAAqB,IAAI,CAAC,EAAE;IAChC;AACJ;AAEA,eAAe,GAAG,CAAC,sBAAsB,eAAe,MAAM,CAAC,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.breakpoint = this.dataset.mcMax\n ? `(max-width: ${this.dataset.mcMax - 0.02}px)`\n : this.dataset.mcMin\n ? `(min-width: ${this.dataset.mcMin}px)`\n : ''\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 static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\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 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 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.dataset.mcSkew) return\n\n const abs = Math.abs(parseInt(this.dataset.mcSkew))\n const style = this.style\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 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.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(tween, {\n timeScale: -1,\n overwrite: true\n })\n }\n\n const autoDirection = () => {\n let currentScroll = 0,\n scrollDirection = 1\n\n const handleScroll = () => {\n let orientation = (window.pageYOffset > currentScroll) ? 1 : -1\n\n if (orientation !== scrollDirection) {\n this.gsap.to(tween, {\n timeScale: orientation,\n overwrite: true\n })\n\n scrollDirection = orientation\n }\n\n currentScroll = window.pageYOffset\n }\n\n addEventListener('scroll', () => {\n handleScroll()\n }, { 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 this.gsap.set(this.children, { clearProps: true })\n }\n })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n if (this.firstElementChild) {\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n }\n\n connectedCallback() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n }\n\n disconnectedCallback() {\n cancelAnimationFrame(this.af)\n }\n}\n\ncustomElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
export default class MarqueeContent extends HTMLElement {
|
|
2
|
-
constructor(
|
|
2
|
+
constructor() {
|
|
3
3
|
super()
|
|
4
4
|
|
|
5
5
|
this.gsap = MarqueeContent.gsap || window.gsap
|
|
6
|
-
this.MM = this.gsap.matchMedia(
|
|
7
|
-
this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
: ''
|
|
6
|
+
this.MM = this.gsap.matchMedia()
|
|
7
|
+
this.breakpoint = this.dataset.mcMax
|
|
8
|
+
? `(max-width: ${this.dataset.mcMax - 0.02}px)`
|
|
9
|
+
: this.dataset.mcMin
|
|
10
|
+
? `(min-width: ${this.dataset.mcMin}px)`
|
|
11
|
+
: ''
|
|
12
|
+
|
|
13
|
+
this.onResize = this.onResize.bind(this)
|
|
14
|
+
this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))
|
|
15
|
+
this.resizeObserver.observe(this)
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
static registerGSAP(gsap) {
|
|
@@ -30,16 +29,20 @@ export default class MarqueeContent extends HTMLElement {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
templates() {
|
|
33
|
-
const
|
|
32
|
+
const wrapper = document.createElement('div')
|
|
33
|
+
wrapper.classList.add('marquee-wrapper')
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const inner = document.createElement('div')
|
|
36
|
+
inner.classList.add('marquee-inner')
|
|
37
|
+
inner.style.display = 'inline-block'
|
|
38
|
+
inner.style.whiteSpace = 'nowrap'
|
|
37
39
|
|
|
38
40
|
while (this.firstChild) {
|
|
39
|
-
|
|
41
|
+
inner.appendChild(this.firstChild)
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
wrapper.appendChild(inner)
|
|
45
|
+
this.appendChild(wrapper)
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
cloning() {
|
|
@@ -69,14 +72,14 @@ export default class MarqueeContent extends HTMLElement {
|
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
skewed() {
|
|
72
|
-
if (!this.
|
|
75
|
+
if (!this.dataset.mcSkew) return
|
|
73
76
|
|
|
74
|
-
const abs = Math.abs(parseInt(this.
|
|
77
|
+
const abs = Math.abs(parseInt(this.dataset.mcSkew))
|
|
75
78
|
const style = this.style
|
|
76
79
|
|
|
77
80
|
this.MM.add(this.breakpoint, () => {
|
|
78
81
|
style.transformOrigin = 'center center'
|
|
79
|
-
style.transform = `skew(0deg, ${this.
|
|
82
|
+
style.transform = `skew(0deg, ${this.dataset.mcSkew}deg)`
|
|
80
83
|
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
|
|
81
84
|
|
|
82
85
|
return () => {
|
|
@@ -97,7 +100,7 @@ export default class MarqueeContent extends HTMLElement {
|
|
|
97
100
|
this.gsap.set(this.children, { 'will-change': 'transform' })
|
|
98
101
|
|
|
99
102
|
const tween = this.gsap.to(this.children, {
|
|
100
|
-
duration: this.
|
|
103
|
+
duration: this.dataset.mcDuration || 20,
|
|
101
104
|
x: '-100%',
|
|
102
105
|
ease: 'none',
|
|
103
106
|
repeat: -1,
|
|
@@ -105,7 +108,7 @@ export default class MarqueeContent extends HTMLElement {
|
|
|
105
108
|
trigger: this,
|
|
106
109
|
start: '-=50% bottom',
|
|
107
110
|
end: 'bottom top',
|
|
108
|
-
toggleActions: 'resume pause resume pause'
|
|
111
|
+
toggleActions: 'resume pause resume pause'
|
|
109
112
|
},
|
|
110
113
|
}).totalProgress(0.5)
|
|
111
114
|
|
|
@@ -117,39 +120,32 @@ export default class MarqueeContent extends HTMLElement {
|
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
const autoDirection = () => {
|
|
120
|
-
let
|
|
123
|
+
let currentScroll = 0,
|
|
124
|
+
scrollDirection = 1
|
|
121
125
|
|
|
122
|
-
const
|
|
123
|
-
|
|
126
|
+
const handleScroll = () => {
|
|
127
|
+
let orientation = (window.pageYOffset > currentScroll) ? 1 : -1
|
|
124
128
|
|
|
125
|
-
|
|
129
|
+
if (orientation !== scrollDirection) {
|
|
130
|
+
this.gsap.to(tween, {
|
|
131
|
+
timeScale: orientation,
|
|
132
|
+
overwrite: true
|
|
133
|
+
})
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
direction = true
|
|
129
|
-
} else if (scrollPosition < previousScrollPosition) {
|
|
130
|
-
direction = false
|
|
135
|
+
scrollDirection = orientation
|
|
131
136
|
}
|
|
132
137
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return direction
|
|
138
|
+
currentScroll = window.pageYOffset
|
|
136
139
|
}
|
|
137
140
|
|
|
138
|
-
addEventListener('scroll',
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.gsap.to(tween, {
|
|
142
|
-
timeScale: scrollDirection ? 1 : -1,
|
|
143
|
-
overwrite: true,
|
|
144
|
-
})
|
|
145
|
-
}, 50), {
|
|
146
|
-
capture: true, passive: true
|
|
147
|
-
})
|
|
141
|
+
addEventListener('scroll', () => {
|
|
142
|
+
handleScroll()
|
|
143
|
+
}, { capture: true, passive: true })
|
|
148
144
|
}
|
|
149
145
|
|
|
150
|
-
if (this.
|
|
146
|
+
if (this.dataset.mcDirection === 'ltr') {
|
|
151
147
|
ltrDirection()
|
|
152
|
-
} else if (this.
|
|
148
|
+
} else if (this.dataset.mcDirection === 'auto') {
|
|
153
149
|
autoDirection()
|
|
154
150
|
}
|
|
155
151
|
|
|
@@ -162,30 +158,24 @@ export default class MarqueeContent extends HTMLElement {
|
|
|
162
158
|
onResize() {
|
|
163
159
|
cancelAnimationFrame(this.af)
|
|
164
160
|
|
|
165
|
-
this.
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
if (this.firstElementChild) {
|
|
162
|
+
this.af = requestAnimationFrame(() => {
|
|
163
|
+
this.cloning()
|
|
164
|
+
this.animation()
|
|
165
|
+
})
|
|
166
|
+
}
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
|
|
169
|
+
connectedCallback() {
|
|
172
170
|
this.templates()
|
|
173
171
|
this.cloning()
|
|
174
172
|
this.skewed()
|
|
175
173
|
this.animation()
|
|
176
|
-
|
|
177
|
-
this.onResize = this.onResize.bind(this)
|
|
178
|
-
this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))
|
|
179
|
-
this.resizeObserver.observe(this)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
connectedCallback() {
|
|
183
|
-
this.onUpdate()
|
|
184
174
|
}
|
|
185
175
|
|
|
186
176
|
disconnectedCallback() {
|
|
187
|
-
|
|
177
|
+
cancelAnimationFrame(this.af)
|
|
188
178
|
}
|
|
189
179
|
}
|
|
190
180
|
|
|
191
|
-
customElements.define('marquee-content', MarqueeContent)
|
|
181
|
+
customElements.get('marquee-content') || customElements.define('marquee-content', MarqueeContent)
|