question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll up call refresh handler every time in multiple.html demo using 0.1.16

See original GitHub issue

Bug report

In our mobile app, after upgrading from 0.1.14 to 0.1.16, the scrollbar will trigger the onRefresh handler every time users touch and drag up even though the view is not at the very top.

I believe the code here makes trouble, the this.mainElement.scrollTop always return 0 each time scroll to be dragged up. However, using the old way, it works fine.

shouldPullToRefresh: function shouldPullToRefresh() {
      return typeof this.mainElement === 'string' ? !document.querySelector(this.mainElement).scrollTop : this.mainElement && !this.mainElement.scrollTop;
      // return !window.scrollY
    },

Current behavior: Calling refresh handler every time when scrolling up the page. Expected behavior: Not calling refresh handler when each time scroll up.

JSFiddle URL for the demo with bug: This bug can be reproduced by tweaking the demo which is multiple.html, looks like the demo still using the old version, by replacing the pulltorefresh.js with the latest 0.1.16, the issue can be observed https://jsfiddle.net/bqc3jnds/ Browsers affected: Chrome dev tool in mobile mode and real devices

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
crux153commented, Apr 5, 2019

I would also like this issue to get addressed. Currently, I’m providing previous default value manually.

pullToRefresh.init({
    shouldPullToRefresh: () => !window.scrollY
});
0reactions
pateketruekecommented, May 8, 2019

Gotcha, definitely this will depend on how you’re building your layout, the default behaviour will not satisfy all needs as layouts can be built in many different ways.

We can go back to the previous default for shouldPullToRefresh but that will also break other’s users setups and such.

The best solution so far is providing a callback that fits to your layout logic.

So much thanks for your feedback!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scroll Events and Intersection Observer - Beginner JavaScript
In this video we will learn about scroll events. A scroll event is when someone goes ahead and scrolls on the page or...
Read more >
Debouncing and Throttling Explained Through Examples
Debounce and throttle are two similar (but different!) techniques to control how many times we allow a function to be executed over time....
Read more >
Intersection Observer API - MDN Web Docs
getBoundingClientRect() to build up the needed information for every element affected. Since all this code runs on the main thread, even one of...
Read more >
Scroll event firing too many times. I only want it to fire a ...
Now, the problem is that every time I scroll, this event fires multiple times per scroll. I would like fire at most every...
Read more >
4 Ways to Listen to Page Scrolling for Dynamic UI in Angular ft ...
Even easier, you can window scroll from any HTML element in the DOM, using the window:scroll event emitter. With this method, you just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found