prevent-pull-refresh icon indicating copy to clipboard operation
prevent-pull-refresh copied to clipboard

Pull to refresh isn't disable on iOS

Open shivamsupr opened this issue 6 years ago • 7 comments

Check the codesandbox. https://codesandbox.io/s/jp8nvvzqoy

shivamsupr avatar Aug 05 '18 20:08 shivamsupr

Maybe the issue on the chrome recent versions.

nghiepdev avatar Aug 06 '18 09:08 nghiepdev

This doesn't seem to work with Chrome 69.0.3497.105 on iOS 11.3. I've also tried multiple other solutions and that had seemed to work before from the reactions of others but they do not work for me for this version.

Other solutions I've tried:

  • http://w3bits.com/prevent-chrome-pull-to-refresh-css/
  • https://stackoverflow.com/questions/50763813/disable-chromes-pull-to-refresh-on-iphone

Jonathan002 avatar Oct 05 '18 08:10 Jonathan002

we need to add { passive: false } for touch move like:

document.addEventListener('touchmove', touchmoveHandler, { passive: false });

because from some version of Chrome, event listeners are default passive true.

apptaro avatar Nov 05 '18 05:11 apptaro

@apptaro Thank for your support. It works! I just published the new patch version for the issue.

nghiepdev avatar Nov 05 '18 06:11 nghiepdev

@nghiepit It's still happening just for the initial load it doesn't happen. check this https://o1l55wryq.codesandbox.io.

To replicate: Scroll up once and then scroll down. You'll see pull-to-refresh.

shivamsupr avatar Nov 05 '18 14:11 shivamsupr

I know what's wrong. When a page is short, scrollling down (panning up) doesn't actually scroll the page, so scrolling up (panning down) will activate pull-to-refresh.

https://github.com/nghiepit/prevent-pull-refresh/blob/master/index.js#L78 here, "maybePrevent" shouldn't be set to false unless window.pageYOffset !== 0.

apptaro avatar Nov 05 '18 15:11 apptaro

@apptaro Did you mean?

const touchmoveHandler = event => {
    if (maybePrevent) {
      if (window.pageYOffset !== 0) {
        maybePrevent = false;
      }
      if (isScrollingUp(event)) {
        return event.preventDefault();
      }
    }
  };

With me. It's still happening, same issue @shivamsupr . Can you help me test and make a pull request?

Thank you in advance.

nghiepdev avatar Nov 06 '18 04:11 nghiepdev