Disable Skrollr for mobile device ( <767px )

后端 未结 6 2072
暖寄归人
暖寄归人 2021-02-02 01:59

Firstly would like to thanks @prinzhorn for such an amazing and powerful library. My question: I have implemented a Skrollr parallax background to the header of my website but I

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-02 02:42

    You can also use userAgent detection - so smaller desktop resolutions still get the parallax effect:

    //function
    $(function skrollrInit() {
    
        //initialize skrollr
        skrollr.init({
            smoothScrolling: false
        });
    
        // disable skrollr if using handheld device
        if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
            skrollr.init().destroy();
        }
    
    });
    
    //execute function
    skrollrInit();
    

提交回复
热议问题