marquee-content 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.mm=gsap.matchMedia(),this.tl=gsap.timeline(),this.duration=this.dataset.mcDuration||20,this.skew=this.dataset.mcSkew,this.max=this.dataset.mcMax,this.min=this.dataset.mcMin,this.dir=this.dataset.mcDirection,this.breakpoints(),this.cloning(),this.skewed(),this.marquee(),this.scrollReverse(),this.debounce(),this.resizing()}breakpoints(){this.max||this.min?(this.max&&(this.breakpoint=`(max-width: ${this.max-.02}px)`),this.min&&(this.breakpoint=`(min-width: ${this.min}px)`)):this.breakpoint=""}cloning(){const t=()=>{for(;this.children.length>1;)this.removeChild(this.lastChild)};t(),this.mm.add(this.breakpoint,(()=>{if(this.hasChildNodes()){let t=(this.clientWidth/this.firstElementChild.clientWidth+3).toFixed(0);for(let e=1;e<t;e++){let t=this.firstElementChild,e=t.cloneNode(!0);t.parentNode.append(e)}}return()=>{t()}}))}skewed(){this.skew&&this.mm.add(this.breakpoint,(()=>{let t=this.skew<0?-1*this.skew:this.skew;return this.style.transformOrigin="center center",this.style.transform=`skew(0deg, ${this.skew}deg)`,this.style.minHeight=`calc(${1.25*t}vh + ${1.25*t}vw)`,()=>{this.style.removeProperty("transform-origin"),this.style.removeProperty("transform"),this.style.removeProperty("min-height")}}))}marquee(){this.mm.add(this.breakpoint,(()=>{this.tl=gsap.timeline(),gsap.config({nullTargetWarn:!1}),this.tl.paused(!0),gsap.set(this.children,{"will-change":"transform"}),this.tl.to(this.children,{duration:this.duration,x:"-100%",ease:"none",repeat:-1}).timeScale("ltr"===this.dir?-1:1).totalProgress(.5),ScrollTrigger.create({trigger:this,start:"top bottom",end:"bottom top",onEnter:()=>this.tl.resume(),onLeave:()=>this.tl.pause(),onEnterBack:()=>this.tl.resume(),onLeaveBack:()=>this.tl.pause()})}))}scrollReverse(){"auto"===this.dir&&this.mm.add(this.breakpoint,(()=>{let t=0,e=1;window.addEventListener("scroll",(()=>{let i=window.pageYOffset>t?1:-1;i!==e&&(gsap.to(this.tl,{timeScale:i,overwrite:!0}),e=i),t=window.pageYOffset}))}))}debounce(t,e){let i;return(...s)=>{i&&clearTimeout(i),i=setTimeout((()=>t(...s)),e)}}resizing(){const t=()=>{this.mm.add(this.breakpoint,(()=>{this.tl.kill(),this.tl=null,gsap.set(this.children,{clearProps:!0}),this.cloning(),this.marquee()}))};this.mm.add("(any-pointer: coarse)",(()=>{window.matchMedia("(orientation: portrait)").addEventListener("change",(e=>{e.matches||t()}))})),this.mm.add("(any-pointer: fine)",(()=>{window.addEventListener("resize",this.debounce((()=>{t()}),250))}))}}customElements.get("marquee-content")||customElements.define("marquee-content",t),new t})();
1
+ (()=>{"use strict";class t extends HTMLElement{constructor(){super(),this.mm=gsap.matchMedia(),this.tl=gsap.timeline(),this.dur=this.dataset.mcDuration||20,this.skew=this.dataset.mcSkew,this.max=this.dataset.mcMax,this.min=this.dataset.mcMin,this.dir=this.dataset.mcDirection,this.breakpoints(),this.cloning(),this.skewed(),this.marquee(),this.scrollReverse(),this.debounce(),this.resizing()}breakpoints(){this.max||this.min?(this.max&&(this.breakpoint=`(max-width: ${this.max-.02}px)`),this.min&&(this.breakpoint=`(min-width: ${this.min}px)`)):this.breakpoint=""}cloning(){const t=()=>{for(;this.children.length>1;)this.removeChild(this.lastChild)};t(),this.mm.add(this.breakpoint,(()=>{if(this.hasChildNodes()){let t=(this.clientWidth/this.firstElementChild.clientWidth+3).toFixed(0);for(let e=1;e<t;e++){let t=this.firstElementChild,e=t.cloneNode(!0);t.parentNode.append(e)}}return()=>{t()}}))}skewed(){this.skew&&this.mm.add(this.breakpoint,(()=>{let t=this.skew<0?-1*this.skew:this.skew;return this.style.transformOrigin="center center",this.style.transform=`skew(0deg, ${this.skew}deg)`,this.style.minHeight=`calc(${1.25*t}vh + ${1.25*t}vw)`,()=>{this.style.removeProperty("transform-origin"),this.style.removeProperty("transform"),this.style.removeProperty("min-height")}}))}marquee(){this.mm.add(this.breakpoint,(()=>{this.tl=gsap.timeline(),gsap.config({nullTargetWarn:!1}),this.tl.paused(!0),gsap.set(this.children,{"will-change":"transform"}),this.tl.to(this.children,{duration:this.dur,x:"-100%",ease:"none",repeat:-1}).timeScale("ltr"===this.dir?-1:1).totalProgress(.5),ScrollTrigger.create({trigger:this,start:"top bottom",end:"bottom top",onEnter:()=>this.tl.resume(),onLeave:()=>this.tl.pause(),onEnterBack:()=>this.tl.resume(),onLeaveBack:()=>this.tl.pause()})}))}scrollReverse(){"auto"===this.dir&&this.mm.add(this.breakpoint,(()=>{let t=0,e=1;window.addEventListener("scroll",(()=>{let i=window.pageYOffset>t?1:-1;i!==e&&(gsap.to(this.tl,{timeScale:i,overwrite:!0}),e=i),t=window.pageYOffset}))}))}debounce(t,e){let i;return(...s)=>{i&&clearTimeout(i),i=setTimeout((()=>t(...s)),e)}}resizing(){const t=()=>{this.mm.add(this.breakpoint,(()=>{this.tl.kill(),this.tl=null,gsap.set(this.children,{clearProps:!0}),this.cloning(),this.marquee()}))};this.mm.add("(any-pointer: coarse)",(()=>{window.matchMedia("(orientation: portrait)").addEventListener("change",(e=>{e.matches||t()}))})),this.mm.add("(any-pointer: fine)",(()=>{window.addEventListener("resize",this.debounce((()=>{t()}),250))}))}}customElements.get("marquee-content")||customElements.define("marquee-content",t),new t})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marquee-content",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Marquee content with GSAP",
5
5
  "author": "ux-ui.pro",
6
6
  "license": "MIT",
@@ -4,7 +4,7 @@ export class MarqueeContent extends HTMLElement {
4
4
 
5
5
  this.mm = gsap.matchMedia()
6
6
  this.tl = gsap.timeline()
7
- this.duration = this.dataset.mcDuration || 20
7
+ this.dur = this.dataset.mcDuration || 20
8
8
  this.skew = this.dataset.mcSkew
9
9
  this.max = this.dataset.mcMax
10
10
  this.min = this.dataset.mcMin
@@ -53,7 +53,9 @@ export class MarqueeContent extends HTMLElement {
53
53
  }
54
54
  }
55
55
 
56
- return () => { removingClones() }
56
+ return () => {
57
+ removingClones()
58
+ }
57
59
  })
58
60
  }
59
61
 
@@ -90,7 +92,7 @@ export class MarqueeContent extends HTMLElement {
90
92
  })
91
93
 
92
94
  this.tl.to(this.children, {
93
- duration: this.duration,
95
+ duration: this.dur,
94
96
  x: '-100%',
95
97
  ease: 'none',
96
98
  repeat: -1
@@ -142,12 +144,11 @@ export class MarqueeContent extends HTMLElement {
142
144
  }
143
145
 
144
146
  resizing() {
145
- const resetAmin = () => {
147
+ const resetAnimation = () => {
146
148
  this.mm.add(this.breakpoint, () => {
147
149
  this.tl.kill()
148
150
  this.tl = null
149
151
  gsap.set(this.children, { clearProps: true })
150
-
151
152
  this.cloning()
152
153
  this.marquee()
153
154
  })
@@ -158,14 +159,14 @@ export class MarqueeContent extends HTMLElement {
158
159
 
159
160
  portrait.addEventListener('change', (e) => {
160
161
  if(!e.matches) {
161
- resetAmin()
162
+ resetAnimation()
162
163
  }
163
164
  })
164
165
  })
165
166
 
166
167
  this.mm.add('(any-pointer: fine)', () => {
167
168
  window.addEventListener('resize', this.debounce(() => {
168
- resetAmin()
169
+ resetAnimation()
169
170
  }, 250))
170
171
  })
171
172
  }