razorjack/quicksand — pull request #90 by JonMcL (2012-09-24 17:39:10+00:00)
Title: Reuse collection elements instead of replacing them

I have a use case where I modify the collection elements after they have loaded. I'm using jquery_lazyload to do a smooth loading of thumbnail images of the collection. Then I am modifying the collection with a new collection loaded via AJAX. The normal operation of quicksand is to animate the elements into their new positions, fade out elements no longer needed, and then it completely REPLACES the collection in the DOM with the new incoming collection. Because of lazyload technique, the replacement elements do not have the final image in place yet and they will either fadeIn or "flash" in after a period of time.

I added a new option, retainExisting. Instead of replacing collection elements in the DOM with the new elements, the ones that will remain are left in the DOM, but resequenced. New elements are already attached to the end of the collection.

This will be useful for any changes that can't be solved by using the "enhancement" callback because they may have their own animations.

In this fork, I have this enabled by default. I can't see any drawbacks to using it all the time, but maybe others will?