Materializecss Parallax mousewheel jitters fix

Materializecss Parallax mousewheel jitters fix

I noticed the materializecss parallax plugin was a bit jittery in chrome when using the mousewheel to scroll. I fixed the problem by adding a window mousewheel callback that aborts the default mousewheel scroll sets the scroll amount consistently. Hope this helps someone.

 

$( window ).bind('mousewheel', function( ev ){
    ev.preventDefault();
    var $window = $(window),
        scrollIncrement = ev.originalEvent.deltaY/5,
        scrollPos = $window.scrollTop(),
        newPos = scrollPos+scrollIncrement;
    $window.scrollTop( newPos );          
} );
This entry was posted in Javascript. Bookmark the permalink.