Skip to content

Fix for multiple reloads in the same instance causes skipping #64

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

Merged

Conversation

observstream
Copy link

When a reload(number) is called multiple times on the ui-scroll, any call after first causes the reload to skip buffer.length pages down and load more than is necessary. What is happening is that the viewport top and bottom padding does not get reset during the reload. This causes any call after the first to be based on the height of the viewport with the padding. This is not a big issue when the items in the viewport are small (many items visible at a time) but is a huge issue when only one item is visible at a time.

Solution Reset the top and bottom padding divs before anything in the reload is set.

Example issue:
Environment
Loading 75 images with a width of 90% of the viewport, a height of almost twice the size of the viewport, and a buffer of 11. The images must have their height set before ui-scroll does anything otherwise too many calls are made since the height of the images is not known at the time the check to load more top or bottom is fired.

  1. Call reload(50) and everything works just fine.
  2. Call reload(20)
  3. After the call of reload(20) the system ends up fetching 3 times from the datasource because the height of the viewport is artificially high
  4. This results in item 29 and 30 showing on the page at the same time
  5. Also, the instant you scroll in either direction, the entire ui-scroll resets to item 1. This appears to be happening because on the 3rd data load, a -Infinity is used when determining the height of the viewport (I don't think this is all that is happening)

@observstream observstream changed the title Fix for multiple reloads in the same instance skipping Fix for multiple reloads in the same instance causes skipping Mar 11, 2016
@dhilt
Copy link
Member

dhilt commented Mar 12, 2016

@jahumes Sounds very reasonable,
to make us more involved it would be greate if you provide us with a demo of your environment setup,
jsfiddle or smth else is appropriate (for example https://jsfiddle.net/dhilt/ypdbmrt8/). This story is a bit complicated and should be double checked I guess. Thank you!

@mfeingold
Copy link
Contributor

@jahumes From the standpoint of the component stability I have no concerns so I am merging the PR, But I second @dhilt with the request for the repro. It might help to uncover some deeper issues

mfeingold added a commit that referenced this pull request Mar 14, 2016
Fix for multiple reloads in the same instance causes skipping
@mfeingold mfeingold merged commit be09ec0 into angular-ui:master Mar 14, 2016
@observstream
Copy link
Author

I have created a new JSFiddle that outlines the issue. Click on either of the buttons to reload to that index. Everything works just fine, but after you click on the other button, it reloads to the middle of the page 10 items further and scrolling in any direction immediately reloads the entire set to 1.

Broken: https://jsfiddle.net/ypdbmrt8/10/
Fixed: https://jsfiddle.net/ypdbmrt8/11/

@observstream observstream deleted the fix-multiple-reload-skipping branch March 14, 2016 16:38
@dhilt
Copy link
Member

dhilt commented Mar 16, 2016

@jahumes Great repro, thanks!

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

Successfully merging this pull request may close these issues.

3 participants