Skip to content

Commit

Permalink
add option to disable initial scrollTop on page load (when hash value…
Browse files Browse the repository at this point in the history
…s are disabled)
  • Loading branch information
shrpne committed Aug 9, 2016
1 parent 92ef42a commit 326c07d
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions jquery.scrollify.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
standardScrollElements: false,
setHeights: true,
overflowScroll:true,
initialScrollToTop: true,
before:function() {},
after:function() {},
afterResize:function() {},
Expand Down Expand Up @@ -152,18 +153,18 @@
scrollTop: heights[index]
}, settings.scrollSpeed,settings.easing);
}

if(window.location.hash.length && settings.sectionName && window.console) {
try {
if($(window.location.hash).length) {
console.warn("Scrollify warning: There are IDs on the page that match the hash value - this will cause the page to anchor.");
}
} catch (e) {
console.warn("Scrollify warning:", window.location.hash, "is not a valid jQuery expression.");
}
}
$(settings.target).promise().done(function(){
currentIndex = index;

if(window.location.hash.length && settings.sectionName && window.console) {
try {
if($(window.location.hash).length) {
console.warn("Scrollify warning: There are IDs on the page that match the hash value - this will cause the page to anchor.");
}
} catch (e) {
console.warn("Scrollify warning:", window.location.hash, "is not a valid jQuery expression.");
}
}
$(settings.target).promise().done(function(){
currentIndex = index;
locked = false;
firstLoad = false;
if(callbacks) {
Expand Down Expand Up @@ -529,10 +530,12 @@

if(true===hasLocation) {
animateScroll(index,false,true);
} else {
} else if (settings.initialScrollToTop) {
setTimeout(function() {
animateScroll(0,false,true);
},200);
} else {
manualScroll.calculateNearest();
}
if(heights.length) {
manualScroll.init();
Expand Down

0 comments on commit 326c07d

Please sign in to comment.