Toggle Class with Scrolling in Firefox

0

Hello! I have the following code that for some reason works perfectly in Chrome, but not in Firefox. Could someone help me figure out why? Given that it has already been worked to try to adapt to Firefox. Still unsuccessful.

<script>
var scrollVal = 0;
var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
$(document).bind(mousewheelevt, function(e) {
    var offset = -1 * e.originalEvent.wheelDelta;
    if (mousewheelevt == "DOMMouseScroll"){
      offset = e.originalEvent.layerY - e.originalEvent.clientY;
    }
    scrollVal += offset;        
    if (scrollVal < 0) scrollVal = 0;
    console.log(scrollVal);        
    if (scrollVal == 0) {
        $('#projetos').addClass( "bottom");
    }else {
        $('#projetos').removeClass("bottom");
    }    
});
</script>
    
asked by anonymous 15.03.2017 / 17:11

0 answers