node-marquee
Advanced tools
Comparing version 2.0.7 to 2.0.9
@@ -11,2 +11,2 @@ /* | ||
*/ | ||
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){"use strict";function i(e){return e instanceof HTMLElement||e instanceof Element}function o(e,t){if(e instanceof Window)return e;if(i(e))return e;if(void 0!==t){const n=o(t);if(n)return n.querySelector(e)}return document.querySelector(e)}n.r(t);const r=[];function s(e,t,n,i){if(void 0!==i){const o={passive:!1,once:!1};i.once&&(o.once=!0),i.passive&&(o.passive=!0),e.addEventListener(t,n,o)}else e.addEventListener(t,n);const o=`${Math.random()}-${+new Date}`;return r.push({id:o,el:e,target:t,callback:n}),{id:o,remove:l.bind(this,o)}}function l(e){const t=[];for(let n=0,i=r.length;n<i;n++){const i=r[n];i.id===e?i.el.removeEventListener(i.target,i.callback):t.push(i)}}window.nodeMarquee=function(e={}){const t="node-marquee";let n=!1;const r=o((e=Object.assign({selector:".node-marquee",speed:1,autoplay:!0,pauseOnHover:!1,applyOuterStyles:!0,optimizeCalculation:!1},e)).selector);if(!i(r))return!1;r.classList.add(t);let l=r.innerHTML,c=0,u=[],a=[],d=0,f=!1,p=!1;v();let m=!1;e.autoplay&&S();const h=s(window,"resize",v.bind(this)),y=s(r,"mouseenter",function(){e.pauseOnHover&&W()}.bind(this)),b=s(r,"mouseleave",function(){e.pauseOnHover&&S()}.bind(this));function v(){O(),c=0,u=[],a=[],r.innerHTML="",e.applyOuterStyles&&(r.style.position="relative",r.style.width="100%",r.style.overflow="hidden",r.style.whiteSpace="nowrap");let t=w().clientWidth;t<=0&&(t=window.innerWidth),t<r.clientWidth&&(c=Math.ceil(1.5*r.clientWidth/t)),c<4&&(c=4);for(let e=0;e<c-1;e++)w(!0,!0);g(),L(),function(){const e={childList:!0};p=new MutationObserver(e=>{for(const t of e)"childList"===t.type&&(l=r.innerHTML,v())}),p.observe(r,e)}(),e.optimizeCalculation&&setTimeout(()=>{g()},500)}function w(e=!1,t=!1){const n=document.createElement("div");return n.classList.add("node-marquee__el"),n.innerHTML=t?" "+l:l,e&&(n.style.position="absolute",n.style.top="0",n.style.left="0"),n.style.display="inline-block",r.appendChild(n),u.push(n),n}function O(){p&&p.disconnect()}function M(){L(),f&&(m=window.requestAnimationFrame(M.bind(this)))}function L(t=e.speed){d+=t;let n=!1,i=0,o=0;for(let t=0;t<c;t++){const r=u[t];e.optimizeCalculation||(a[t]=r.clientWidth);const s=a[t],l=o-d;o+=s,r.style.transform=`matrix3d(1,0,0.00,0,0.00,1,0.00,0,0,0,1,0, ${l}, 0, 0,1)`,l<-1*s&&(n=r,i=t)}n&&(u.push(u.splice(u.indexOf(n),1)[0]),d-=e.optimizeCalculation?a[i]:n.clientWidth,e.optimizeCalculation&&g())}function g(){if(!n)for(let e=0;e<c;e++){let t=u[e].clientWidth;t=u[e].clientWidth,t<=0&&(t=window.innerWidth),a[e]=t}}function S(){m||(f=!0,m=window.requestAnimationFrame(M.bind(this)))}function W(){f=!1,m&&(window.cancelAnimationFrame(m),m=!1)}return{play:S.bind(this),pause:W.bind(this),isPlaying:()=>f,render:L.bind(this),recreate:v.bind(this),updateSizes:g.bind(this),destroy:function(){n=!0,W(),O(),h.remove(),y.remove(),b.remove(),r.innerHTML=l}.bind(this)}}}]); | ||
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){"use strict";function i(e){return e instanceof HTMLElement||e instanceof Element}function o(e,t){if(e instanceof Window)return e;if(i(e))return e;if(void 0!==t){const n=o(t);if(n)return n.querySelector(e)}return document.querySelector(e)}n.r(t);const r=[];function s(e,t,n,i){if(void 0!==i){const o={passive:!1,once:!1};i.once&&(o.once=!0),i.passive&&(o.passive=!0),e.addEventListener(t,n,o)}else e.addEventListener(t,n);const o=`${Math.random()}-${+new Date}`;return r.push({id:o,el:e,target:t,callback:n}),{id:o,remove:l.bind(this,o)}}function l(e){const t=[];for(let n=0,i=r.length;n<i;n++){const i=r[n];i.id===e?i.el.removeEventListener(i.target,i.callback):t.push(i)}}window.nodeMarquee=function(e={}){const t="node-marquee";let n=!1;const r=o((e=Object.assign({selector:".node-marquee",speed:1,autoplay:!0,pauseOnHover:!1,applyOuterStyles:!0,optimizeCalculation:!1},e)).selector);if(!i(r))return!1;r.classList.add(t);let l=r.innerHTML,c=0,u=[],a=[],d=0,f=!1,p=!1;v();let m=!1;e.autoplay&&S();const h=s(window,"resize",v.bind(this)),y=s(r,"mouseenter",function(){e.pauseOnHover&&W()}.bind(this)),b=s(r,"mouseleave",function(){e.pauseOnHover&&S()}.bind(this));function v(){O(),c=0,u=[],a=[],r.innerHTML="",e.applyOuterStyles&&(r.style.position="relative",r.style.width="100%",r.style.overflow="hidden",r.style.whiteSpace="nowrap");let t=w().clientWidth;t<=0&&(t=window.innerWidth),t<r.clientWidth&&(c=Math.ceil(1.5*r.clientWidth/t)),c<4&&(c=4);for(let e=0;e<c-1;e++)w(!0);g(),L(),function(){const e={childList:!0};p=new MutationObserver((e=>{for(const t of e)"childList"===t.type&&(l=r.innerHTML,v())})),p.observe(r,e)}(),e.optimizeCalculation&&setTimeout((()=>{g()}),500)}function w(e=!1){const t=document.createElement("div");return t.classList.add("node-marquee__el"),t.innerHTML=` ${l}`,e&&(t.style.position="absolute",t.style.top="0",t.style.left="0"),t.style.display="inline-block",r.appendChild(t),u.push(t),t}function O(){p&&p.disconnect()}function M(){L(),f&&(m=window.requestAnimationFrame(M.bind(this)))}function L(t=e.speed){d+=t;let n=!1,i=0,o=0;for(let t=0;t<c;t++){const r=u[t];e.optimizeCalculation||(a[t]=r.clientWidth);const s=a[t],l=o-d;o+=s,r.style.transform=`matrix3d(1,0,0.00,0,0.00,1,0.00,0,0,0,1,0, ${l}, 0, 0,1)`,l<-1*s&&(n=r,i=t)}n&&(u.push(u.splice(u.indexOf(n),1)[0]),d-=e.optimizeCalculation?a[i]:n.clientWidth,e.optimizeCalculation&&g())}function g(){if(!n)for(let e=0;e<c;e++){let t=u[e].clientWidth;t=u[e].clientWidth,t<=0&&(t=window.innerWidth),a[e]=t}}function S(){m||(f=!0,m=window.requestAnimationFrame(M.bind(this)))}function W(){f=!1,m&&(window.cancelAnimationFrame(m),m=!1)}return{play:S.bind(this),pause:W.bind(this),isPlaying:()=>f,render:L.bind(this),recreate:v.bind(this),updateSizes:g.bind(this),destroy:function(){n=!0,W(),O(),h.remove(),y.remove(),b.remove(),r.innerHTML=l}.bind(this)}}}]); |
@@ -85,3 +85,3 @@ "use strict"; | ||
for (var i = 0; i < quantity - 1; i++) { | ||
createElement(true, true); | ||
createElement(true); | ||
} | ||
@@ -101,14 +101,8 @@ // update sizes of the elements | ||
} | ||
function createElement(absolutePosition, appendWhitespace) { | ||
function createElement(absolutePosition) { | ||
if (absolutePosition === void 0) { absolutePosition = false; } | ||
if (appendWhitespace === void 0) { appendWhitespace = false; } | ||
var el = document.createElement('div'); | ||
el.classList.add(className + "__el"); | ||
// set text | ||
if (appendWhitespace) { | ||
el.innerHTML = " " + text; | ||
} | ||
else { | ||
el.innerHTML = text; | ||
} | ||
el.innerHTML = " " + text; | ||
// apply styles | ||
@@ -115,0 +109,0 @@ if (absolutePosition) { |
@@ -82,3 +82,3 @@ import { selectOne, isElement, addEventListener } from 'vevet-dom'; | ||
for (let i = 0; i < quantity - 1; i++) { | ||
createElement(true, true); | ||
createElement(true); | ||
} | ||
@@ -98,12 +98,7 @@ // update sizes of the elements | ||
} | ||
function createElement(absolutePosition = false, appendWhitespace = false) { | ||
function createElement(absolutePosition = false) { | ||
const el = document.createElement('div'); | ||
el.classList.add(`${className}__el`); | ||
// set text | ||
if (appendWhitespace) { | ||
el.innerHTML = ` ${text}`; | ||
} | ||
else { | ||
el.innerHTML = text; | ||
} | ||
el.innerHTML = ` ${text}`; | ||
// apply styles | ||
@@ -110,0 +105,0 @@ if (absolutePosition) { |
{ | ||
"name": "node-marquee", | ||
"version": "2.0.7", | ||
"version": "2.0.9", | ||
"description": "Custom Marquee element", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,0 +0,0 @@ # Custom Marquee element |
@@ -0,0 +0,0 @@ import nodeMarquee from '../ts/index'; |
@@ -119,3 +119,3 @@ import { selectOne, isElement, addEventListener } from 'vevet-dom'; | ||
for (let i = 0; i < quantity - 1; i++) { | ||
createElement(true, true); | ||
createElement(true); | ||
} | ||
@@ -143,3 +143,2 @@ | ||
absolutePosition = false, | ||
appendWhitespace = false, | ||
) { | ||
@@ -151,8 +150,3 @@ | ||
// set text | ||
if (appendWhitespace) { | ||
el.innerHTML = ` ${text}`; | ||
} | ||
else { | ||
el.innerHTML = text; | ||
} | ||
el.innerHTML = ` ${text}`; | ||
@@ -159,0 +153,0 @@ // apply styles |
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
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
256155
3409