2

I have a problem with removing event listeners from mousewheel and wheel. I'm using fullpage.js plugin.

The problem is, when I get from my "about page" to another by clicking link (I am using the ui router for angular.js) and then clicking on back button to get back on about page, the event listeners on mousewheel and wheel are not removed and get an additional listener attached. Repeating these steps add more listeners.

.directive('dfAboutPagesView', function(  ) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
                scope.checkPackages = {
                    all: false
                };

            scope.$on("$destroy", function() {
                $(document).off();
            });

            var fullpage_in = function () {

                element.fullpage({
                    scrollingSpeed: 500,
                    autoScrolling: false
                });
                element.fullpage({
                    onLeave: function (index, nextIndex, direction) {
                        if (index == 1 && direction == 'down') {
                            $('#header').slideUp(500, 'easeInQuad');
                        }
                        else if (index == 2 && direction == 'up') {
                            $('#header').slideDown(500, 'easeInQuad');
                        }
                        else if (index == 3 && direction == 'down') {
                            $('#footer').slideDown(500, 'easeInQuad');
                        }
                        else if (index == 4 && direction == 'up') {
                            $('#footer').slideUp(500, 'easeInQuad');
                        }
                        }
                    });
                };
    fullpage_in();
            }
    }
})

1 Answer 1

3

Looking at the documentation for fullPage.js, I think you want to call the plugin's destroy method in your $destroy handler:

scope.$on("$destroy", function() {
     $.fn.fullpage.destroy('all');
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.