UNPKG

futura.js

Version:

A small JavaScript library for common tasks such as Carousel, Exception, Animation handler and more...

9 lines (8 loc) 1.5 kB
/* : MIT @version : v1.0.0 @contributors : ... */ class Exception$$module$lib$core$Exception{constructor(a){console.error("---------- FuturaJs -----------\n \n \t AN ERROR WAS OCCURRED\n\nFile : \nMessage : "+(a+"\nLine : \n \n \nVisit web site for help -> https://js.futura-vision.com"));document}}window.fJs=window.fJs??{};window.fJs.Exception=Exception$$module$lib$core$Exception;var module$lib$core$Exception={};module$lib$core$Exception.default=Exception$$module$lib$core$Exception;const STICKY_CLASS_LIST$$module$lib$core$Sticky="position-fixed w-100 start-0 top-0 shadow fv-zd animate__animated animate__fadeInDown".split(" "),EXCEPTION_ERROR$$module$lib$core$Sticky="Element options is empty"; class Sticky$$module$lib$core$Sticky{constructor(a={elt:"",class:"",callback:null,fallback:null}){if(""===a.elt)return new Exception$$module$lib$core$Exception(EXCEPTION_ERROR$$module$lib$core$Sticky);a.elt=document.querySelector(a.elt);this.options=a;this.run()}run(){let a=this.options;window.addEventListener("scroll",c=>{window.scrollY>=a.elt.getClientRects()[0].height?STICKY_CLASS_LIST$$module$lib$core$Sticky.forEach(b=>{a.elt.classList.add(b)})||(a.callback?a.callback(a.elt):!1):STICKY_CLASS_LIST$$module$lib$core$Sticky.forEach(b=> {a.elt.classList.remove(b)})||a.elt.classList.remove(a.class)||(a.fallback?a.fallback(a.elt):!1)})}}window.fJs.Sticky=Sticky$$module$lib$core$Sticky;var module$lib$core$Sticky={};module$lib$core$Sticky.default=Sticky$$module$lib$core$Sticky;