I have a requirement where one part of code builds up a stack of :
$scope.values = items;
Another part of code watches this collection :
scope.$watchCollection('values', function(values) {
if(Array.isArray(values)) {
//only if it's an array, draw and watch all its items for changes
draw(values);
for(var key in values) {
if(values.hasOwnProperty(key)) {
scope.$watch("values['" + key + "']", function(val, oldVal) {
updateValue(val.id);
}, true); }
}
}
});
The updateValue function takes care of the animation :
var updateValue = function(id) {
//when an item changes, trigger the change animation
var sectElement = svg.select(".arc-section-" + id);
//go to highlighted mode
sectElement.transition()
.duration(changeValueTransitionSpeed)
.call(drawSectionHighlighted);
//after highlighted mode transition is done, go back to normal mode
sectElement
.transition()
.delay(changeValueTransitionSpeed)
.duration(changeValueTransitionSpeed)
.call(drawSection);
}
As soon as the value collection gets filled the updateValue will execute and the animation would start. At the moment the animation starts every 3 seconds when a new event arrives. I want to control the time of animation which could be decided dynamically based on a parameter.
P.S I have already tried setTimeout() and setInterval().