PluginProbe
UiCore Elements – Free widgets and templates for Elementor / trunk
UiCore Elements – Free widgets and templates for Elementor vtrunk
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / assets / js / lib / odometer.js

odometer.js in UiCore Elements – Free widgets and templates for Elementor trunk, at assets/js/lib/odometer.js

1 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";var __assign=function(){return(__assign=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},rAF=window.requestAnimationFrame||function(t){window.setTimeout(t,1e3/60)},Odometer=function(){function t(t){this.version="1.0",this.defaults={duration:.8,lastDigitDelay:.25},this.cell_digits=null,this.options=__assign(__assign({},this.defaults),t),this.cell_digits=null}return t.prototype.render=function(t,o){for(var e,s=this.options,n=!1,l=(this.cell_digits||(n=!0,document.querySelector("style[odometer]")||((e=document.createElement("style")).setAttribute("odometer","odometer"),e.innerHTML=".odometer-numbers{display:inline-flex;line-height:100%;overflow-y:hidden}.odometer-numbers>span{display:flex;flex-direction:column;justify-content:start;align-items:center;height:1em;will-change:transform;transform:translateY(0)}",document.head.appendChild(e)),t.innerHTML='<div class="odometer-numbers"></div>',this.cell_digits=[]),'<span style="color:transparent">0</span>'),a="transform ".concat(s.duration,"s ease-out"),d=this.cell_digits.length;d<o.length;d++){var i=document.createElement("span");i.style.transition=a,i.innerHTML=n?"":l,t.firstChild&&t.firstChild.appendChild(i),this.cell_digits.push({container:i,current:void 0,position:n?1:0,new:!0})}function c(t,e){t.position--,t.container.appendChild(e),t.lastTimeAdd=+new Date,t.new?(t.new=!1,rAF(function(){t.container.style.transform="translateY(".concat(t.position,"em)")})):t.container.style.transform="translateY(".concat(t.position,"em)")}for(var u,m,r=Math.max(o.length,this.cell_digits.length),h=function(){u=d<o.length?o.charAt(d):null;var t,e,n,i,r=f.cell_digits[d];r.current!=u&&(r.current=u,(m=document.createElement("span")).innerHTML=null===u?l:u,r.container.children.length<4?c(r,m):(e=m,(t=r).nextToAdd&&(c(t,t.nextToAdd),clearTimeout(t.lastTimer),t.nextToAdd=null),n=+new Date,i=1e3*s.lastDigitDelay-(n-t.lastTimeAdd),s.lastDigitDelay<=0||n-t.lastTimeAdd>=1.05*i?(c(t,e),t.nextToAdd=null):(t.nextToAdd=e,t.lastTimer=setTimeout(function(){c(t,t.nextToAdd),t.nextToAdd=null},1e3*s.duration))),clearTimeout(r.timerClean),r.timerClean=setTimeout(function(){r.timerClean=null,r.container.children.length<3||(r.container.style.transition="none",rAF(function(){for(r.position=-1;1<r.container.children.length;)r.container.removeChild(r.container.firstChild);var t=document.createElement("span");t.innerHTML=l,r.container.insertBefore(t,r.container.firstChild),r.container.style.transform="translateY(".concat(r.position,"em)"),rAF(function(){r.container.style.transition=a})}))},1e3*((s.duration||.8)+(s.duration||.25))+2500))},f=this,d=0;d<r;d++)h()},t}();window.Odometer=Odometer;