At various places in my single page app I use composition to compose one view into another. At the same time I have noticed some animation effects when certain pages load, almost as if sections were dynamically expanding as binding, etc. took place. I am pretty sure that this has nothing to do with Durandal's transitions as I disabled that and still got the expanding "animation" effect.
This morning I created a new view, copied some existing HTML from another view into it and replaced this HTML in the parent view with the new composed child view. In other words, the parent view went from this:
<div data-bind="visible: contactPerson, with: contactPerson">
<span data-bind="text: firstName"></span><br />
<span data-bind="text: lastName"></span><br />
</div>
to this:
<div data-bind="compose: { model: 'viewmodels/contact-view', activationData: { contactPerson: contactPerson } }"></div>
Upon testing this change I immediately noticed that the original version had no expanding animation effect while the composed version does. After playing around with the Durandal transitions I came to the conclusion that this is quite possibly not related to that but more probably due to delayed insertion of the child view HTML.
The new child viewmodel is extremely simple so I see no issues there, unless it has to do with the fact that it is not a singleton, which it cannot be in this case.
define(['services/dataservice',
'services/logger'],
function (dataservice, logger) {
return function () {
var self = this;
var contactPerson = ko.observable();
var activate = function (activationData) {
contactPerson(ko.unwrap(activationData.contactPerson));
};
// Make sure required internally defined functions and properties are exported.
self.activate = activate;
self.contactPerson = contactPerson;
};
});
Can anybody help me figure out how to get rid of the transition effect? I can post a video of the before and after if somebody wants to take a look at it.