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

CollectionView: Reorder DOM elements after sorting #1979

Closed
ptbrowne opened this issue Oct 8, 2014 · 5 comments
Closed

CollectionView: Reorder DOM elements after sorting #1979

ptbrowne opened this issue Oct 8, 2014 · 5 comments

Comments

@ptbrowne
Copy link
Contributor

ptbrowne commented Oct 8, 2014

Hi,

I have just set up a proof of concept to increase the performance of re-rendering large CollectionView after sorting. The default behavior is to re-render but this seems very inefficient since the templates are already rendered and inserted in the DOM. My approach is simple but it seems to deliver good results: I basically detach all children' $el and reinsert them in the order of the collection.

I have had more than 10x perf increase and it should be more if the template is complicated. If you click on profile in the jsBin, you will be able to see that in Chrome Profiler.

I wonder what do you think, if this technique has any flaws (beside the fact that if the template or itemViewOptions use the index, it will not work as expected). I am open to critics.

Here is the jsBin: http://jsbin.com/vecobada/13/edit

Thanks for Marionette !

@jamesplease
Copy link
Member

👍

Nice work, @ptbrowne! Would you be interested in making a PR? I can see this working in situations where we can be 100% sure that the other models in the collection are unchanged.

Also, because this changes the behavior in a breaking, though more efficient, way, we'll have to throw this into a major release. v4 is all about views, but this is a friendly enough change that I can see it landing in v3.

@ptbrowne
Copy link
Contributor Author

ptbrowne commented Oct 8, 2014

Cool. Sure, I will do the PR :)

@samccone
Copy link
Member

samccone commented Feb 4, 2015

@ptbrowne any word on the PR?

@ptbrowne
Copy link
Contributor Author

ptbrowne commented Feb 4, 2015

I am pretty busy at the moment but I will try to do that this week. Sorry
for not sending updates...

On Wed Feb 04 2015 at 2:58:36 AM Sam Saccone notifications@github.com
wrote:

@ptbrowne https://github.com/ptbrowne any word on the PR?


Reply to this email directly or view it on GitHub
#1979 (comment)
.

@ahumphreys87
Copy link
Member

fixed in 2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants