Devon
Devon

Reputation: 89

Fullpage.js OnLeave firing twice when return false in all browsers but Chrome

I have this code:

$('#fullpage').fullpage({
    scrollingSpeed: 500,
    onLeave: function(index, nextIndex, direction){
        if(nextIndex == 2){
                alert('test');
            return false;
        }
    }
});

In Chrome the alert is occurring once, but in Firefox and IE it seems to be occurring twice. Any insight into why this is happening would be SUPER appreciated!

Here's the fiddle: http://jsfiddle.net/97tbk/856/

Thanks!

Upvotes: 3

Views: 615

Answers (1)

Alvaro
Alvaro

Reputation: 41595

It seems to be a bug in fullPage.js related with the way it handles the mouse events:

function addMouseWheelHandler() {
    if (document.addEventListener) {
        document.addEventListener('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
        document.addEventListener('wheel', MouseWheelHandler, false); //Firefox

    // [[[[[[[ THE ISSUE IS HERE ]]]]]]]
        document.addEventListener('DOMMouseScroll', MouseWheelHandler, false); //Old Firefox 
    } else {
        document.attachEvent('onmousewheel', MouseWheelHandler); //IE 6/7/8
    }
}

It seems Firefox is listening to both events, wheel and DOMMouseScroll. You can check it here. Try removing the "Old firefox" event handler (DOMMouseScroll) and you'll see how it only fires one now.

Feel free to open an issue in fullpage.js repository reporting it.

Upvotes: 1

Related Questions