futura.js
Version:
A small JavaScript library for common tasks such as Carousel, Exception, Animation handler and more...
6 lines (5 loc) • 1.75 kB
JavaScript
const DEFAULT_INTERSECTION_OPTION$$module$lib$Utils={root:null,ratio:.2,rootMargin:"0px",threshold:.7,timeout:200},DATA_INTERSECTION_VISIBLE$$module$lib$Utils="data-fv-visible";
class Utils$$module$lib$Utils{IntersectionHandler(a={elt:"",visible:null,invisible:null,options:{}}){const d=a.options??DEFAULT_INTERSECTION_OPTION$$module$lib$Utils;if(IntersectionObserver){const c=new IntersectionObserver(function(b,g){b.forEach(function(f){let e=f.target;f.intersectionRatio>d.ratio?e.hasAttribute(DATA_INTERSECTION_VISIBLE$$module$lib$Utils)||(a.visible?a.visible(e):!1,e.setAttribute(DATA_INTERSECTION_VISIBLE$$module$lib$Utils,!0)):a.invisible?a.invisible(e):!1})},d);a.elt.forEach(function(b,
g){c.observe(b)})}}}var module$lib$Utils={};module$lib$Utils.default=Utils$$module$lib$Utils;const DATA_VALUE$$module$lib$core$NumberAutoCount="data-fv-data",COUNTDOWN_SELECTOR$$module$lib$core$NumberAutoCount="[data-fv-anim='countdown']";let _u$$module$lib$core$NumberAutoCount=new Utils$$module$lib$Utils;
class NumberAutoCount$$module$lib$core$NumberAutoCount{constructor(a=200){this.timeout=a;this.___=document.querySelectorAll(COUNTDOWN_SELECTOR$$module$lib$core$NumberAutoCount);this.begin()}begin(){_u$$module$lib$core$NumberAutoCount.IntersectionHandler({elt:this.___,visible:a=>this.count(a)})}count(a){const d=a.getAttribute(DATA_VALUE$$module$lib$core$NumberAutoCount);let c=0,b=setInterval(()=>{c<=d?a.innerText=c:this.stopCount(b);c++},this.timeout)}stopCount(a){clearInterval(a)}}
window.fJs.NumberAutoCount=NumberAutoCount$$module$lib$core$NumberAutoCount;new NumberAutoCount$$module$lib$core$NumberAutoCount;var module$lib$core$NumberAutoCount={};module$lib$core$NumberAutoCount.default=NumberAutoCount$$module$lib$core$NumberAutoCount;