pixelcog / parallax.js

Simple parallax scrolling effect inspired by Spotify.com implemented as a jQuery plugin
MIT License
3.53k stars 838 forks source link

How to use with custom scroll bar plugin? #246

Open ahsanazwar opened 6 years ago

ahsanazwar commented 6 years ago

I am using parallax scrolling on the with the plugin (pixelcog parallax.js) its running fine with the default browser scroll bar but I am using custom scroll bar plugin on my website but parallax is not running. I tried the following code but its not working. Html:

<body>
<section class="hobies-wrapper" data-parallax="scroll" data-image-src="images/parallax-img2.png"></section>
</body>

Javascripr

function myCustomFn(el){
    $('.hobies-wrapper').parallax({imageSrc: 'images/parallax-img2.png'});    
};
$(document).ready(function () 
{
$("body").mCustomScrollbar({
                theme:"minimal",
                mouseWheel:{ enable: true },
                keyboard:{ enable: true },
                mouseWheel:{ invert: true },
                documentTouchScroll: true,
                scrollEasing:"easeInOut",
                scrollButtons:{
                    enable:true
                    },
                callbacks:{
                    onScroll:function(){
                        myCustomFn(this);   
                    }
                    }
                    });
});