marciofmjr
5/4/2018 - 12:48 AM

isMobile

Javascript function to verify if breakpoint is mobile or not based on css

+bp-mobile // or mobile breakpoint
    body:before
        display: block
        width: 1px
        height: 1px
        overflow: hidden
        opacity: 0
        color: transparent
        position: absolute
        content: "mobile"
function isMobile(){
    var content = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content');
    if(content == "\"mobile\"" || content == "mobile"){
        return true;
    }else{
        return false;
    }
}