Prinzhorn / skrollr-menu

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

a hook for the hashchange #61

Closed mkdgs closed 9 years ago

mkdgs commented 9 years ago

I want know when the hash change, so i propose these change.

and use it like that:

            // Init Skrollr
            s = skrollr.init();
            skrollr.menu.init();

            s.onHashChange = function(hash) {
                    jQuery(window).trigger('hashchange'); // yeah !!! i can catch hashchange event !!!
            };           
Prinzhorn commented 9 years ago

Is there a reason you can't use the native hashchange event (https://developer.mozilla.org/en-US/docs/Web/Events/hashchange)?

mkdgs commented 9 years ago

of course ! because hashchange is never triggering by history.pushState( ) . if skrollr keep silent this change, no one see it. see: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_pushState%28%29_method Let me know if i am wrong, and thanks for your good work !

have a happy New Year of code !