Opened 15 years ago

Closed 15 years ago

#3477 closed defect (fixed)

onEnd fires multiple times for combined animations

Reported by: Adam Peller Owned by: alex
Priority: high Milestone: 1.0
Component: fx Version: 0.9
Keywords: Cc: Adam Peller
Blocked By: Blocking:


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 (5)

comment:1 Changed 15 years 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
	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;
//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){
				dojo.connect(first, event, current, event);
		}, this);
	return first; // dojo._Animation

comment:2 Changed 15 years ago by alex

Owner: changed from Bryan Forbes to alex
Status: newassigned

comment:3 Changed 15 years ago by alex

Milestone: 0.91.0

comment:4 Changed 15 years ago by Adam Peller

Component: lfxfx

comment:5 Changed 15 years ago by alex

Resolution: fixed
Status: assignedclosed

(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.