marquee3001
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -21,24 +21,24 @@ /** | ||
constructor(element, options) { | ||
this.element = element; | ||
this.selector = options.selector; | ||
this.speed = element.dataset.speed || 0.25; | ||
this.pausable = element.dataset.pausable; | ||
this.reverse = element.dataset.reverse; | ||
this.paused = false; | ||
this.parent = element.parentElement; | ||
this.parentProps = this.parent.getBoundingClientRect(); | ||
this.content = element.children[0]; | ||
this.innerContent = this.content.innerHTML; | ||
this.wrapStyles = ''; | ||
this.offset = 0; | ||
this.element = element; | ||
this.selector = options.selector; | ||
this.speed = element.dataset.speed || 0.25; | ||
this.pausable = element.dataset.pausable; | ||
this.reverse = element.dataset.reverse; | ||
this.paused = false; | ||
this.parent = element.parentElement; | ||
this.parentProps = this.parent.getBoundingClientRect(); | ||
this.content = element.children[0]; | ||
this.innerContent = this.content.innerHTML; | ||
this.wrapStyles = ''; | ||
this.offset = 0; | ||
this._setupWrapper(); | ||
this._setupContent(); | ||
this._setupEvents(); | ||
this._setupWrapper(); | ||
this._setupContent(); | ||
this._setupEvents(); | ||
this.wrapper.appendChild(this.content); | ||
this.element.appendChild(this.wrapper); | ||
this.wrapper.appendChild(this.content); | ||
this.element.appendChild(this.wrapper); | ||
} | ||
_setupWrapper() { | ||
_setupWrapper() { | ||
this.wrapper = document.createElement('div'); | ||
@@ -125,4 +125,6 @@ this.wrapper.classList.add('marquee3k__wrapper'); | ||
static init(options = { selector: 'marquee3k' }) { | ||
let animationId; | ||
window.cancelAnimationFrame(animationId); | ||
window.removeEventListener('resize', resizeListener); | ||
if (window.MARQUEES_ANIMATIONID) { | ||
window.cancelAnimationFrame(window.MARQUEES_ANIMATIONID); | ||
} | ||
window.MARQUEES = []; | ||
@@ -145,19 +147,21 @@ const marquees = Array.from(document.querySelectorAll(`.${options.selector}`)); | ||
} | ||
animationId = window.requestAnimationFrame(animate); | ||
window.MARQUEES_ANIMATIONID = window.requestAnimationFrame(animate); | ||
} | ||
window.addEventListener('resize', () => { | ||
clearTimeout(timer); | ||
function resizeListener() { | ||
clearTimeout(timer); | ||
timer = setTimeout(() => { | ||
const isLarger = previousWidth < window.innerWidth; | ||
const difference = window.innerWidth - previousWidth; | ||
timer = setTimeout(() => { | ||
const isLarger = previousWidth < window.innerWidth; | ||
const difference = window.innerWidth - previousWidth; | ||
for (let i = 0; i < MARQUEES.length; i++) { | ||
MARQUEES[i].repopulate(difference, isLarger); | ||
} | ||
for (let i = 0; i < MARQUEES.length; i++) { | ||
MARQUEES[i].repopulate(difference, isLarger); | ||
} | ||
previousWidth = this.innerWidth; | ||
}); | ||
}, 250); | ||
previousWidth = this.innerWidth; | ||
}, 250); | ||
} | ||
window.addEventListener('resize', resizeListener); | ||
} | ||
@@ -164,0 +168,0 @@ } |
{ | ||
"name": "marquee3001", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Internet marquees in HD!", | ||
@@ -5,0 +5,0 @@ "keywords": ["marquee", "marquees"], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32761
277