Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I catch the jQTouch animation completion?
    primarykey
    data
    text
    <p>I use jQTouch (and its built-in animations) in developing iPhone version of a website. So, I have a static menu:</p> <pre><code>&lt;ul class="rounded"&gt; &lt;li class="arrow"&gt;&lt;a href="#item1" class="fade"&gt;Item 1&lt;/a&gt;&lt;/li&gt; &lt;li class="arrow"&gt;&lt;a href="#item2" class="fade"&gt;Item 2&lt;/a&gt;&lt;/li&gt; &lt;li class="arrow"&gt;&lt;a href="#item3" class="fade"&gt;Item 3&lt;/a&gt;&lt;/li&gt; &lt;li class="arrow"&gt;&lt;a href="#item4" class="fade"&gt;Item 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>that's included in some <code>div</code>'s. My problem is to hide the item that has link with hash same as the <code>id</code> of the <code>div</code>, it belongs to, and same as the <code>location.hash</code>, when the user is on such a page.</p> <p>So, <code>click</code> event on a link (which moves user to another <code>div</code> with animation) isn't appropriate because the <code>location.hash</code> changes only when the animation completes.</p> <p>That's the question: How can I catch the jQTouch animation completion to solve the problem? Maybe I can do it with jQuery itself, but how?</p> <p>Thanks.</p> <p><strong>EDIT:</strong> I've found the solution. So, I post it here.</p> <pre><code> $('body &gt; div').bind('pageAnimationEnd', function(){ //wait a bit for the end of the animation //and hash change setTimeout(function(){ //current div id divId = '#' + $('.current .toolbar + .section').parent().attr('id'); //test whether there's a link to the same page link = $(divId + ' .rounded li').find('a[href='+divId+']'); if ( divId == location.hash &amp;&amp; link.length &gt; 0 ) { $('a[href='+divId+']').parent().fadeOut(0); } else { $('a[href='+divId+']').parent().fadeIn(0); } }, 100); }); </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.
 

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