accordion.js
2 weeks ago
add-to-cart.js
2 weeks ago
animated-heading.js
2 weeks ago
block-animations.js
2 weeks ago
carousel.js
2 weeks ago
count-animations.js
2 weeks ago
countdown.js
2 weeks ago
form.js
2 weeks ago
popup.js
2 weeks ago
progress-bar.js
2 weeks ago
reveal-button.js
2 weeks ago
sticky.js
2 weeks ago
table-of-contents-smooth-scroll.js
2 weeks ago
typing-animations.js
2 weeks ago
count-animations.js
1 lines
| 1 | (()=>{"use strict";var t,e=new WeakMap;function n(t,e,n){var a=n>0?t.toFixed(n):Math.round(t).toString();if(e){var i=a.split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),i.join(".")}return a}function a(t,a){var i=a||{},o=t.textContent,r=function(t){var e=t.trim(),n=-1!==e.indexOf(","),a=e.replace(/[,\s]/g,""),i=parseFloat(a);if(isNaN(i))return null;var o=0,r=a.indexOf(".");return-1!==r&&(o=a.length-r-1),{value:i,hasCommas:n,decimals:o}}(o.trim());if(r){var s,u=o.match(/^\s*/)[0],d=o.match(/\s*$/)[0],c=2e3/(s=parseFloat(t.getAttribute("data-spbadd-anim-count-speed")),Math.max(.25,Math.min(3,s||1))),l=function(t){return Math.max(0,Math.min(99999,t||0))}(parseInt(t.getAttribute("data-spbadd-anim-count-delay"),10)),m=!i.once&&"true"===t.getAttribute("data-spbadd-anim-count-loop"),f=r.value;!function(t){var n=e.get(t);n&&(cancelAnimationFrame(n.raf),clearTimeout(n.timeout),null!=n.originalText&&(t.textContent=n.originalText),n.styleLocked&&(t.style.minWidth=n.originalMinWidth),e.delete(t))}(t);var h,p={raf:0,timeout:0,originalText:i.preview?o:null,styleLocked:!1,originalMinWidth:t.style.minWidth};e.set(t,p),document.fonts&&document.fonts.ready?document.fonts.ready.then(g):g()}function v(){var a=null;h.textContent=u+n(0,r.hasCommas,r.decimals)+d,p.raf=requestAnimationFrame((function o(s){if(!i.preview||h.isConnected){a||(a=s);var l=Math.min((s-a)/c,1),g=1-Math.pow(1-l,3),x=f*g;h.textContent=u+n(x,r.hasCommas,r.decimals)+d,l<1?p.raf=requestAnimationFrame(o):m?p.timeout=setTimeout((function(){v()}),2e3):e.delete(t)}else e.delete(t)}))}function g(){if(e.get(t)===p){var n=Math.ceil(t.getBoundingClientRect().width);n>0&&(t.style.minWidth=n+"px",p.styleLocked=!0),h=i.preview?function(t){var e=document.createElement("span");return e.className="spbadd-anim-count-display",e.setAttribute("contenteditable","false"),e.textContent=t.textContent,t.textContent="",t.appendChild(e),e}(t):t,p.timeout=setTimeout(v,l)}}}(t=document.querySelectorAll(".spbadd-anim-count")).length&&(window.matchMedia("(prefers-reduced-motion: reduce)").matches||t.forEach((function(t){var e=new IntersectionObserver((function(n){n.forEach((function(n){n.isIntersecting&&(a(t),e.unobserve(t))}))}),{threshold:.5});e.observe(t)})))})(); |