p-t-r

0.0.5 • Public • Published

pull-to-refresh

Trying to be, but it is not yet: Android / Chrome / Material like pull to refresh for mobile and browser that doesn't block text selection.

It works on mobile browsers. Desktop/mouse situations have a lot of annoying edge cases. There is code in this repo that deals with desktop, but it needs work to have a nice API that handles desktop considerations and yet is not ridiculous to configure for mobile also.

View the demo.

install

$ npm install p-t-r

example

import { pullToRefresh, Indicator, ElasticIndicator } from 'p-t-r'
import disableChromePtr from 'disable-chrome-ptr'
import bowser from 'bowser'
 
const enableChromePtr = (bowser.mobile && bowser.chrome) ? disableChromePtr() : () => {}
 
const ptr = pullToRefresh({
  touchElement: document.body,
  scrollElememt: document.body,
  indicator: (bowser.webkit ? ElasticIndicator : Indicator)({ target: document.body }),
  onRefresh: () => { return promiseFromSomeAsyncThing() }
})
 
// do an initial load if you want
ptr.refresh()
 
// to remove pull to refresh
ptr.end()
enableChromePtr()

Package Sidebar

Install

npm i p-t-r

Weekly Downloads

0

Version

0.0.5

License

CC0-1.0

Last publish

Collaborators

  • m59