I have a fairly long single page site which I use navigation to scroll up and down vertically through the different sections. Currently I am using the following javascript to accomplish this.
$(".scroll").click(function(event) {
event.preventDefault();
var $anchor = $('#' + this.hash.substring(1));
$('html,body').animate({
scrollTop: $anchor.offset().top - $anchor.attr('data-section-offset')
}, 500);
});
});
The issue I am having is the page is also quite heavy on large images and so when I am scrolling through sections it can get a bit choppy. I was wondering how difficult would it be to add some easing to this? I am already including the jquery-easing script for another plugin, but my jquery and html5 animate knowledge is still a bit light. Any suggestions would be appreciated.
I had thought of just using lazy load on images but they are all background images so I dont think that will help.
- The data offset is being used so the scroll clears the sicky navigation bar. Thanks, JC