I'm attempting to create a horizontal scroller simliar to this. http://www.k2.pl/
I made a prototype here. http://jsfiddle.net/Uu3aP/1
I looked into the carousel plugins but none function how I would like.
I'm just curious how I perform speed calculation based on the x position to the left and right and maybe use an easing method for the sides.
This is where I am currently at, any assistance would be appreciated.
HTML
<div id="scroll">
<div id="scrollContainer">
<ul>
<li><img src="http://placehold.it/350x350" alt="" /></li>
<li><img src="http://placehold.it/350x350" alt="" /></li>
<li><img src="http://placehold.it/350x350" alt="" /></li>
<li><img src="http://placehold.it/350x350" alt="" /></li>
<li><img src="http://placehold.it/350x350" alt="" /></li>
</ul>
</div>
CSS
body {
margin: 0;
}
#scroll {
width: 100%;
overflow: hidden;
}
#scrollContainer * {
float: left;
list-style: none;
margin: 0;
padding: 0;
}
JAVASCRIPT
$(document).ready(function() {
var $totalwidth = 0;
var $paneTarget = $('#scroll');
var $paneContainer = $('#scrollContainer');
var $this = $(this);
var $w = $this.width();
$paneTarget.find('li').each(function() {
$totalwidth += $this.width();
$paneContainer.width($totalwidth);
});
$paneTarget.on('mousemove', function(e) {
if ((e.pageX) < $w / 2) {
$paneTarget.stop().scrollTo( {top:'0', left:'-=100'}, 200, {easing: 'linear'});
} else if ((e.pageX) > ($w / 2)) {
$paneTarget.stop().scrollTo( {top:'0', left:'+=100'}, 200, {easing: 'linear'});
}
else {
$paneTarget.stop();
}
});
});