views:

301

answers:

2

I have some NSViews that I'm putting in one of two layouts depending on the size of my window.

I'm adjusting the layout when the relevant superview receives the resizeSubviewsWithOldSize method.

This works, but I'd like to animate the change. So naturally I tried calling the animator proxy when I set the new frames, but the animation won't run while the user is still dragging. If I release the mouse before the animation is scheduled to be done I can see the tail end of the animation, but nothing until then. I tried making sure kCATransactionDisableActions was set to NO, but that didn't help.

Is it possible to start a new animation and actually have it run during the resize?

A: 

This really isn't an answer, but I would advise against animating anything while dragging to resize a window. The screen is already animating (from the window moving) - further animations are likely going to be visually confusing and extraneous.

CoreAnimation effects are best used to move from one known state to another - for example, when a preference window is resizing to accompany a new pane's contents, and you know both the old and new sizes, or when you are fading an object in or out (or both). Doing animation while the window is resizing is going to be visually confusing and make it harder for the user to focus on getting the size of the window where they want it to be.

Dan Udey
With due respect, these comments don't apply to my situation. I'm moving between two known states. Two simple layout options, depending on available space. The interaction works very nicely just "popping" from one to the other, but would be less jarring if it could be animated.
Christopher Ashworth
For what it's worth, NSCollectionView does this too (you can see it in action in the IconCollection sample code). They apparently wait for a "quiet period" in which you've stopped dragging.I've been trying to write a similar class, and it is definitely a pain to get the animations to run consistently and properly during the resize.
David Dunham
+2  A: 

I don't think you can do this easily because CA's animations are run via a timer and the timer won't fire during the runloop modes that are active while the user is dragging.

If you can control the runloop as the user is dragging, play around with the runloop modes. That'll make it work. I don't think you can change it on the CA side.

smeger