Re: CA: How to wait for an animation to finish?
Re: CA: How to wait for an animation to finish?
- Subject: Re: CA: How to wait for an animation to finish?
- From: Jens Alfke <email@hidden>
- Date: Mon, 17 Mar 2008 09:25:55 -0700
On 16 Mar '08, at 12:07 PM, John Harper wrote:
Implicit animations are useful in many scenarios, but due to the
simplicity of the API they don't cover everything. If there are
things you'd like to see them extended to support please file bugs.
Thanks for your detailed answers, John.
The main problem I run into with implicit animations is that I can't
make atomic changes to the layer hierarchy and positions.
Specifically, in GeekGameBoard I often need to change a layer's
superlayer without altering its onscreen position. (On a mouse-down on
a game piece, it needs to be removed from the square that contains it
and added to the root layer so it can be dragged all around the
board.) The basic calls to do this* are:
[piece removeFromSuperlayer];
piece.position = newPositionRelativeToRootLayer;
[rootLayer addSublayer: piece];
Unfortunately this has the visual effect of making the piece shoot
offscreen and then back, because the position change and the
superlayer change don't happen simultaneously.
The way around that is to wrap a CATransaction around the whole thing
and disable animations in it.
But if there's any animation involving that layer already in progress,
the supposedly-non-animated layer/position change seem to screw it up,
and the layer ends up jumping to the wrong place.
So what I need is a way to say "block until all animations have
finished" at the start of my ChangeSuperlayer function. Or "queue
these changes after all current animations finish". That's what I
hoped +[CATransaction flush] would do, but doesn't.
—Jens
* http://mooseyard.com/hg/hgwebdir.cgi/GeekGameBoard/file/af9b2b929b03/Source/QuartzUtils.m
(see ChangeSuperlayer( ) function.)
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden