node-marquee
Advanced tools
Comparing version 2.0.1 to 2.0.3
@@ -11,2 +11,2 @@ /* | ||
*/ | ||
!function(e){var n={};function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(i,r,function(n){return e[n]}.bind(null,r));return i},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=0)}([function(e,n,t){"use strict";function i(e){return e instanceof HTMLElement||e instanceof Element}function r(e,n){if(e instanceof Window)return e;if(i(e))return e;if(void 0!==n){const t=r(n);if(t)return t.querySelector(e)}return document.querySelector(e)}t.r(n),window.nodeMarquee=function(e={}){const n="node-marquee",t=r((e=Object.assign({selector:".node-marquee",speed:1,autoplay:!0,pauseOnHover:!1,applyOuterStyles:!0},e)).selector);if(!i(t))return!1;t.classList.add(n);let o=t.innerHTML,s=0,u=[],l=0,c=!1,d=!1;const a=b.bind(this),f=function(){e.pauseOnHover&&O()}.bind(this),p=function(){e.pauseOnHover&&L()}.bind(this);b();let y=!1;function b(){v(),s=0,u=[],t.innerHTML="",e.applyOuterStyles&&(t.style.position="relative",t.style.width="100%",t.style.overflow="hidden",t.style.whiteSpace="nowrap");let n=m().clientWidth;n<=0&&(n=window.innerWidth),n<t.clientWidth&&(s=Math.ceil(1.5*t.clientWidth/n)),s<4&&(s=4);for(let e=0;e<s-1;e++)m(!0,!0);w(),function(){const e={childList:!0};d=new MutationObserver(e=>{for(const n of e)"childList"===n.type&&(o=t.innerHTML,b())}),d.observe(t,e)}()}function m(e=!1,n=!1){const i=document.createElement("div");return i.classList.add("node-marquee__el"),i.innerHTML=n?" "+o:o,e&&(i.style.position="absolute",i.style.top="0",i.style.left="0"),i.style.display="inline-block",t.appendChild(i),u.push(i),i}function v(){d&&d.disconnect()}function h(){w(),c&&(y=window.requestAnimationFrame(h.bind(this)))}function w(){l+=e.speed;let n=!1,t=0;for(let e=0;e<s;e++){const i=u[e],r=t-l;t+=i.clientWidth,i.style.transform=`translate(${r}px, 0)`,r<-1*i.clientWidth&&(n=i)}n&&(u.push(u.splice(u.indexOf(n),1)[0]),l-=n.clientWidth)}function L(){y||(c=!0,y=window.requestAnimationFrame(h.bind(this)))}function O(){c=!1,y&&(window.cancelAnimationFrame(y),y=!1)}return e.autoplay&&L(),window.addEventListener("resize",a,!1),t.addEventListener("mouseenter",f,!1),t.addEventListener("mouseleave",p,!1),{play:L.bind(this),pause:O.bind(this),isPlaying:()=>c,render:w.bind(this),recreate:b.bind(this),destroy:function(){O(),v(),window.removeEventListener("resize",a,!1),t.removeEventListener("mouseenter",f,!1),t.removeEventListener("mouseleave",p,!1),t.innerHTML=o}.bind(this)}}}]); | ||
!function(e){var n={};function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(i,r,function(n){return e[n]}.bind(null,r));return i},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=0)}([function(e,n,t){"use strict";function i(e){return e instanceof HTMLElement||e instanceof Element}function r(e,n){if(e instanceof Window)return e;if(i(e))return e;if(void 0!==n){const t=r(n);if(t)return t.querySelector(e)}return document.querySelector(e)}t.r(n),window.nodeMarquee=function(e={}){const n="node-marquee",t=r((e=Object.assign({selector:".node-marquee",speed:1,autoplay:!0,pauseOnHover:!1,applyOuterStyles:!0},e)).selector);if(!i(t))return!1;t.classList.add(n);let o=t.innerHTML,s=0,u=[],l=0,c=!1,d=!1;const a=b.bind(this),f=function(){e.pauseOnHover&&O()}.bind(this),p=function(){e.pauseOnHover&&L()}.bind(this);b();let y=!1;function b(){v(),s=0,u=[],t.innerHTML="",e.applyOuterStyles&&(t.style.position="relative",t.style.width="100%",t.style.overflow="hidden",t.style.whiteSpace="nowrap");let n=m().clientWidth;n<=0&&(n=window.innerWidth),n<t.clientWidth&&(s=Math.ceil(1.5*t.clientWidth/n)),s<4&&(s=4);for(let e=0;e<s-1;e++)m(!0,!0);w(),function(){const e={childList:!0};d=new MutationObserver(e=>{for(const n of e)"childList"===n.type&&(o=t.innerHTML,b())}),d.observe(t,e)}()}function m(e=!1,n=!1){const i=document.createElement("div");return i.classList.add("node-marquee__el"),i.innerHTML=n?" "+o:o,e&&(i.style.position="absolute",i.style.top="0",i.style.left="0"),i.style.display="inline-block",t.appendChild(i),u.push(i),i}function v(){d&&d.disconnect()}function h(){w(),c&&(y=window.requestAnimationFrame(h.bind(this)))}function w(n=e.speed){l+=n;let t=!1,i=0;for(let e=0;e<s;e++){const n=u[e],r=i-l;i+=n.clientWidth,n.style.transform=`translate(${r}px, 0)`,r<-1*n.clientWidth&&(t=n)}t&&(u.push(u.splice(u.indexOf(t),1)[0]),l-=t.clientWidth)}function L(){y||(c=!0,y=window.requestAnimationFrame(h.bind(this)))}function O(){c=!1,y&&(window.cancelAnimationFrame(y),y=!1)}return e.autoplay&&L(),window.addEventListener("resize",a,!1),t.addEventListener("mouseenter",f,!1),t.addEventListener("mouseleave",p,!1),{play:L.bind(this),pause:O.bind(this),isPlaying:()=>c,render:w.bind(this),recreate:b.bind(this),destroy:function(){O(),v(),window.removeEventListener("resize",a,!1),t.removeEventListener("mouseenter",f,!1),t.removeEventListener("mouseleave",p,!1),t.innerHTML=o}.bind(this)}}}]); |
@@ -161,4 +161,5 @@ "use strict"; | ||
// Render the Marquee Elements | ||
function renderElements() { | ||
translateX += prop.speed; | ||
function renderElements(speed) { | ||
if (speed === void 0) { speed = prop.speed; } | ||
translateX += speed; | ||
var moveToEnd = false; | ||
@@ -165,0 +166,0 @@ var w = 0; |
@@ -155,4 +155,4 @@ import { selectOne, isElement } from 'vevet-dom'; | ||
// Render the Marquee Elements | ||
function renderElements() { | ||
translateX += prop.speed; | ||
function renderElements(speed = prop.speed) { | ||
translateX += speed; | ||
let moveToEnd = false; | ||
@@ -159,0 +159,0 @@ let w = 0; |
@@ -44,3 +44,3 @@ export interface NodeMarqueeProp { | ||
*/ | ||
render: () => void; | ||
render: (speed: number) => void; | ||
/** | ||
@@ -47,0 +47,0 @@ * Destroy and create |
{ | ||
"name": "node-marquee", | ||
"version": "2.0.1", | ||
"version": "2.0.3", | ||
"description": "Custom Marquee element", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -226,5 +226,7 @@ import { selectOne, isElement } from 'vevet-dom'; | ||
// Render the Marquee Elements | ||
function renderElements () { | ||
function renderElements ( | ||
speed = prop.speed, | ||
) { | ||
translateX += prop.speed; | ||
translateX += speed; | ||
let moveToEnd: (HTMLElement | false) = false; | ||
@@ -231,0 +233,0 @@ |
@@ -47,3 +47,3 @@ export interface NodeMarqueeProp { | ||
*/ | ||
render: () => void; | ||
render: (speed: number) => void; | ||
/** | ||
@@ -50,0 +50,0 @@ * Destroy and create |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
245909
3282
1