Computer >> 컴퓨터 >  >> 프로그램 작성 >> HTML

HTML로 모바일 웹 브라우저에서 새로고침하려면 아래로 당깁니다.


최신 업데이트를 받기 위해 페이지를 새로고침하기 위해 화면을 풀다운해야 하는 경우 JavaScript, xhttprequests 및 터치 이벤트의 도움으로 이를 수행할 수 있습니다.

풀 새로 고침은 AJAX에서 XHR에 대한 트리거입니다. 원하는 요소에 새 데이터를 추가합니다.

풀 새로 고침은 iscroll과 같은 하이재킹된 JavaScript 스크롤 메커니즘을 사용하여 구현할 수 있습니다. Twitter는 새로 고침 옵션을 가져오기 위해 iscroll을 사용하고 있습니다.

또 다른 방법은 overflow에 대한 새로 고침 처리기를 만드는 것입니다. :스크롤 구성 요소.

제공된 인터페이스는 핸들러 인터페이스에 대한 아이디어를 제공할 수 있습니다 -

var PullToRefresh= function(callback, wrapper, instructionsText) {

   //It creates dom elements and append them before content wrapper  
   
   // <div class="mainWrapper" style="overflow: scroll; height: 600px;">
   <div class="pullToReloadWrapper"></div><div class = "contentWrapper"></div>
   </div> is the markup.
   
   // if main wrapper's height is > than content wrapper's
   height, then change the main wrapper height to be the height of the content wrapper.
   
   // scroll main wrapper.
   // invoke initializeEvents() to inititalize the events
};