marquee-content 1.9.4 → 1.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +68 -68
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +68 -68
- package/dist/index.module.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +75 -75
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
8
|
this.dataSkew = this.dataset.mcSkew;
|
|
@@ -32,30 +32,30 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
32
32
|
while(this.childElementCount > 1)this.removeChild(this.lastChild);
|
|
33
33
|
};
|
|
34
34
|
removingClones();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
36
|
+
let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
|
|
37
|
+
if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
|
|
38
|
+
let cloned = this.firstElementChild;
|
|
39
|
+
let clone = cloned.cloneNode(true);
|
|
40
|
+
cloned.parentNode.append(clone);
|
|
41
|
+
}
|
|
42
|
+
return ()=>{
|
|
43
|
+
removingClones();
|
|
44
|
+
};
|
|
45
|
+
// })
|
|
46
46
|
}
|
|
47
47
|
skewed() {
|
|
48
48
|
if (!this.dataSkew) return;
|
|
49
49
|
const abs = Math.abs(parseInt(this.dataSkew));
|
|
50
50
|
const style = this.style;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
52
|
+
style.transformOrigin = "center center";
|
|
53
|
+
style.transform = `skew(0deg, ${this.dataSkew}deg)`;
|
|
54
|
+
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
55
|
+
return ()=>{
|
|
56
|
+
style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
|
|
57
|
+
};
|
|
58
|
+
// })
|
|
59
59
|
}
|
|
60
60
|
animation() {
|
|
61
61
|
let timeLine = this.gsap.timeline();
|
|
@@ -64,57 +64,57 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
64
64
|
this.gsap.set(this.children, {
|
|
65
65
|
clearProps: true
|
|
66
66
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
68
|
+
this.gsap.set(this.children, {
|
|
69
|
+
"will-change": "transform"
|
|
70
|
+
});
|
|
71
|
+
const tween = this.gsap.to(this.children, {
|
|
72
|
+
duration: this.dataDuration,
|
|
73
|
+
x: "-100%",
|
|
74
|
+
ease: "none",
|
|
75
|
+
repeat: -1,
|
|
76
|
+
scrollTrigger: {
|
|
77
|
+
trigger: this,
|
|
78
|
+
start: "-=50% bottom",
|
|
79
|
+
end: "bottom top",
|
|
80
|
+
toggleActions: "resume pause resume pause"
|
|
81
|
+
}
|
|
82
|
+
}).totalProgress(0.5);
|
|
83
|
+
const ltrDirection = ()=>{
|
|
84
|
+
this.gsap.to(tween, {
|
|
85
|
+
timeScale: -1,
|
|
86
|
+
overwrite: true
|
|
70
87
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
};
|
|
89
|
+
const autoDirection = ()=>{
|
|
90
|
+
let previousScrollPosition = 0;
|
|
91
|
+
const isScrollingDown = ()=>{
|
|
92
|
+
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
93
|
+
let direction = false;
|
|
94
|
+
if (scrollPosition > previousScrollPosition) direction = true;
|
|
95
|
+
else if (scrollPosition < previousScrollPosition) direction = false;
|
|
96
|
+
previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
|
|
97
|
+
return direction;
|
|
98
|
+
};
|
|
99
|
+
addEventListener("scroll", this.debounce(()=>{
|
|
100
|
+
const scrollDirection = isScrollingDown();
|
|
84
101
|
this.gsap.to(tween, {
|
|
85
|
-
timeScale: -1,
|
|
102
|
+
timeScale: scrollDirection ? 1 : -1,
|
|
86
103
|
overwrite: true
|
|
87
104
|
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.gsap.to(tween, {
|
|
102
|
-
timeScale: scrollDirection ? 1 : -1,
|
|
103
|
-
overwrite: true
|
|
104
|
-
});
|
|
105
|
-
}, 50), {
|
|
106
|
-
capture: true,
|
|
107
|
-
passive: true
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
if (this.dataDirection === "ltr") ltrDirection();
|
|
111
|
-
else if (this.dataDirection === "auto") autoDirection();
|
|
112
|
-
return ()=>{
|
|
113
|
-
this.gsap.set(this.children, {
|
|
114
|
-
clearProps: true
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
});
|
|
105
|
+
}, 50), {
|
|
106
|
+
capture: true,
|
|
107
|
+
passive: true
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
if (this.dataDirection === "ltr") ltrDirection();
|
|
111
|
+
else if (this.dataDirection === "auto") autoDirection();
|
|
112
|
+
return ()=>{
|
|
113
|
+
this.gsap.set(this.children, {
|
|
114
|
+
clearProps: true
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
// })
|
|
118
118
|
}
|
|
119
119
|
onResize() {
|
|
120
120
|
cancelAnimationFrame(this.af);
|
|
@@ -136,7 +136,7 @@ class $4fa36e821943b400$var$MarqueeContent extends HTMLElement {
|
|
|
136
136
|
this.onUpdate();
|
|
137
137
|
}
|
|
138
138
|
disconnectedCallback() {
|
|
139
|
-
|
|
139
|
+
// gsap.matchMedia().remove()
|
|
140
140
|
document.fonts.removeEventListener("loadingdone", this.onUpdate);
|
|
141
141
|
}
|
|
142
142
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,
|
|
1
|
+
{"mappings":"AAAA,MAAM,6CAAuB;IACzB,OAAO,aAAa,IAAI,EAAE;QACtB,qCAAe,IAAI,GAAG;IAC1B;IAEA,YAAY,KAAK,CAAE;QACf,KAAK;QAEL,IAAI,CAAC,IAAI,GAAG,qCAAe,IAAI,IAAI,OAAO,IAAI;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK;QACtC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,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\n MarqueeContent.gsap = gsap\n }\n\n constructor(query) {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.dataSkew = this.dataset.mcSkew\n this.dataDuration = this.dataset.mcDuration || 20\n this.dataDirection = this.dataset.mcDirection\n this.dataMaxWidth = this.dataset.mcMax\n this.dataMinWidth = this.dataset.mcMin\n this.breakpoint = this.dataMaxWidth\n ? `(max-width: ${this.dataMaxWidth - 0.02}px)`\n : this.dataMinWidth\n ? `(min-width: ${this.dataMinWidth}px)`\n : ''\n this.debounce()\n }\n\n debounce(fn, delay) {\n let timer\n\n return (...args) => {\n if (timer) clearTimeout(timer)\n timer = setTimeout(() => fn(...args), delay)\n }\n }\n\n templates() {\n const div = document.createElement('div')\n\n div.style.display = 'inline-block'\n div.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n div.appendChild(this.firstChild)\n }\n\n this.appendChild(div)\n }\n\n cloning() {\n const removingClones = () => {\n while (this.childElementCount > 1) {\n this.removeChild(this.lastChild)\n }\n }\n\n removingClones()\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)\n\n if (this.childElementCount < requiredQuantity) {\n for (let i = 1; i < requiredQuantity; i++) {\n let cloned = this.firstElementChild\n let clone = cloned.cloneNode(true)\n cloned.parentNode.append(clone)\n }\n }\n\n return () => {\n removingClones()\n }\n // })\n }\n\n skewed() {\n if (!this.dataSkew) return\n\n const abs = Math.abs(parseInt(this.dataSkew))\n const style = this.style\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n style.transformOrigin = 'center center'\n style.transform = `skew(0deg, ${this.dataSkew}deg)`\n style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`\n\n return () => {\n style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'\n }\n // })\n }\n\n animation() {\n let timeLine = this.gsap.timeline()\n\n timeLine.kill()\n timeLine = null\n\n this.gsap.set(this.children, { clearProps: true })\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n this.gsap.set(this.children, { 'will-change': 'transform' })\n\n const tween = this.gsap.to(this.children, {\n duration: this.dataDuration,\n x: '-100%',\n ease: 'none',\n repeat: -1,\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause',\n },\n }).totalProgress(0.5)\n\n const ltrDirection = () => {\n this.gsap.to(tween, {\n timeScale: -1,\n overwrite: true\n })\n }\n\n const autoDirection = () => {\n let previousScrollPosition = 0\n\n const isScrollingDown = () => {\n const scrollPosition = window.pageYOffset || document.documentElement.scrollTop\n\n let direction = false\n\n if (scrollPosition > previousScrollPosition) {\n direction = true\n } else if (scrollPosition < previousScrollPosition) {\n direction = false\n }\n\n previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition\n\n return direction\n }\n\n addEventListener('scroll', this.debounce(() => {\n const scrollDirection = isScrollingDown()\n\n this.gsap.to(tween, {\n timeScale: scrollDirection ? 1 : -1,\n overwrite: true,\n })\n }, 50), {\n capture: true, passive: true\n })\n }\n\n if (this.dataDirection === 'ltr') {\n ltrDirection()\n } else if (this.dataDirection === 'auto') {\n autoDirection()\n }\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n // })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n\n onUpdate() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n\n this.onResize = this.onResize.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n connectedCallback() {\n this.onUpdate()\n }\n\n disconnectedCallback() {\n // gsap.matchMedia().remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.js.map"}
|
package/dist/index.module.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
9
|
this.dataSkew = this.dataset.mcSkew;
|
|
@@ -33,30 +33,30 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
33
33
|
while(this.childElementCount > 1)this.removeChild(this.lastChild);
|
|
34
34
|
};
|
|
35
35
|
removingClones();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
37
|
+
let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2);
|
|
38
|
+
if (this.childElementCount < requiredQuantity) for(let i = 1; i < requiredQuantity; i++){
|
|
39
|
+
let cloned = this.firstElementChild;
|
|
40
|
+
let clone = cloned.cloneNode(true);
|
|
41
|
+
cloned.parentNode.append(clone);
|
|
42
|
+
}
|
|
43
|
+
return ()=>{
|
|
44
|
+
removingClones();
|
|
45
|
+
};
|
|
46
|
+
// })
|
|
47
47
|
}
|
|
48
48
|
skewed() {
|
|
49
49
|
if (!this.dataSkew) return;
|
|
50
50
|
const abs = Math.abs(parseInt(this.dataSkew));
|
|
51
51
|
const style = this.style;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
53
|
+
style.transformOrigin = "center center";
|
|
54
|
+
style.transform = `skew(0deg, ${this.dataSkew}deg)`;
|
|
55
|
+
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`;
|
|
56
|
+
return ()=>{
|
|
57
|
+
style.cssText = "transform-origin: unset; transform: unset; min-height: unset;";
|
|
58
|
+
};
|
|
59
|
+
// })
|
|
60
60
|
}
|
|
61
61
|
animation() {
|
|
62
62
|
let timeLine = this.gsap.timeline();
|
|
@@ -65,57 +65,57 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
65
65
|
this.gsap.set(this.children, {
|
|
66
66
|
clearProps: true
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
69
|
+
this.gsap.set(this.children, {
|
|
70
|
+
"will-change": "transform"
|
|
71
|
+
});
|
|
72
|
+
const tween = this.gsap.to(this.children, {
|
|
73
|
+
duration: this.dataDuration,
|
|
74
|
+
x: "-100%",
|
|
75
|
+
ease: "none",
|
|
76
|
+
repeat: -1,
|
|
77
|
+
scrollTrigger: {
|
|
78
|
+
trigger: this,
|
|
79
|
+
start: "-=50% bottom",
|
|
80
|
+
end: "bottom top",
|
|
81
|
+
toggleActions: "resume pause resume pause"
|
|
82
|
+
}
|
|
83
|
+
}).totalProgress(0.5);
|
|
84
|
+
const ltrDirection = ()=>{
|
|
85
|
+
this.gsap.to(tween, {
|
|
86
|
+
timeScale: -1,
|
|
87
|
+
overwrite: true
|
|
71
88
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
};
|
|
90
|
+
const autoDirection = ()=>{
|
|
91
|
+
let previousScrollPosition = 0;
|
|
92
|
+
const isScrollingDown = ()=>{
|
|
93
|
+
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
94
|
+
let direction = false;
|
|
95
|
+
if (scrollPosition > previousScrollPosition) direction = true;
|
|
96
|
+
else if (scrollPosition < previousScrollPosition) direction = false;
|
|
97
|
+
previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition;
|
|
98
|
+
return direction;
|
|
99
|
+
};
|
|
100
|
+
addEventListener("scroll", this.debounce(()=>{
|
|
101
|
+
const scrollDirection = isScrollingDown();
|
|
85
102
|
this.gsap.to(tween, {
|
|
86
|
-
timeScale: -1,
|
|
103
|
+
timeScale: scrollDirection ? 1 : -1,
|
|
87
104
|
overwrite: true
|
|
88
105
|
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.gsap.to(tween, {
|
|
103
|
-
timeScale: scrollDirection ? 1 : -1,
|
|
104
|
-
overwrite: true
|
|
105
|
-
});
|
|
106
|
-
}, 50), {
|
|
107
|
-
capture: true,
|
|
108
|
-
passive: true
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
if (this.dataDirection === "ltr") ltrDirection();
|
|
112
|
-
else if (this.dataDirection === "auto") autoDirection();
|
|
113
|
-
return ()=>{
|
|
114
|
-
this.gsap.set(this.children, {
|
|
115
|
-
clearProps: true
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
});
|
|
106
|
+
}, 50), {
|
|
107
|
+
capture: true,
|
|
108
|
+
passive: true
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
if (this.dataDirection === "ltr") ltrDirection();
|
|
112
|
+
else if (this.dataDirection === "auto") autoDirection();
|
|
113
|
+
return ()=>{
|
|
114
|
+
this.gsap.set(this.children, {
|
|
115
|
+
clearProps: true
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
// })
|
|
119
119
|
}
|
|
120
120
|
onResize() {
|
|
121
121
|
cancelAnimationFrame(this.af);
|
|
@@ -137,7 +137,7 @@ class $cf838c15c8b009ba$var$MarqueeContent extends HTMLElement {
|
|
|
137
137
|
this.onUpdate();
|
|
138
138
|
}
|
|
139
139
|
disconnectedCallback() {
|
|
140
|
-
|
|
140
|
+
// gsap.matchMedia().remove()
|
|
141
141
|
document.fonts.removeEventListener("loadingdone", this.onUpdate);
|
|
142
142
|
}
|
|
143
143
|
}
|
package/dist/index.module.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,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,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,IAAI;YAChC;QACJ;QAEA,IAAI,IAAI,CAAC,aAAa,KAAK,OACvB;aACG,IAAI,IAAI,CAAC,aAAa,KAAK,QAC9B;QAGJ,OAAO,IAAM;YACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAAE,YAAY,IAAI;YAAC;QACpD;IACA,KAAK;IACT;IAEA,WAAW;QACP,qBAAqB,IAAI,CAAC,EAAE;QAE5B,IAAI,CAAC,EAAE,GAAG,sBAAsB,IAAM;YAClC,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,SAAS;QAClB;IACJ;IAEA,WAAW;QACP,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,SAAS;QAEd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI;QACvC,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG;QACjF,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI;IACpC;IAEA,oBAAoB;QAChB,IAAI,CAAC,QAAQ;IACjB;IAEA,uBAAuB;QACnB,6BAA6B;QAE7B,SAAS,KAAK,CAAC,mBAAmB,CAAC,eAAe,IAAI,CAAC,QAAQ;IACnE;AACJ;AAEA,eAAe,MAAM,CAAC,mBAAmB","sources":["src/index.js"],"sourcesContent":["class MarqueeContent extends HTMLElement {\n static registerGSAP(gsap) {\n MarqueeContent.gsap = gsap\n }\n\n constructor(query) {\n super()\n\n this.gsap = MarqueeContent.gsap || window.gsap\n this.dataSkew = this.dataset.mcSkew\n this.dataDuration = this.dataset.mcDuration || 20\n this.dataDirection = this.dataset.mcDirection\n this.dataMaxWidth = this.dataset.mcMax\n this.dataMinWidth = this.dataset.mcMin\n this.breakpoint = this.dataMaxWidth\n ? `(max-width: ${this.dataMaxWidth - 0.02}px)`\n : this.dataMinWidth\n ? `(min-width: ${this.dataMinWidth}px)`\n : ''\n this.debounce()\n }\n\n debounce(fn, delay) {\n let timer\n\n return (...args) => {\n if (timer) clearTimeout(timer)\n timer = setTimeout(() => fn(...args), delay)\n }\n }\n\n templates() {\n const div = document.createElement('div')\n\n div.style.display = 'inline-block'\n div.style.whiteSpace = 'nowrap'\n\n while (this.firstChild) {\n div.appendChild(this.firstChild)\n }\n\n this.appendChild(div)\n }\n\n cloning() {\n const removingClones = () => {\n while (this.childElementCount > 1) {\n this.removeChild(this.lastChild)\n }\n }\n\n removingClones()\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)\n\n if (this.childElementCount < requiredQuantity) {\n for (let i = 1; i < requiredQuantity; i++) {\n let cloned = this.firstElementChild\n let clone = cloned.cloneNode(true)\n cloned.parentNode.append(clone)\n }\n }\n\n return () => {\n removingClones()\n }\n // })\n }\n\n skewed() {\n if (!this.dataSkew) return\n\n const abs = Math.abs(parseInt(this.dataSkew))\n const style = this.style\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n style.transformOrigin = 'center center'\n style.transform = `skew(0deg, ${this.dataSkew}deg)`\n style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`\n\n return () => {\n style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'\n }\n // })\n }\n\n animation() {\n let timeLine = this.gsap.timeline()\n\n timeLine.kill()\n timeLine = null\n\n this.gsap.set(this.children, { clearProps: true })\n\n // gsap.matchMedia().add(this.breakpoint, () => {\n this.gsap.set(this.children, { 'will-change': 'transform' })\n\n const tween = this.gsap.to(this.children, {\n duration: this.dataDuration,\n x: '-100%',\n ease: 'none',\n repeat: -1,\n scrollTrigger: {\n trigger: this,\n start: '-=50% bottom',\n end: 'bottom top',\n toggleActions: 'resume pause resume pause',\n },\n }).totalProgress(0.5)\n\n const ltrDirection = () => {\n this.gsap.to(tween, {\n timeScale: -1,\n overwrite: true\n })\n }\n\n const autoDirection = () => {\n let previousScrollPosition = 0\n\n const isScrollingDown = () => {\n const scrollPosition = window.pageYOffset || document.documentElement.scrollTop\n\n let direction = false\n\n if (scrollPosition > previousScrollPosition) {\n direction = true\n } else if (scrollPosition < previousScrollPosition) {\n direction = false\n }\n\n previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition\n\n return direction\n }\n\n addEventListener('scroll', this.debounce(() => {\n const scrollDirection = isScrollingDown()\n\n this.gsap.to(tween, {\n timeScale: scrollDirection ? 1 : -1,\n overwrite: true,\n })\n }, 50), {\n capture: true, passive: true\n })\n }\n\n if (this.dataDirection === 'ltr') {\n ltrDirection()\n } else if (this.dataDirection === 'auto') {\n autoDirection()\n }\n\n return () => {\n this.gsap.set(this.children, { clearProps: true })\n }\n // })\n }\n\n onResize() {\n cancelAnimationFrame(this.af)\n\n this.af = requestAnimationFrame(() => {\n this.cloning()\n this.animation()\n })\n }\n\n onUpdate() {\n this.templates()\n this.cloning()\n this.skewed()\n this.animation()\n\n this.onResize = this.onResize.bind(this)\n this.resizeObserver = new ResizeObserver(this.debounce(this.onResize.bind(this), 150))\n this.resizeObserver.observe(this)\n }\n\n connectedCallback() {\n this.onUpdate()\n }\n\n disconnectedCallback() {\n // gsap.matchMedia().remove()\n\n document.fonts.removeEventListener('loadingdone', this.onUpdate)\n }\n}\n\ncustomElements.define('marquee-content', MarqueeContent)"],"names":[],"version":3,"file":"index.module.js.map"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
|
@@ -51,21 +51,21 @@ class MarqueeContent extends HTMLElement {
|
|
|
51
51
|
|
|
52
52
|
removingClones()
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
55
|
+
let requiredQuantity = Math.ceil(this.scrollWidth / this.firstElementChild.clientWidth + 2)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
57
|
+
if (this.childElementCount < requiredQuantity) {
|
|
58
|
+
for (let i = 1; i < requiredQuantity; i++) {
|
|
59
|
+
let cloned = this.firstElementChild
|
|
60
|
+
let clone = cloned.cloneNode(true)
|
|
61
|
+
cloned.parentNode.append(clone)
|
|
63
62
|
}
|
|
63
|
+
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
65
|
+
return () => {
|
|
66
|
+
removingClones()
|
|
67
|
+
}
|
|
68
|
+
// })
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
skewed() {
|
|
@@ -74,15 +74,15 @@ class MarqueeContent extends HTMLElement {
|
|
|
74
74
|
const abs = Math.abs(parseInt(this.dataSkew))
|
|
75
75
|
const style = this.style
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
78
|
+
style.transformOrigin = 'center center'
|
|
79
|
+
style.transform = `skew(0deg, ${this.dataSkew}deg)`
|
|
80
|
+
style.minHeight = `calc(${abs * 1.25}vh + ${abs * 1.25}vw)`
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
82
|
+
return () => {
|
|
83
|
+
style.cssText = 'transform-origin: unset; transform: unset; min-height: unset;'
|
|
84
|
+
}
|
|
85
|
+
// })
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
animation() {
|
|
@@ -93,70 +93,70 @@ class MarqueeContent extends HTMLElement {
|
|
|
93
93
|
|
|
94
94
|
this.gsap.set(this.children, { clearProps: true })
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
96
|
+
// gsap.matchMedia().add(this.breakpoint, () => {
|
|
97
|
+
this.gsap.set(this.children, { 'will-change': 'transform' })
|
|
98
|
+
|
|
99
|
+
const tween = this.gsap.to(this.children, {
|
|
100
|
+
duration: this.dataDuration,
|
|
101
|
+
x: '-100%',
|
|
102
|
+
ease: 'none',
|
|
103
|
+
repeat: -1,
|
|
104
|
+
scrollTrigger: {
|
|
105
|
+
trigger: this,
|
|
106
|
+
start: '-=50% bottom',
|
|
107
|
+
end: 'bottom top',
|
|
108
|
+
toggleActions: 'resume pause resume pause',
|
|
109
|
+
},
|
|
110
|
+
}).totalProgress(0.5)
|
|
111
|
+
|
|
112
|
+
const ltrDirection = () => {
|
|
113
|
+
this.gsap.to(tween, {
|
|
114
|
+
timeScale: -1,
|
|
115
|
+
overwrite: true
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
const autoDirection = () => {
|
|
120
|
+
let previousScrollPosition = 0
|
|
121
121
|
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
const isScrollingDown = () => {
|
|
123
|
+
const scrollPosition = window.pageYOffset || document.documentElement.scrollTop
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
let direction = false
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
if (scrollPosition > previousScrollPosition) {
|
|
128
|
+
direction = true
|
|
129
|
+
} else if (scrollPosition < previousScrollPosition) {
|
|
130
|
+
direction = false
|
|
131
|
+
}
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
previousScrollPosition = scrollPosition <= 0 ? 0 : scrollPosition
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
return direction
|
|
136
|
+
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
addEventListener('scroll', this.debounce(() => {
|
|
139
|
+
const scrollDirection = isScrollingDown()
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
})
|
|
145
|
-
}, 50), {
|
|
146
|
-
capture: true, passive: true
|
|
141
|
+
this.gsap.to(tween, {
|
|
142
|
+
timeScale: scrollDirection ? 1 : -1,
|
|
143
|
+
overwrite: true,
|
|
147
144
|
})
|
|
148
|
-
}
|
|
145
|
+
}, 50), {
|
|
146
|
+
capture: true, passive: true
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
if (this.dataDirection === 'ltr') {
|
|
151
|
+
ltrDirection()
|
|
152
|
+
} else if (this.dataDirection === 'auto') {
|
|
153
|
+
autoDirection()
|
|
154
|
+
}
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
})
|
|
156
|
+
return () => {
|
|
157
|
+
this.gsap.set(this.children, { clearProps: true })
|
|
158
|
+
}
|
|
159
|
+
// })
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
onResize() {
|
|
@@ -184,7 +184,7 @@ class MarqueeContent extends HTMLElement {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
disconnectedCallback() {
|
|
187
|
-
|
|
187
|
+
// gsap.matchMedia().remove()
|
|
188
188
|
|
|
189
189
|
document.fonts.removeEventListener('loadingdone', this.onUpdate)
|
|
190
190
|
}
|