Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Scrollable Missing position onload and on api seek in webkit browsers
    primarykey
    data
    text
    <p>Strange issue i am having while working on <a href="http://identica.staging.dante-studios.com/" rel="nofollow">this</a> in the bottom right hand corner is a history section with a scrollable section that moved right or left. On load it picks a random number and moves to it.</p> <p>Problem is that on load (without moving) it loads in the wrong position, and on moving with the api it moves to the wrong offset (right image just not positioned correctly). This issue only happens in <strong>Webkit</strong> browsers (<strong>Safari</strong> and <strong>Chromium</strong>)</p> <p>Any help would be greatly appreciated as i cant seem to get to the bottom of this IE and FF behave well strangely! :(</p> <p><strong>JavaScript</strong>:</p> <pre><code>$(document).ready(function(){ $('.timeline-container').scrollable({circular: true, next: ".timeline-next", prev: ".timeline-prev"}); var api_timeline = $(".timeline-container").data("scrollable"); //console.info(api_timeline.getSize()); var timeline_random_index = Math.floor( Math.random() * ( api_timeline.getSize()+1) )+1; //console.info(timeline_random_index); api_timeline.move( timeline_random_index, 1000 ); }); </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div class="timeline-container"&gt; &lt;div class="timeline-items"&gt; &lt;div class="timeline-item"&gt; &lt;img src="http://identica.local/wp-content/uploads/2010/10/timeline_thumb01.png" /&gt; &lt;p&gt;&lt;span class="timeline-item-date"&gt;1996&lt;/span&gt; Russian Flag carrier Aeroflot created&lt;/p&gt; &lt;/div&gt; &lt;div class="timeline-item"&gt; &lt;img src="http://identica.local/wp-content/uploads/2010/10/timeline_thumb02.png" /&gt; &lt;p&gt;&lt;span class="timeline-item-date"&gt;1997&lt;/span&gt; Universal Studios created&lt;/p&gt; &lt;/div&gt; &lt;div class="timeline-item"&gt; &lt;img src="http://identica.local/wp-content/uploads/2010/10/timeline_thumb03.png" /&gt; &lt;p&gt;&lt;span class="timeline-item-date"&gt;1998&lt;/span&gt; Vodafone brand refresh&lt;/p&gt; &lt;/div&gt; &lt;div class="timeline-item"&gt; &lt;img src="http://identica.local/wp-content/uploads/2010/10/timeline_thumb04.png" /&gt; &lt;p&gt;&lt;span class="timeline-item-date"&gt;1998&lt;/span&gt; Wembley Stadium identity created&lt;/p&gt; &lt;/div&gt; &lt;div class="timeline-item"&gt; &lt;img src="http://identica.local/wp-content/uploads/2010/10/timeline_thumb05.png" /&gt; &lt;p&gt;&lt;span class="timeline-item-date"&gt;2000&lt;/span&gt; Jonnie Walker brand created&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>.timeline-container {overflow:hidden; width: 245px;position:relative; min-height: 170px;height: 170px !important;} .timeline-container .timeline-items { width:20000em; position:absolute;} .timeline-container .timeline-item {float:left;text-align:center;position: relative;} .timeline-container .timeline-items p { font-weight: normal; font-size: 13px; margin-bottom:0;} .timeline-container .timeline-items span { font-weight: bold;} </code></pre> <p><strong>UPDATE</strong></p> <p>Really strange, i have set this up on <a href="http://jsfiddle.net/r9XSg/" rel="nofollow">jsFiddle</a> and it runs correctly in all browsers. with exactly the same code. Not it is more confusing. Something "else" on the page must be effecting it.</p> <p><strong>UPDATE 2</strong></p> <p>I have just "fixed" it in a way, but it is a dirty little hack - not ideal but works:</p> <pre><code>$(document).ready(function(){ $('.timeline-container').scrollable({circular: true, next: ".timeline-next", prev: ".timeline-prev"}); var api_timeline = $(".timeline-container").data("scrollable"); var timeline_random_index = Math.floor( Math.random() * ( api_timeline.getSize()+1) )+1; var timeline_random_index_pixles = timeline_random_index * 245 * -1; $(".timeline-items").css("left", timeline_random_index_pixles+"px") }); </code></pre>
    singulars
    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.
 

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