src/PullToRefresh.js
async function handleScrollPull(element, scrollTarget) {
  const scrollTop = scrollTarget === window ?
    document.body.scrollTop :
    scrollTarget.scrollTop;
  if (scrollTop < 0) {
    // Negative scroll top means we're probably in WebKit.
    // Start a scroll pull operation.
    let scrollPullDistance = -scrollTop;
    if (element.state.scrollPullDistance &&
      !element.state.scrollPullMaxReached &&
      scrollPullDistance < element.state.scrollPullDistance) {
      // The negative scroll events have started to head back to zero (most
      // likely because the user let go and stopped scrolling), so we've reached
      // the maximum extent of the scroll pull. From this point on, we want to
      // stop our own translation effect and let the browser smoothly snap the
      // page back to the top (zero) scroll position. If we don't do that, we'll
      // be fighting with the browser effect, and the result will not be smooth.
      element.setState({ scrollPullMaxReached: true });
    }
    await element.setState({ scrollPullDistance });
  } else if (element.state.scrollPullDistance !== null) {
    // We've scrolled back into zero/positive territory, i.e., at or below the
    // top of the page, so the scroll pull has finished.
    await element.setState({
      scrollPullDistance: null,
      scrollPullMaxReached: false,
    });
  }
}
async function handleScrollPull(element, scrollTarget) {
  const scrollTop = scrollTarget === window ?
    document.body.scrollTop :
    scrollTarget.scrollTop;
  if (scrollTop < 0) {
    // Negative scroll top means we're probably in WebKit.
    // Start a scroll pull operation.
    let scrollPullDistance = -scrollTop;
    if (element.state.scrollPullDistance &&
      !element.state.scrollPullMaxReached &&
      scrollPullDistance < element.state.scrollPullDistance) {
      // The negative scroll events have started to head back to zero (most
      // likely because the user let go and stopped scrolling), so we've reached
      // the maximum extent of the scroll pull. From this point on, we want to
      // stop our own translation effect and let the browser smoothly snap the
      // page back to the top (zero) scroll position. If we don't do that, we'll
      // be fighting with the browser effect, and the result will not be smooth.
      element.setState({ scrollPullMaxReached: true });
    }
    await element.setState({ scrollPullDistance });
  } else if (element.state.scrollPullDistance !== null) {
    // We've scrolled back into zero/positive territory, i.e., at or below the
    // top of the page, so the scroll pull has finished.
    await element.setState({
      scrollPullDistance: null,
      scrollPullMaxReached: false,
    });
  }
}
async function handleScrollPull ( element , scrollTarget ) { const scrollTop = scrollTarget === window ? document . body . scrollTop : scrollTarget . scrollTop ; if ( scrollTop < 0 ) { // Negative scroll top means we're probably in WebKit. // Start a scroll pull operation. let scrollPullDistance = - scrollTop ; if ( element . state . scrollPullDistance && ! element . state . scrollPullMaxReached && scrollPullDistance < element . state . scrollPullDistance ) { // The negative scroll events have started to head back to zero (most // likely because the user let go and stopped scrolling), so we've reached // the maximum extent of the scroll pull. From this point on, we want to // stop our own translation effect and let the browser smoothly snap the // page back to the top (zero) scroll position. If we don't do that, we'll // be fighting with the browser effect, and the result will not be smooth. element . setState ( { scrollPullMaxReached : true } ) ; } await element . setState ( { scrollPullDistance } ) ; } else if ( element . state . scrollPullDistance !== null ) { // We've scrolled back into zero/positive territory, i.e., at or below the // top of the page, so the scroll pull has finished. await element . setState ( { scrollPullDistance : null , scrollPullMaxReached : false , } ) ; } }
If a user flicks down to quickly scroll up, and scrolls past the top of the page, the area above the page may be shown briefly. We use that opportunity to show the user the refresh header so they'll realize they can pull to refresh. We call this operation a "scroll pull". It works a little like a real touch drag, but cannot trigger a refresh.  We can only handle a scroll pull in a browser like Mobile Safari that gives us scroll events past the top of the page.
If a user flicks down to quickly scroll up and scrolls past the top of the page the area above the page may be shown briefly . We use that opportunity to show the user the refresh header so they ll realize they can pull to refresh . We call this operation a scroll pull . It works a little like a real touch drag but cannot trigger a refresh . We can only handle a scroll pull in a browser like Mobile Safari that gives us scroll events past the top of the page .