class WindowUtils {    
    constructor() {
        this.w = {
            h: window.innerHeight,
            w: window.innerWidth,
            st: window.pageYOffset
        };

        this.BREAKPOINTS = {
            XS: { NAME: "xs", MIN: 0,    MAX: 767  },
            SM: { NAME: "sm", MIN: 768,  MAX: 1099 },
            MD: { NAME: "md", MIN: 1100, MAX: 1299 },
            LG: { NAME: "lg", MIN: 1300, MAX: 1499 },
            XL: { NAME: "xl", MIN: 1500, MAX: null }
        };

        this.updateWindowH();
        this.updateWindowW();
        this.updateVh();
    }

    isTouch () {
        return 'ontouchstart' in document.documentElement;
    }
    
    isXS () {
        return window.innerWidth <= this.BREAKPOINTS.XS.MAX;
    }

    isSM () {
        return window.innerWidth >= this.BREAKPOINTS.SM.MIN && window.innerWidth <= this.BREAKPOINTS.SM.MAX;
    }
    
    isMD () {
        return window.innerWidth >= this.BREAKPOINTS.MD.MIN && window.innerWidth <= this.BREAKPOINTS.MD.MAX;
    }

    isLG () {
        return window.innerWidth >= this.BREAKPOINTS.LG.MIN && window.innerWidth <= this.BREAKPOINTS.LG.MAX;
    }

    isXL () {
        return window.innerWidth >= this.BREAKPOINTS.XL.MIN;
    }
    
    isTablet () {
        return isSM() || isMD();
    }

    isDesktop () {
        return isLG() || isXL();
    }

    updateWindowH () {
        this.w.h = window.innerHeight;
    }

    updateWindowW () {
        this.w.w = window.innerWidth;
    }

    updateVh () {
        var vh = this.w.h * 0.01 + "px";
        document.documentElement.style.setProperty('--vh', vh);
    }
}

export default WindowUtils;