I'm trying to build site from divs that act kinda like pages. So there are multiple divs with min-height of 100% of browser window on top of each other. I'm trying to make navigation work so that user can scroll to next div with mouse wheel. I found this useful piece of code:
http://jsfiddle.net/Mottie/Vk7gB/
$('#nav').onePageNav();
var $current, flag = false;
$('body').mousewheel(function(event, delta) {
if (flag) { return false; }
$current = $('div.current');
if (delta > 0) {
$prev = $current.prev();
if ($prev.length) {
flag = true;
$('body').scrollTo($prev, 1000, {
onAfter : function(){
flag = false;
}
});
$current.removeClass('current');
$prev.addClass('current');
}
} else {
$next = $current.next();
if ($next.length) {
flag = true;
$('body').scrollTo($next, 1000, {
onAfter : function(){
flag = false;
}
});
$current.removeClass('current');
$next.addClass('current');
}
}
event.preventDefault();
});
But you can see that there is problem when content is longer than the browser window. I would like it to work so that if current div is longer than browser window scrolling works normally, but it should stop at the bottom of the div and then next time scroll all the way to the next div. Is there any way to make this happen?
I hope that this makes some sense..
Thanks,
-Mikkå