• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Modify view animation while running
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modify view animation while running


  • Subject: Re: Modify view animation while running
  • From: Daniel Gobera <email@hidden>
  • Date: Tue, 14 Nov 2006 11:53:41 -0800

I finally found a solution for this problem. My code had basically two problems:

1. When interrupting an animation to start a new one, I was setting the startFrame of the new one to the current frame of the view, which was the right thing to do. However, I was doing this AFTER calling stopAnimation, so the current frame of the view was no longer the frame as it looked in the middle of the animation, but the target frame (because stopAnimation changes it immediately).

2. Now, after fixing this issue, I got a "flash" of the view in the end location by one instant and then appeared again where I wanted. This happened because stopLocation moved the view to the end location and it was drawn there for one frame before the new animation started. Scott Anguish suggested to turn off window flushing while doing this, and re-enabling it after the second animation started. This worked perfectly.

Now that this issue was solved, there are still some problems I need to fix to make my animations look exactly as I want. I'm starting to suspect that nsviewanimation by itself won't be enough. Maybe even using views is not a good approach for this. The problem is that when I interrupt an animation and start a new one, to change the direction of a moving view, it starts again with 0 speed (because I'm using ease in and out), so it gives a feeling of sudden stop and start. I would like it to graciously change direction, maybe depicting a curve instead of a straight line. Again, I think I'll just wait for Core Animation.

Daniel

On Nov 13, 2006, at 3:05 PM, Daniel Gobera wrote:

Thanks for your suggestions.

Both seem reasonable and may be the only way to achieve exactly what I want. However, the complexity of the implementation may exceed the benefit here. My animations are .5 seconds long, so the chances that the target state will change in the middle are pretty low. Also, each NSViewAnimation is animating 3 views simultaneously, so it will be a pain to calculate intermediate size and position for each if I override setCurrentProgress (that's why I'm not using NSAnimation directly).

From what I saw on the WWDC keynote, Core Animation will solve most of the problems with current interface animation techniques, so I guess I'll just wait.

Daniel

On Nov 11, 2006, at 2:18 PM, Bill Cheeseman wrote:

on 2006-11-11 3:04 PM, Daniel Gobera at email@hidden wrote:

Does anybody know if it is possible to change the target frame of an
NSViewAnimation while it is running?

I've been fiddling with similar issues the last few days, but not exactly
the same one you're asking about. So far, my impression is that you can do
just about anything you want to do with NSViewAnimation, but sometimes it
requires clever and indirect approaches. I've had particular success with
NSAnimation delegate methods and with subclassing NSViewAnimation to control
drawing at each iteration.


I don't know whether you can change the endFrame midstream. If not, two
other possible approaches suggest themselves to me.


1. Subclass NSViewAnimation and override -setCurrentProgress: per the
documentation. I do this to control the transparency of a view while it's
moving, but I'm thinking you might be able to control the drawing of the
view frame despite what endFrame thinks the current view frame is.


2. Break your animations into shorter pieces, each piece taking the view
only part way toward the last user click. If there's no second user click,
just keep stringing the animations together until the view gets to its final
destination. But if there is an intervening user click, start using a new
animation with a new endFrame as soon as the current leg ends. How short you
have to make the legs to yield a smooth result will be a matter of trial and
error.


--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Modify view animation while running (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: CoreData, reset a persistent store
  • Next by Date: Re: NSPredicate behavior with different stores (CONTAINS vs. LIKE)
  • Previous by thread: Re: Modify view animation while running
  • Next by thread: how to validate toolbar with different target?
  • Index(es):
    • Date
    • Thread