2010-07-21 4 views
3

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> 

내 문제는 divid과 같은 해시 링크가있는 항목을 숨기고 사용자가 해당 페이지에있을 때 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);    
    }); 
+0

하하! 그것은 '단지 google it!'입니다 ... 사람들, google 'jqtouch events'에 붙여 넣기 만하면 첫 번째 링크가 jQTouch 콜백 이벤트에 대한 Google 저장소의 위키로 연결됩니다. http://code.google. co.kr/p/jqtouch/wiki/CallbackEvents. – franzose

답변

0

Safari와 Chrome에서 작동합니까? 저에게 그것은 Firefox에서만 작동합니다.

+0

나는 오랫동안 그걸로 뭔가 해왔다. 내가 아는 한, 그것은 Webkit에서만 적절하게 작동합니다. 왜냐하면 jQTouch는 Apple의 모바일 개발을 위해 설계 되었기 때문입니다. 우리는 그 당시 모바일 개발을 탐험하는 것을 멈추었으며 지금은 jQuery Mobile을 기다리고 있습니다. 약속대로 진정한 크로스 플랫폼입니다. – franzose

관련 문제