Prinzhorn / skrollr-menu

skrollr plugin for hash navigation
MIT License
285 stars 143 forks source link

handleLink buggy on safari iOS #84

Open Bobz-zg opened 8 years ago

Bobz-zg commented 8 years ago

Works very bad when I try to use handleLink to define scrollTop position, if removed all works well. But problem is that I have sticky nav at top and want to calculate my own offset. If I add offset as data-attribute to each section then also all works fine, so I'm not sure is there something wrong with my code or what..

It just scrolls to random parts of page.

$(document).ready( function($) {

        var s = skrollr.init({
            forceHeight: true,
            edgeStrategy: 'set',
            smoothScrolling: true,
            easing: {
                WTF: Math.random,
                inverted: function(p) {
                    return 1-p;
                }
            }
        });

        skrollr.menu.init(s, {
            animate: true,
            easing: 'sqrt',
            complexLinks: false,
            handleLink: function(link) {
                $menu = $(link).attr('href');
                $pos  = parseInt($($menu).offset().top) - $('.banner').outerHeight();

                return Math.abs($pos);
            },
            change: function(newHash, newTopPosition) {

                $('body').removeClass('nav-active');

                return newTopPosition;
            },
            updateUrl: false
        });
    });