I want to give an object an attribute once a transition is finished. I'm simply updating an images position as follows:
tmp.transition().duration(1000)
.attr("transform", function(d) {return 'translate(' +
coordinates[d].x +',' +
coordinates[d].y + ')'})
Once it finishes, I want to give the object tmp an attribute "moved" with the value "no". I tried:
tmp.transition().duration(1000)
.attr("transform", function(d) {return 'translate(' +
coordinates[d].x +',' +
coordinates[d].y + ')'}).end('moved', 'no')
But without success. Any tips? Thanks,
According to the documentation, you can use .each:
tmp.transition().duration(1000)
.attr("transform", function(d) {return 'translate(' +
coordinates[d].x +',' +
coordinates[d].y + ')'}
).each('end', function() {
d3.select(this).attr('moved', 'no');
// or maybe also this.setAttribute('moved', 'no');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With