Ticket #3477 (closed defect: fixed)

Opened 18 months ago

Last modified 14 months ago

onEnd fires multiple times for combined animations

Reported by: peller Owned by: alex
Priority: high Milestone: 1.0
Component: fx Version: 0.9
Severity: normal Keywords:
Cc: peller

Description

This is confusing, at best. I've got no way, as the caller, to determine when the combined animation is finished without keeping a counter or some other sort of kludge. Even the event doesn't seem to pass in any args.

Also, the chain and combine methods are destructive. The original animation is altered (is that good or bad?) and it's not clear if the events are symmetrically bound.

Perhaps we need to create a new animation object and use it to tie the events together,

Change History

Changed 17 months ago by tk

Would this work? (cant test this at work easily)

dojo.fx.combine = function(/*dojo._Animation[]*/ animations){
	// summary: Combine a list of _Animations to run in parallel
	var sortDuration = function(a,b){
		return b.duration - a.duration;
	}
	//sort animations from longest duration to shortest
	animations.sort(sortDuration);
	var first = animations.shift(); //now the longest duration animation
	dojo.forEach(animations, function(current){
		//since longest animation is out of the array, null out all onEnds
		current.onEnd = null;
		dojo.forEach([
//FIXME: onEnd gets fired multiple times for each animation, not once for the combined animation
//	should we return to a "container" with its own unique events?
//FIXME: should we add "onEnd" here... and connect all the onEnd events to first.onEnd
//	allowing each event to still have its own onEnd function, and just "combine" them by connecting to first.onEnd?
			"play", "pause", "stop"
		], function(event){
			if(current[event]){
				dojo.connect(first, event, current, event);
			}
		}, this);
	});
	return first; // dojo._Animation
};

Changed 16 months ago by alex

  • status changed from new to assigned
  • owner changed from BryanForbes to alex

Changed 16 months ago by alex

  • milestone changed from 0.9 to 1.0

Changed 14 months ago by peller

  • component changed from lfx to fx

Changed 14 months ago by alex

  • status changed from assigned to closed
  • resolution set to fixed

(In [11062]) ensure that combinations return a wrapper animation. Also, move all animations to be keyed on a single timing loop for smoother animations when mutliple animations are joined (as in dojo.fx.combine()). Fixes #3477

Note: See TracTickets for help on using tickets.