I have a horizontal-scrolling site that is using mousewheel jQuery Plugin. The scroll works but I want to snap each "article" to the left-side of the document so it doesn't stay half-way cut once scrolling is stopped.
The markup I have so far:
CSS
#viewport {
width:100%;
height:100%;
overflow: hidden;
}
#stage {
height:100%;
width:400%;
position: absolute;
display:block;
overflow: hidden;
}
#stage article {
width:25%;
height:100%;
position: relative;
display:block;
float:left;
}
HTML
<div id="viewport">
<section id="stage" class="clearfix">
<article>
This is the block that should snap to the left once scrolling is stopped.
</article>
<article>
This is the block that should snap to the left once scrolling is stopped.
</article>
<article>
This is the block that should snap to the left once scrolling is stopped.
</article>
<article>
This is the block that should snap to the left once scrolling is stopped.
</article>
</section>
</div>
JQUERY
$(function() {
$("html, body").mousewheel(function(event, delta) {
this.scrollLeft -= (delta * 30);
event.preventDefault();
});
});
I tried using this script with no good results. It seems the percentages are preventing knowing the previous/next location.
https://stackoverflow.com/a/8170667
Thanks in advance.