Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when a horizontal scrollbar appears and disappears #183

Open
unpollito opened this issue Jan 2, 2018 · 0 comments
Open

Infinite loop when a horizontal scrollbar appears and disappears #183

unpollito opened this issue Jan 2, 2018 · 0 comments

Comments

@unpollito
Copy link

unpollito commented Jan 2, 2018

Hello,

I have noticed an infinite loop scenario in angular-vs-repeat which causes the application to hang indefinitely. I'm using Angular 1.6.6 and angular-vs-repeat 1.1.17. The situation is as follows:

  1. I have a list of elements and a container with overflow: auto such that only N fit completely and the N+1-th element fits only partially.
  2. The first N elements fit in the container, but the N+1-th element is too wide and causes a horizontal scrollbar to appear.
  3. Since a horizontal scrollbar appears, the container's clientHeight changes, and now only the first N elements are painted.
  4. Since the first N elements fit inside the container, the horizontal scrollbar is no longer needed and it disappears, thus triggering reinitialization again.
  5. The N+1-th element appears again, causing the horizontal scrollbar to appear again, and we're back at step 2.

I have created a Plunkr where this issue can be seen in action: https://plnkr.co/edit/yn9ddqejzH23J6TL0vfP.

I believe that the following approaches could solve this issue:

  • Adding a limit to the number of recursive calls that can be done to reinitialize() from reinitOnClientHeightChange().
  • Using offsetHeight instead of clientHeight to calculate how many items can be drawn, and account for borders and padding separately.
  • Keep track of whether the container had a horizontal scrollbar in the previous call to reinitOnClientChange and, if the only reason why the clientHeight changes is that a scrollbar just appeared, refrain from invoking the reinitialize() method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant