I would like it to scroll to the next "page" or section of the page when the user uses the scroll wheel. Of course with the code I have (see below) it jumps to the next section but after multiple scrolls (like a standard user would scroll) it jumps through the sections, it seems to need a scroll threshold.
jQuery for ScrollTo:
var current
//Srolls window to the next div element using the scroll wheel.
// Would like to work out a scroll threshold.
$(function() {
$('body').mousewheel(function(event, delta) {
var $current = $('div.current');
console.log(delta);
console.log($current);
if (delta > 0) {
$prev = $current.prev();
if ($prev.length) {
$('body').scrollTo($prev, 500);
$current.removeClass('current');
$prev.addClass('current');
}
} else {
$next = $current.next();
if ($next.length) {
$('body').scrollTo($next, 500);
$current.removeClass('current');
$next.addClass('current');
}
}
event.preventDefault();
});
});
The version of scrollTo: http://cdnjs.cloudfl...usewheel.min.js
HTML
<body>
<div id="navWrap">
<div id="nav">
<ul>
<li><a href="#" class="smoothScroll">Demo Link 1</a></li>
<li><a href="#" class="smoothScroll">Demo Link 2</a></li>
<li><a href="#" class="smoothScroll">Demo Link 3</a></li>
<li><a href="#" class="smoothScroll">Demo Link 4</a></li>
</ul>
<br class="clearLeft" />
</div>
</div>
<div class="container current" id="welcome">
<div class="message">
<h1>It can be a lonely road. <br/>Let me help you.</h1>
</div>
</div>
<div class="container" id="aboutme"></div>
<div class="container" id="mywork"></div>
</body>
If you were to use this concept, how would you implement it? I do like the idea but I'm not the best jQuery programmer.

New Topic/Question
Reply


MultiQuote



|