我使用jQTouch(及其内置动画)开发iPhone版的网站。所以,我有一个静态菜单:如何捕捉jQTouch动画完成?
<ul class="rounded">
<li class="arrow"><a href="#item1" class="fade">Item 1</a></li>
<li class="arrow"><a href="#item2" class="fade">Item 2</a></li>
<li class="arrow"><a href="#item3" class="fade">Item 3</a></li>
<li class="arrow"><a href="#item4" class="fade">Item 4</a></li>
</ul>
这是包含在一些div
的。我的问题是隐藏与hash链接相同的项目div
的id
,它属于location.hash
,并且与用户在此页面上时相同。
因此,链接上的click
事件(将用户移动到另一个带动画的div
)并不合适,因为location.hash
仅在动画完成时才会更改。
这就是问题:如何捕捉jQTouch动画完成来解决问题?也许我可以用jQuery自己做,但是怎么做?
谢谢。
编辑: 我找到了解决方案。所以,我在这里发布。
$('body > 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
&& link.length > 0)
{
$('a[href='+divId+']').parent().fadeOut(0);
}
else
{
$('a[href='+divId+']').parent().fadeIn(0);
}
}, 100);
});
哈哈!这就是所谓的'只是谷歌它!'...人们,粘贴到谷歌'jqtouch事件',第一个链接将传递给谷歌存储库的关于jQTouch回调事件,http://code.google。 COM/p/jqtouch /维基/ CallbackEvents。 – franzose 2010-07-21 06:03:02