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

Correcting start index of repeater #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MailzMMorozov
Copy link

Making startIndex less then original length

Making startIndex less then original length
@Jonathan-Law
Copy link

+1

) - $scope.excess / 2,
0
),
originalLength

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I appreciate the direction of this change, I'm not sure this is safe.

There are many circumstances - especially where using window as the scroll-parent - where the expression:

($scrollPosition - $scope.offsetBefore - scrollOffset) / $scope.elementSize

can become (positive) Infinity, but this is a deficiency in the calculation, not an indication that we've actually scrolled well past the end of the list.

In my setup, I have used:

vs-repeat
vs-autosize
vs-scroll-parent="window"

and this pretty much guarantees that $scope.elementSize is zero at all times, which throws the maths out completely.

Ultimately, I think more careful consideration of the maths involved is needed, and the motivation for this fix should be part of it.

Copy link

@dmitry-dedukhin dmitry-dedukhin Feb 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have 14 expandable/collapsable vs-repeat containers and 600 items in each. My vs-scroll-parent is a window.
When I expand e.g. 4-th container and scroll down all looks well until I scroll close to the end of the window. At this point my expanded container is not visible in viewport and while I scroll down __startIndex becomes 601, which is wrong. But sometimes __startIndex becomes 602 and this cause digestRequired set to true. After that, digest is triggered and height of the $beforeContent is constantly increasing so I can't scroll to the end at all.
I've fixed my issue by adding the following check after __startIndex calculation:

if(__startIndex > originalLength) {
	__startIndex = originalLength;
}

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.

4 participants