GithubHelp home page GithubHelp logo

zhengdai / pull-to-refresh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svdgraaf/pull-to-refresh

0.0 1.0 0.0 146 KB

pull-to-refresh jquery plugin

CSS 21.61% HTML 49.62% JavaScript 28.77%

pull-to-refresh's Introduction

Pull to refresh

Easy to use javascript plugin for implementing pull-to-refresh to any page. It works especially well for webapps installed on the homescreen. Or you can use it in your app webviews.

Demo

Point your i-device to: http://bit.ly/pull-to-refresh

How to use

See demo.html, call pull_to_refresh() on a block element and you're done. Easiest would be to point a wrapper element surrounding your entire content.

The wrapper element will get a 'position: absolute' css style (to support the pulling), and will add a div above your wrapper which will hold the actual pullbar.

  $('#wrapper').pull_to_refresh({
    refresh: function(stoploading){
      alert('start reload!');
      stoploading();
    }
  });

Options

There are several options available, which you can provide during setup:

  var defaults = {
    refresh: function(callback){},
    pull_to_refresh_text: 'Pull down to refresh...',
    letgo_text: 'Release to refresh...',
    refreshing_text: 'Refreshing...',
    status_indicator_id: 'pull_to_refresh',
    refreshClass: 'refresh',
    visibleClass: 'visible',
  };
  • refresh

    A function, which will be called when the refresh is triggered, it will get a callback method as only option. You can call this function to have the bar removed again.

  • pull_to_refresh_text

    The text that will show up when the bar is being pulled

  • letgo_text

    The text that will show up when the bar is pulled enough to trigger the refresh callback

  • refreshing_text

    Text that will show when the bar is let go, and the refresh callback will be triggered

  • status_indicator_id

    id of the element to use for the status indicator, you probably won't have to change this

  • refresh_class

    Class to be used when bar is being refreshed

  • visible_class

    Class to be used when the bar was pulled far enough to trigger the refresh callback

Pro-tips

  • Handy for full webapp functionality
  • See the demo.html file for an example

Problems?

I haven't tested this with other libraries out there (jquery-mobile, iscroll, etc.), so I'm not sure whether this script will interfere with any of those. Then again, they probably provide their own solution :)

Caveats/TODO

  • I'm not sure if this works on any Android devices, I don't have those around, so if anyone can test, that would be sweet :)
  • The element you call will get a position absolute, to support the dragging
  • We need to call e.preventDefault() so this will break the default bouncing of your webview, any tips would be appreciated

Credits

Inspired by http://waynepan.com/2010/07/30/javascript-pull-to-refresh/

pull-to-refresh's People

Contributors

svdgraaf avatar

Watchers

Zhengdai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.