Let's say, I just have a common Knockoutjs layout/approach:
function User(data) {
this.name = ko.observable(data.name);
}
function UsersViewModel() {
var self = this;
self.users = ko.observableArray([]);
}
var viewModel = new UsersViewModel();
service.initialize(viewModel);
ko.applyBindings(viewModel);
and HTML:
<ul data-bind="foreach: users">
<li>
<span data-bind="text:name"></span>
</li>
</ul>
What I want is to apply some nice animation on the data changes in Knockoutjs: for existing DOM elements to disappear smoothly (which would take some time while the animation of disappearing finishes), and right after that (or even right on starting of disappearing) to start animation on new elements appearing. (In this very example -- for "li" elements to disappear separatly with every element separate animation (some delay between every element) (but that's not so important)).
(I consider here just will be a full replacement of elements (let's say not to be bothered much if new data contains items with the same id... that's complicated, I understand that)).
As I understand, that might be pretty tough, and I should consider to change/extend Knockoutjs sources (right?) to deal with "start-disappearing-animation", "disappearing-animation-finished", "start-appearing-animation".
But is there at least any way to prevent knockout to delete existent DOM elements (for me to handle that manually)... some way to "detach" them from container.
Or, if nothing else above possible, then just to have "on before data changing" event?
Thank you!