angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications

Home Page:http://angular-ui.github.io/ui-scroll/demo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keeping the ui limited

Jerczu opened this issue · comments

commented

So I've noticed if I don't scroll but just keep appending via adapter the adapter seem to ignore the buffer size lets say its 50 you would expect 50 is the limit of the ui in the view but it looks like if I keep appending/prepending those elements are added to UI but none of existing ones removed. Any methods to alleviate that without reloading the whole data source?

You can replicate that in this demo by spamming the prepend button - https://rawgit.com/angular-ui/ui-scroll/master/demo/append/append.html

@Jerczu You always can eliminate items via adapter.applyUpdates method. It seems logical to do it manually since you are adding items manually...

commented

@dhilt Thanks for the advice, much appreciated I'll have a go at implementing that and see how well it works.

@dhilt do you think it makes sense to apply the same trimming process after manual updates? It should not be too difficult

@mfeingold One more remote-sync demo for applyUpdates? A good idea, I think.

commented

Yeah I tried to trim the dataset manually using the applyUpdates() and while it works pagination seem to get broken I'm ending up with a huge whitespace in between pages. I might be doing something wrong but I thought if I return [] the adapter is going to remove the item from the ui and update the pointers not sure what is happening over there.

@Jerczu I have solved your task, please look at https://rawgit.com/angular-ui/ui-scroll/master/demo/adapterSync/adapterSync.html. This also has required some changes in the ui-scroll source code. I would even say that it was uncovered use case, a bug...

There is another problem, I see. When you remove almost all available items and both of EOF and BOF are reached, then the process of items clipping/fetching can not be started -- you may append/prepend unlimited number of items and none of them will be clipped from the viewport.

commented

I have solved your task

Brilliant thank you that helps a lot!

When you remove almost all available items and both of EOF and BOF are reached, then the process of items clipping/fetching can not be started -- you may append/prepend unlimited number of items and none of them will be clipped from the viewport.

Yes that was what I was referring to essentially you can end up with a very long list of elements that can pollute the total watchers amount leading to poorly performing or in some cases I experienced unresponsive ui. This is actually fixed by scrolling those elements trim ok on scroll but if you keep appending / prepending elements they aren't removed from the viewport as you said.

@Jerczu Btw the described fix will be included in the next (v1.6.2) release and also I have opened a separate issue (#151) for the remain part of the problem, so I'm closing this one. Thanks!