iPhone 버전의 웹 사이트를 개발할 때 jQTouch (및 내장 애니메이션)를 사용합니다. 정적 메뉴가 있습니다. div
에 포함 된 고정 메뉴가 있습니다.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
의 id
과 같은 해시 링크가있는 항목을 숨기고 사용자가 해당 페이지에있을 때 location.hash
과 같으며 속합니다.
location.hash
은 애니메이션이 완료 될 때만 변경되기 때문에 링크상의 이벤트 (애니메이션을 사용하여 다른 div
으로 이동하는)의 이벤트는 적합하지 않습니다.
질문 : 문제를 해결하기 위해 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);
});
하하! 그것은 '단지 google it!'입니다 ... 사람들, google 'jqtouch events'에 붙여 넣기 만하면 첫 번째 링크가 jQTouch 콜백 이벤트에 대한 Google 저장소의 위키로 연결됩니다. http://code.google. co.kr/p/jqtouch/wiki/CallbackEvents. – franzose