Pull down to refresh on the mobile web browser in HTML.


When there is a requirement to pull down the screen to refresh the page to get latest updates, this can be done with the help of JavaScript, xhttprequests and then touch events.

Pull refresh is a trigger to XHR in AJAX .It adds new data to the element we want.

Pull refresh can be implemented with the help of hijacked JavaScript scrolling mechanism like iscroll. Twitter is using iscroll to pull refresh option.

Another way is to create a refresh handler for overflow:scroll components.

The interface provided can give an idea about the handler interface −

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
};

Updated on: 24-Jun-2020

689 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements