marquee-content 4.5.1-dev.1 → 4.5.1-dev.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 +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +20 -18
- package/dist/index.es.js +49 -45
- package/dist/index.umd.js +1 -1
- package/package.json +4 -2
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
|
-
<sup>
|
|
12
|
+
<sup>1.5kB gzipped</sup>
|
|
13
13
|
|
|
14
14
|
<a href="https://codepen.io/ux-ui/full/dygzqYm">Demo</a>
|
|
15
15
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var d=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>d(r,typeof e!="symbol"?e+"":e,t);const p=require("gsap"),u=require("gsap/ScrollTrigger"),i=class i{constructor({element:e=".marquee"}={}){n(this,"gsapInstance",i._gsap);n(this,"timeline");n(this,"matchMedia");n(this,"element");n(this,"resizeObserver");n(this,"animationFrame");const t=e instanceof HTMLElement?e:document.querySelector(e);if(!t)throw new Error("Target element not found");this.element=t,this.gsapInstance=i._gsap,this.matchMedia=this.gsapInstance.matchMedia(),this.resizeObserver=new ResizeObserver(i.debounce(()=>{this.update()})),this.resizeObserver.observe(this.element)}static registerGSAP(e,t){i._gsap=e,i._ScrollTrigger=t}static debounce(e){let t=null;return(...s)=>{t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>e(...s))}}init(){this.setup()}destroy(){this.animationFrame!==void 0&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=void 0),this.resizeObserver.disconnect(),this.clearTimeline()}setup(){this.clearTimeline(),this.cloneElements(),this.setBreakpoints(),this.applySkew(),this.timeline=this.createAnimation()}update(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),this.animationFrame=requestAnimationFrame(()=>{var e,t;this.setup(),(t=(e=i._ScrollTrigger).refresh)==null||t.call(e)})}createAnimation(){var s;(s=this.timeline)==null||s.kill();const e=this.gsapInstance.timeline({scrollTrigger:{trigger:this.element,start:"top bottom",end:"bottom top",toggleActions:"resume pause resume pause",onUpdate:a=>{const{mcDirection:l}=this.element.dataset;l==="ltr"?e.timeScale(-1):l==="auto"&&e.timeScale(a.direction)}}}),t=this.element.dataset.mcBreakpoint||"";return this.matchMedia.add(t,()=>{const a=parseFloat(this.element.dataset.mcSpeed??"20");return e.to(this.element.children,{duration:a,x:"-100%",repeat:-1,ease:"none"}),e.totalProgress(.5),()=>{e.kill()}}),e}clearTimeline(){var e;(e=this.timeline)==null||e.kill(),this.timeline=void 0,this.gsapInstance.set(this.element.children,{clearProps:"all"})}setBreakpoints(){const{mcMax:e,mcMin:t}=this.element.dataset;this.element.dataset.mcBreakpoint=e?`(max-width: ${parseFloat(e)-.02}px)`:t?`(min-width: ${t}px)`:""}cloneElements(){const e=()=>{for(;this.element.childElementCount>1;)this.element.removeChild(this.element.lastChild)};e();const t=this.element.dataset.mcBreakpoint||"";this.matchMedia.add(t,()=>{const s=this.element.firstElementChild;if(!s)return()=>{};const a=Math.ceil(this.element.scrollWidth/s.clientWidth+2);if(this.element.childElementCount<a){const l=document.createDocumentFragment();for(let o=0;o<a-1;o++){const c=s.cloneNode(!0);l.appendChild(c)}this.element.appendChild(l)}return()=>{e()}})}applySkew(){const{mcSkew:e}=this.element.dataset;e&&(this.element.style.transformOrigin="center center",this.element.style.transform=`skew(0deg, ${e}deg)`)}};n(i,"_gsap",p.gsap),n(i,"_ScrollTrigger",u.ScrollTrigger);let m=i;module.exports=m;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
+
import { gsap } from 'gsap';
|
|
2
|
+
import { ScrollTrigger } from 'gsap/ScrollTrigger';
|
|
1
3
|
interface MarqueeOptions {
|
|
2
4
|
element?: string | HTMLElement;
|
|
3
5
|
}
|
|
4
|
-
|
|
5
|
-
private static
|
|
6
|
-
private static
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
6
|
+
export default class MarqueeContent {
|
|
7
|
+
private static _gsap;
|
|
8
|
+
private static _ScrollTrigger;
|
|
9
|
+
private gsapInstance;
|
|
10
|
+
private timeline?;
|
|
11
|
+
private matchMedia;
|
|
12
|
+
private element;
|
|
13
|
+
private resizeObserver;
|
|
14
|
+
private animationFrame?;
|
|
13
15
|
constructor({ element }?: MarqueeOptions);
|
|
14
16
|
static registerGSAP(gsapInstance: typeof gsap, scrollTriggerInstance: typeof ScrollTrigger): void;
|
|
15
|
-
private static
|
|
17
|
+
private static debounce;
|
|
16
18
|
init(): void;
|
|
17
19
|
destroy(): void;
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
private
|
|
20
|
+
private setup;
|
|
21
|
+
private update;
|
|
22
|
+
private createAnimation;
|
|
23
|
+
private clearTimeline;
|
|
24
|
+
private setBreakpoints;
|
|
25
|
+
private cloneElements;
|
|
26
|
+
private applySkew;
|
|
25
27
|
}
|
|
26
|
-
export
|
|
28
|
+
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -1,94 +1,98 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var n = (r, e, t) =>
|
|
2
|
+
var d = (r, e, t) => e in r ? h(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var n = (r, e, t) => d(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { gsap as p } from "gsap";
|
|
5
|
+
import { ScrollTrigger as u } from "gsap/ScrollTrigger";
|
|
4
6
|
const i = class i {
|
|
5
7
|
constructor({ element: e = ".marquee" } = {}) {
|
|
6
|
-
n(this, "
|
|
7
|
-
n(this, "
|
|
8
|
-
n(this, "
|
|
9
|
-
n(this, "
|
|
10
|
-
n(this, "
|
|
11
|
-
n(this, "
|
|
8
|
+
n(this, "gsapInstance", i._gsap);
|
|
9
|
+
n(this, "timeline");
|
|
10
|
+
n(this, "matchMedia");
|
|
11
|
+
n(this, "element");
|
|
12
|
+
n(this, "resizeObserver");
|
|
13
|
+
n(this, "animationFrame");
|
|
12
14
|
const t = e instanceof HTMLElement ? e : document.querySelector(e);
|
|
13
15
|
if (!t) throw new Error("Target element not found");
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
})), this.
|
|
16
|
+
this.element = t, this.gsapInstance = i._gsap, this.matchMedia = this.gsapInstance.matchMedia(), this.resizeObserver = new ResizeObserver(i.debounce(() => {
|
|
17
|
+
this.update();
|
|
18
|
+
})), this.resizeObserver.observe(this.element);
|
|
17
19
|
}
|
|
18
20
|
static registerGSAP(e, t) {
|
|
19
|
-
i.
|
|
21
|
+
i._gsap = e, i._ScrollTrigger = t;
|
|
20
22
|
}
|
|
21
|
-
static
|
|
23
|
+
static debounce(e) {
|
|
22
24
|
let t = null;
|
|
23
25
|
return (...s) => {
|
|
24
26
|
t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => e(...s));
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
init() {
|
|
28
|
-
this.
|
|
30
|
+
this.setup();
|
|
29
31
|
}
|
|
30
32
|
destroy() {
|
|
31
|
-
this.
|
|
33
|
+
this.animationFrame !== void 0 && (cancelAnimationFrame(this.animationFrame), this.animationFrame = void 0), this.resizeObserver.disconnect(), this.clearTimeline();
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
+
setup() {
|
|
36
|
+
this.clearTimeline(), this.cloneElements(), this.setBreakpoints(), this.applySkew(), this.timeline = this.createAnimation();
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
38
|
+
update() {
|
|
39
|
+
this.animationFrame !== void 0 && cancelAnimationFrame(this.animationFrame), this.animationFrame = requestAnimationFrame(() => {
|
|
40
|
+
var e, t;
|
|
41
|
+
this.setup(), (t = (e = i._ScrollTrigger).refresh) == null || t.call(e);
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
createAnimation() {
|
|
42
45
|
var s;
|
|
43
|
-
(s = this.
|
|
44
|
-
const e = this.
|
|
45
|
-
const l = this.
|
|
46
|
+
(s = this.timeline) == null || s.kill();
|
|
47
|
+
const e = this.gsapInstance.timeline({ scrollTrigger: { trigger: this.element, start: "top bottom", end: "bottom top", toggleActions: "resume pause resume pause", onUpdate: (a) => {
|
|
48
|
+
const { mcDirection: l } = this.element.dataset;
|
|
46
49
|
l === "ltr" ? e.timeScale(-1) : l === "auto" && e.timeScale(a.direction);
|
|
47
|
-
} } }), t = this.
|
|
48
|
-
return this.
|
|
49
|
-
const a = parseFloat(this.
|
|
50
|
-
return e.to(this.
|
|
50
|
+
} } }), t = this.element.dataset.mcBreakpoint || "";
|
|
51
|
+
return this.matchMedia.add(t, () => {
|
|
52
|
+
const a = parseFloat(this.element.dataset.mcSpeed ?? "20");
|
|
53
|
+
return e.to(this.element.children, { duration: a, x: "-100%", repeat: -1, ease: "none" }), e.totalProgress(0.5), () => {
|
|
51
54
|
e.kill();
|
|
52
55
|
};
|
|
53
56
|
}), e;
|
|
54
57
|
}
|
|
55
|
-
|
|
58
|
+
clearTimeline() {
|
|
56
59
|
var e;
|
|
57
|
-
(e = this.
|
|
60
|
+
(e = this.timeline) == null || e.kill(), this.timeline = void 0, this.gsapInstance.set(this.element.children, { clearProps: "all" });
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
const { mcMax: e, mcMin: t } = this.
|
|
61
|
-
this.
|
|
62
|
+
setBreakpoints() {
|
|
63
|
+
const { mcMax: e, mcMin: t } = this.element.dataset;
|
|
64
|
+
this.element.dataset.mcBreakpoint = e ? `(max-width: ${parseFloat(e) - 0.02}px)` : t ? `(min-width: ${t}px)` : "";
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
cloneElements() {
|
|
64
67
|
const e = () => {
|
|
65
|
-
for (; this.
|
|
68
|
+
for (; this.element.childElementCount > 1; ) this.element.removeChild(this.element.lastChild);
|
|
66
69
|
};
|
|
67
70
|
e();
|
|
68
|
-
const t = this.
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
+
const t = this.element.dataset.mcBreakpoint || "";
|
|
72
|
+
this.matchMedia.add(t, () => {
|
|
73
|
+
const s = this.element.firstElementChild;
|
|
74
|
+
if (!s) return () => {
|
|
71
75
|
};
|
|
72
|
-
const
|
|
73
|
-
if (this.
|
|
76
|
+
const a = Math.ceil(this.element.scrollWidth / s.clientWidth + 2);
|
|
77
|
+
if (this.element.childElementCount < a) {
|
|
74
78
|
const l = document.createDocumentFragment();
|
|
75
79
|
for (let m = 0; m < a - 1; m++) {
|
|
76
80
|
const c = s.cloneNode(!0);
|
|
77
81
|
l.appendChild(c);
|
|
78
82
|
}
|
|
79
|
-
this.
|
|
83
|
+
this.element.appendChild(l);
|
|
80
84
|
}
|
|
81
85
|
return () => {
|
|
82
86
|
e();
|
|
83
87
|
};
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
|
-
|
|
87
|
-
const { mcSkew: e } = this.
|
|
88
|
-
e && (this.
|
|
90
|
+
applySkew() {
|
|
91
|
+
const { mcSkew: e } = this.element.dataset;
|
|
92
|
+
e && (this.element.style.transformOrigin = "center center", this.element.style.transform = `skew(0deg, ${e}deg)`);
|
|
89
93
|
}
|
|
90
94
|
};
|
|
91
|
-
n(i, "
|
|
95
|
+
n(i, "_gsap", p), n(i, "_ScrollTrigger", u);
|
|
92
96
|
let o = i;
|
|
93
97
|
export {
|
|
94
98
|
o as default
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("gsap"),require("gsap/ScrollTrigger")):typeof define=="function"&&define.amd?define(["gsap","gsap/ScrollTrigger"],i):(n=typeof globalThis<"u"?globalThis:n||self).MarqueeContent=i(n.gsap,n.ScrollTrigger)})(this,function(n,i){"use strict";var d=Object.defineProperty;var p=(n,i,r)=>i in n?d(n,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[i]=r;var a=(n,i,r)=>p(n,typeof i!="symbol"?i+"":i,r);const s=class s{constructor({element:e=".marquee"}={}){a(this,"gsapInstance",s._gsap);a(this,"timeline");a(this,"matchMedia");a(this,"element");a(this,"resizeObserver");a(this,"animationFrame");const t=e instanceof HTMLElement?e:document.querySelector(e);if(!t)throw new Error("Target element not found");this.element=t,this.gsapInstance=s._gsap,this.matchMedia=this.gsapInstance.matchMedia(),this.resizeObserver=new ResizeObserver(s.debounce(()=>{this.update()})),this.resizeObserver.observe(this.element)}static registerGSAP(e,t){s._gsap=e,s._ScrollTrigger=t}static debounce(e){let t=null;return(...l)=>{t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>e(...l))}}init(){this.setup()}destroy(){this.animationFrame!==void 0&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=void 0),this.resizeObserver.disconnect(),this.clearTimeline()}setup(){this.clearTimeline(),this.cloneElements(),this.setBreakpoints(),this.applySkew(),this.timeline=this.createAnimation()}update(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),this.animationFrame=requestAnimationFrame(()=>{var e,t;this.setup(),(t=(e=s._ScrollTrigger).refresh)==null||t.call(e)})}createAnimation(){var l;(l=this.timeline)==null||l.kill();const e=this.gsapInstance.timeline({scrollTrigger:{trigger:this.element,start:"top bottom",end:"bottom top",toggleActions:"resume pause resume pause",onUpdate:o=>{const{mcDirection:m}=this.element.dataset;m==="ltr"?e.timeScale(-1):m==="auto"&&e.timeScale(o.direction)}}}),t=this.element.dataset.mcBreakpoint||"";return this.matchMedia.add(t,()=>{const o=parseFloat(this.element.dataset.mcSpeed??"20");return e.to(this.element.children,{duration:o,x:"-100%",repeat:-1,ease:"none"}),e.totalProgress(.5),()=>{e.kill()}}),e}clearTimeline(){var e;(e=this.timeline)==null||e.kill(),this.timeline=void 0,this.gsapInstance.set(this.element.children,{clearProps:"all"})}setBreakpoints(){const{mcMax:e,mcMin:t}=this.element.dataset;this.element.dataset.mcBreakpoint=e?`(max-width: ${parseFloat(e)-.02}px)`:t?`(min-width: ${t}px)`:""}cloneElements(){const e=()=>{for(;this.element.childElementCount>1;)this.element.removeChild(this.element.lastChild)};e();const t=this.element.dataset.mcBreakpoint||"";this.matchMedia.add(t,()=>{const l=this.element.firstElementChild;if(!l)return()=>{};const o=Math.ceil(this.element.scrollWidth/l.clientWidth+2);if(this.element.childElementCount<o){const m=document.createDocumentFragment();for(let c=0;c<o-1;c++){const h=l.cloneNode(!0);m.appendChild(h)}this.element.appendChild(m)}return()=>{e()}})}applySkew(){const{mcSkew:e}=this.element.dataset;e&&(this.element.style.transformOrigin="center center",this.element.style.transform=`skew(0deg, ${e}deg)`)}};a(s,"_gsap",n.gsap),a(s,"_ScrollTrigger",i.ScrollTrigger);let r=s;return r});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marquee-content",
|
|
3
|
-
"version": "4.5.1-dev.
|
|
3
|
+
"version": "4.5.1-dev.3",
|
|
4
4
|
"description": "MarqueeContent provides a set of tools for creating dynamic and adaptive ticker animations on web pages using GSAP and ScrollTrigger.",
|
|
5
5
|
"author": "ux-ui.pro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,9 @@
|
|
|
52
52
|
"rimraf": "6.0.1",
|
|
53
53
|
"typescript": "5.8.2",
|
|
54
54
|
"vite": "6.2.1",
|
|
55
|
-
"vite-plugin-dts": "4.5.3"
|
|
55
|
+
"vite-plugin-dts": "4.5.3"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
56
58
|
"gsap": "3.12.7"
|
|
57
59
|
},
|
|
58
60
|
"keywords": [
|