node-marquee
Advanced tools
Comparing version 1.0.23 to 1.0.25
@@ -11,2 +11,2 @@ /* | ||
*/ | ||
!function(t){var r={};function i(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=r,i.d=function(e,n,t){i.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(n,e){if(1&e&&(n=i(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)i.d(t,r,function(e){return n[e]}.bind(null,r));return t},i.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(n,"a",n),n},i.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},i.p="/",i(i.s=0)}([function(e,n,t){"use strict";function L(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=function(e,n){if(!e)return;if("string"==typeof e)return u(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,n)}(e))){var n=0,t=function(){};return{s:t,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i,o=!0,a=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}function u(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}t.r(n);function r(e){var o=0<arguments.length&&void 0!==e?e:{};o=Object.assign({selector:".node-marquee",speed:1,autoplay:!0,pauseOnHover:!1},o);var n,a=(n=o.selector)instanceof HTMLElement||n instanceof Window?n:document.querySelector(n);if(null==a)return!1;a.classList.add("node-marquee");var u=a.innerText,l=0,s=[],c=0,t=!1,r=4,i=!1;function d(){i&&i.disconnect()}m();var f=m.bind(this);window.addEventListener("resize",f,!1);var v=function(){o.pauseOnHover&&O()};a.addEventListener("mouseenter",v,!1);var p=function(){o.pauseOnHover&&g()};a.addEventListener("mouseleave",p,!1);var y=!1;function m(){d(),l=0,s=[],a.innerHTML="",a.style.position="relative",a.style.width="100%",a.style.overflow="hidden",a.style.whiteSpace="nowrap";var e=b().clientWidth;e<a.clientWidth&&(l=Math.ceil(1.5*a.clientWidth/e)),l<r&&(l=r);for(var n=0;n<l-1;n++)b(!0,!0);w(),(i=new MutationObserver(function(e){var n,t=L(e);try{for(t.s();!(n=t.n()).done;){"childList"===n.value.type&&(u=a.innerText,m())}}catch(e){t.e(e)}finally{t.f()}})).observe(a,{childList:!0})}function b(e,n){var t=0<arguments.length&&void 0!==e&&e,r=1<arguments.length&&void 0!==n&&n,i=document.createElement("div");return i.classList.add("node-marquee__el"),i.innerHTML=r?" "+u:u,t&&(i.style.position="absolute",i.style.top="0",i.style.left="0"),i.style.display="inline-block",a.appendChild(i),s.push(i),i}function h(){w(),t&&(y=window.requestAnimationFrame(h.bind(this)))}function w(){c+=o.speed;for(var e=!1,n=0,t=0;t<l;t++){var r=s[t],i=n-c;n+=r.clientWidth,r.style.transform="translate(".concat(i,"px, 0)"),i<-1*r.clientWidth&&(e=r)}e&&(s.push(s.splice(s.indexOf(e),1)[0]),c-=e.clientWidth)}function g(){y||(t=!0,y=window.requestAnimationFrame(h.bind(this)))}function O(){t=!1,y&&(window.cancelAnimationFrame(y),y=!1)}return o.autoplay&&g(),{play:g.bind(this),pause:O.bind(this),destroy:function(){O(),d(),window.removeEventListener("resize",f,!1),a.removeEventListener("mouseenter",v,!1),a.removeEventListener("mouseleave",p,!1),a.innerHTML=u}.bind(this),render:h.bind(this)}}window.nodeMarquee=r}]); | ||
!function(t){var r={};function i(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=r,i.d=function(e,n,t){i.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(n,e){if(1&e&&(n=i(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)i.d(t,r,function(e){return n[e]}.bind(null,r));return t},i.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(n,"a",n),n},i.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},i.p="/",i(i.s=0)}([function(e,n,t){"use strict";function M(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(!e)return;if("string"==typeof e)return l(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,n)}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){u=!0,o=e},f:function(){try{a||null==t.return||t.return()}finally{if(u)throw o}}}}function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}t.r(n);function r(e){var n,o=0<arguments.length&&void 0!==e?e:{},o=Object.assign({selector:".node-marquee",speed:1,autoplay:!0,pauseOnHover:!1,source:"innerHTML"},o),a=(n=o.selector)instanceof HTMLElement||n instanceof Window?n:document.querySelector(n);if(null==a)return!1;a.classList.add("node-marquee");var u="innerHTML"==o.source?a.innerHTML:a.innerText,l=0,s=[],c=0,t=!1,r=4,i=!1;function d(){i&&i.disconnect()}m();var f=m.bind(this);window.addEventListener("resize",f,!1);var v=function(){o.pauseOnHover&&L()};a.addEventListener("mouseenter",v,!1);var p=function(){o.pauseOnHover&&g()};a.addEventListener("mouseleave",p,!1);var y=!1;function m(){d(),l=0,s=[],a.innerHTML="",a.style.position="relative",a.style.width="100%",a.style.overflow="hidden",a.style.whiteSpace="nowrap";var e=b().clientWidth;e<a.clientWidth&&(l=Math.ceil(1.5*a.clientWidth/e)),l<r&&(l=r);for(var n=0;n<l-1;n++)b(!0,!0);w(),(i=new MutationObserver(function(e){var n,t=M(e);try{for(t.s();!(n=t.n()).done;){"childList"===n.value.type&&(u=a.innerText,m())}}catch(e){t.e(e)}finally{t.f()}})).observe(a,{childList:!0})}function b(e,n){var t=0<arguments.length&&void 0!==e&&e,r=1<arguments.length&&void 0!==n&&n,i=document.createElement("div");return i.classList.add("node-marquee__el"),i.innerHTML=r?" "+u:u,t&&(i.style.position="absolute",i.style.top="0",i.style.left="0"),i.style.display="inline-block",a.appendChild(i),s.push(i),i}function h(){w(),t&&(y=window.requestAnimationFrame(h.bind(this)))}function w(){c+=o.speed;for(var e=!1,n=0,t=0;t<l;t++){var r=s[t],i=n-c;n+=r.clientWidth,r.style.transform="translate(".concat(i,"px, 0)"),i<-1*r.clientWidth&&(e=r)}e&&(s.push(s.splice(s.indexOf(e),1)[0]),c-=e.clientWidth)}function g(){y||(t=!0,y=window.requestAnimationFrame(h.bind(this)))}function L(){t=!1,y&&(window.cancelAnimationFrame(y),y=!1)}return o.autoplay&&g(),{play:g.bind(this),pause:L.bind(this),destroy:function(){L(),d(),window.removeEventListener("resize",f,!1),a.removeEventListener("mouseenter",v,!1),a.removeEventListener("mouseleave",p,!1),a.innerHTML=u}.bind(this),render:h.bind(this)}}window.nodeMarquee=r}]); |
@@ -12,5 +12,5 @@ "use strict"; | ||
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
@@ -25,2 +25,3 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
* @property {boolean} [pauseOnHover=false] Stop the marquee on hover. | ||
* @property { "innerHTML" | "innerText" } [source="innerHTML"] The source of text. | ||
*/ | ||
@@ -50,3 +51,4 @@ | ||
autoplay: true, | ||
pauseOnHover: false | ||
pauseOnHover: false, | ||
source: "innerHTML" | ||
}; | ||
@@ -63,3 +65,3 @@ prop = Object.assign(DEFAULT_PROP, prop); // check if the element exists | ||
var text = OUTER.innerText; // quantity of elements | ||
var text = prop.source == "innerHTML" ? OUTER.innerHTML : OUTER.innerText; // quantity of elements | ||
@@ -66,0 +68,0 @@ var quantity = 0, |
export = nodeMarquee; | ||
/** | ||
* @typedef Prop | ||
* @property {string|HTMLElement} [selector=.node-marquee] The selector of the element or the elements itself. | ||
* @property {number} [speed=1] The amount of pixels to move with each frame. | ||
* @property {boolean} [autoplay=true] If you want the marquee element to start moving after its initializing. | ||
* @property {boolean} [pauseOnHover=false] Stop the marquee on hover. | ||
* @property [selector = .node-marquee] - <p>The selector of the element or the elements itself.</p> | ||
* @property [speed = 1] - <p>The amount of pixels to move with each frame.</p> | ||
* @property [autoplay = true] - <p>If you want the marquee element to start moving after its initializing.</p> | ||
* @property [pauseOnHover = false] - <p>Stop the marquee on hover.</p> | ||
* @property [source = "innerHTML"] - <p>The source of text.</p> | ||
*/ | ||
@@ -14,11 +14,5 @@ declare type Prop = { | ||
pauseOnHover?: boolean; | ||
source?: "innerHTML" | "innerText"; | ||
}; | ||
/** | ||
* @typedef Returns | ||
* @property {Function} play | ||
* @property {Function} pause | ||
* @property {Function} destroy | ||
* @property {Function} render | ||
*/ | ||
declare type Returns = { | ||
@@ -32,9 +26,5 @@ play: (...params: any[]) => any; | ||
/** | ||
* @author Anthony Bobrov {@link https://github.com/antonbobrov/node-marquee.git| GitHub} | ||
* | ||
* Custom Marquee element with JavaScript. | ||
* @param {Prop} prop | ||
* @returns { Returns | false } Returns a set of methods. | ||
* @returns <p>Returns a set of methods.</p> | ||
*/ | ||
declare function nodeMarquee(prop: Prop): Returns | false; | ||
{ | ||
"name": "node-marquee", | ||
"version": "1.0.23", | ||
"version": "1.0.25", | ||
"description": "Custom Marquee element with JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -43,2 +43,4 @@ # Custom Marquee element with JavaScript. | ||
autoplay | boolean | true | If you want the marquee element to start moving after its initializing. | ||
pauseOnHover | boolean | false | Pause animation on mouse enter. | ||
source | "innerHTML" \| "innerText" | "innerHTML" | Text source. | ||
@@ -52,2 +54,4 @@ | ||
play | Start animation. | ||
pause | Pause animation. | ||
pause | Pause animation. | ||
destroy | Destroy the marquee. | ||
render | Imitate rendering. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
649831
55
1322