Note that there are some explanatory texts on larger screens.

plurals
  1. POhorizontal accelerated carousel scroller
    primarykey
    data
    text
    <p>I'm attempting to create a horizontal scroller simliar to this. <a href="http://www.k2.pl/" rel="nofollow">http://www.k2.pl/</a> </p> <p>I made a prototype here. <a href="http://jsfiddle.net/Uu3aP/1" rel="nofollow">http://jsfiddle.net/Uu3aP/1</a></p> <p>I looked into the carousel plugins but none function how I would like.</p> <p>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.</p> <p>This is where I am currently at, any assistance would be appreciated.</p> <p>HTML</p> <pre><code>&lt;div id="scroll"&gt; &lt;div id="scrollContainer"&gt; &lt;ul&gt; &lt;li&gt;&lt;img src="http://placehold.it/350x350" alt="" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="http://placehold.it/350x350" alt="" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="http://placehold.it/350x350" alt="" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="http://placehold.it/350x350" alt="" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="http://placehold.it/350x350" alt="" /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p></p> <p>CSS</p> <pre><code>body { margin: 0; } #scroll { width: 100%; overflow: hidden; } #scrollContainer * { float: left; list-style: none; margin: 0; padding: 0; } </code></pre> <p>JAVASCRIPT</p> <pre><code>$(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) &lt; $w / 2) { $paneTarget.stop().scrollTo( {top:'0', left:'-=100'}, 200, {easing: 'linear'}); } else if ((e.pageX) &gt; ($w / 2)) { $paneTarget.stop().scrollTo( {top:'0', left:'+=100'}, 200, {easing: 'linear'}); } else { $paneTarget.stop(); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload