I've managed to get this scroll function to work whereby it scrolls to the top of the div when you stop scrolling, the only problem is, it's doesn't do it smoothly at all, it just keeps jumping around and doesn't work very well.
Here's my js:
$(document).ready(function(){
Resize();
});
//Every resize of window
$(window).resize(function() {
Resize();
});
//Dynamically assign height
function Resize() {
// Handler for .ready() called.
var windowHeight = $(window).height() + 'px';
$('.fill-browser').css('height', windowHeight);
}
$(function(){
var _top = $(window).scrollTop();
var individualDivHeight = $(".fill-browser").height();
$(window).scroll(function(){
var _cur_top = $(window).scrollTop();
var totalHeight = $('body').height();
var posToScroll = Math.round(_cur_top / individualDivHeight) * individualDivHeight;
$('html, body').stop().animate({scrollTop: posToScroll}, 200);
});
});
Also a working fiddle here too to demonstrate what I mean: http://jsfiddle.net/vHAWW/2/
I would like the function to be quite quick when you stop scrolling, but it's just not smooth at all, can't seem to figure out why?