Closed zacronos closed 6 years ago
@zacronos I think, I've got the solution, please try branch code. It also includes the solution for "blank" issue (https://github.com/angular-ui/ui-scroll/issues/189), so setTimeout on start is no more needed.
I've updated the plunker. It seems the first case is fixed, but setting dataSource.minIndex
and dataSource.maxIndex
after calling adapter.reload()
still has some problems.
Also, if I comment out the setTimeout, I still see the blank issue.
@zacronos I did some update covering that case (the test), please try latest branch code.
Regarding blank issue, I see that Plunker loads resources for too long. I gave 500ms on initialization and styles applying, but in that case it isn't enough. I would reduce it down to 250ms, which will make the success for Plunker less probable, so one of suggested workarounds should be applied...
Plunker updated again. The 2nd case now works as well, except if I am scrolled to within the 1st 50 items or the last 50 items when I hit the reload button -- in that case, the scroll position after reload does not match the index value passed to adapter.reload()
. (The 1st case does not have this problem.)
@zacronos I made a fix that covers this use case. Unfortunately, I was not able to write appropriate test due to datasource.get async nature, which is not async in the test environment, so the new items processing occurs before min/maxIndex set. Please try the latest dist again... and thanks for participation!
That did it! Everything seems correct to me.
Closing due to v1.7.0-rc.6 has been released.
Here is a plunker for this issue. When you click the Do Reload button, the min and max items available from the data source are changed, and
dataSource.minIndex
anddataSource.maxIndex
are changed accordingly, and thenadapter.reload()
is called, passing in the index of the top visible element (to attempt to keep the scroll in visually the same location).As-is, the scroll position is kept close to the same visible position as intended, however the padding to keep the scrollbar at proper total height seems to get wiped and isn't updated to the new
dataSource.minIndex
/dataSource.maxIndex
values. Alternatively, I've tried settingdataSource.minIndex
anddataSource.maxIndex
after callingadapter.reload()
instead of before; in this case the scrollbar height is set properly, but the scroll position is lost and it winds up at the first available item instead of the one passed toadapter.reload()
.