diff --git a/index.html b/index.html index 2b2f4a8..da8d67e 100644 --- a/index.html +++ b/index.html @@ -114,14 +114,16 @@

Wambo

- + diff --git a/src/skrollr.menu.js b/src/skrollr.menu.js index f8e2bcd..395695a 100644 --- a/src/skrollr.menu.js +++ b/src/skrollr.menu.js @@ -43,7 +43,7 @@ */ var handleClick = function(e) { //Only handle left click. - if((e.which || e.button) !== 1) { + if(e.which !== 1 && e.button !== 0) { return; } @@ -116,6 +116,16 @@ return true; }; + var jumpStraightToHash = function() { + if(window.location.hash && document.querySelector) { + var link = document.querySelector('a[href="' + window.location.hash + '"]'); + + if(link) { + handleLink(link, true); + } + } + }; + var defer = function(fn) { window.setTimeout(fn, 1); }; @@ -154,6 +164,8 @@ }); }, false); } + + jumpStraightToHash(); }; //Private reference to the initialized skrollr. @@ -168,14 +180,6 @@ defer(function() { if(window.location.hash) { window.scrollTo(0, 0); - - if(document.querySelector) { - var link = document.querySelector('a[href="' + window.location.hash + '"]'); - - if(link) { - handleLink(link, true); - } - } } }); }(document, window));