2011-12-08 2 views
2

iPad의 Mobile Safari에있는 HTML5 템플릿. iScroll 부서가 잘 작동합니다. 또한 if/else 문에 jQuery 함수가 포함되어 있어야합니다. 이 함수는 사용자가 iScroll div 외부를 탭하면 iScroll div를 페이드 아웃하는지 테스트합니다.
if/else 문은 사용자가 페이지에서 두 번째 div 외부를 두드리는 경우 테스트로 작동하지만 사용자가 iScroll div 외부를 두드리는 경우 테스트로 작동하지 않습니다. 왜, 모든 div ID가 iScroll div와 관련된 if/else 구문에서 시도했는지는 알 수 없습니다. 아래
기능 :
iScroll 충돌

var articleBodyEl = document.getElementById('content'); 
articleBodyEl.addEventListener("touchend", function() { 
var $target = $(event.target); 
if ($target.is('ul#article_images') || $target.is('ul#article_images li') || $target.is('div#article')) { 
    //do nothing 
} else { 
    $('#article').fadeToggle('fast'); 
} 
}); 

#article = iScroll 사업부이 사업부가 잘 작동 외부 사용자가 클릭하면

#article_images = 페이지에 별도의 사업부, 고환.
HTML :

<div id="article"> 
<div id="article_content"> 
    <div id="scroller"> 
    <div id="text_1" class="article_text"> 
    <h4>Wish you were here</h4> 
    <p>Sometimes we stumble upon a photograph that requires no words whatsoever. An image that proves the ancient adage that a good picture is worth a thousand words (and probably more, if some of them are small words like ‘if’, ‘it’ and ‘er’). </p> 
    </div> 
    </div> 
</div> 
</div> 

답변

0

는 다음과 경우/다른 대체하려고, 콘텐츠 사업부는 iScroll의 부모가 당신이 iScroll의 touchend 이벤트에 인 stopPropagation에있을 수 있습니다 다음 div에있다

if (!$target.is('div#article')) { 
    $('div#article').fadeToggle('fast'); 
} 

합니다.