I started app from Todos example from Meteor Guide aplication, so there are similarity.
I have Elements Collection with this schema, here is part that i update
"transform": { // Object Element position
"x": "12", // String translateX
"y": "34", // String translateY
"rot": "0" // String rotateZ
},
This goes to component template (with sub-components) to show all (SVG) elements (source):
{{#each element in elements}}
{{> Elements_item (elementArgs element)}}
{{else}}
Then i have rotateElement method in methods.js to do:
Elements.update(eid, {
$set: { "transform.rot": phi },
});
Now, my problem is, that element (inside #each) does rotate (it is visable) and then dissapear when i call rotateElement method.
If than i refresh browser (F5) it shows correctly (rotated)
Same thing happen when i call method connectElementToNet (source)
Elements.update(
{ cid: cid, name: name, "pins.id": pin },
{ $set: { "pins.$.net": net } }
);
Is this problem with Tracker, what is missing?
Do i need to “tell” publication is changed?
Ok, i find that updated “element” from argument used in #each (see first post)
does not pass to return object:
elementArgs(element) {
console.log( "elementArgs for "+ element.name + " ("+ element._id +"); newRot is: "+ element.transform.rot );
return {
element: element,
}
},
Template.Elements_item.onCreated(function elementsItemOnCreated() {
this.autorun(() => {
new SimpleSchema({
element: { type: Elements._helpers },
}).validate(Template.currentData());
console.log( "elementsItemOnCreated for "+ this.data.element.name + " ("+ this.data.element._id +"); newRot is: "+ this.data.element.transform.rot );
});
});
elementsItemOnCreated returnd OLD element.transform.rot
No, sorry, updated element come to Elements_item
template correctly, BUT
Template.Elements_item.onCreated(function elementsItemOnCreated() {
this.autorun(() => {
new SimpleSchema({
element: { type: Elements._helpers },
}).validate(Template.currentData());
console.log( Template.currentData() );
console.log( this.data );
});
});
This returns different results on change. Template.currentData()
is “up-to-date”, while this.data
is “outdated”.
If i do this.data = Template.currentData();
it doesn’t solve my problem.
I find it!
meteor-momentum some how works bad on svg shanges. I’ll try to replicate this in new app to expose this, but maybe later this yer.
So, i removed {{#momentum plugin="fade"}}
line and it works now.