Re: Layout-triggered animation
Re: Layout-triggered animation
- Subject: Re: Layout-triggered animation
- From: Jakob Egger <email@hidden>
- Date: Wed, 23 Apr 2014 09:39:34 +0200
> New questions:
> 1. Is there any point in using addConstraint/removeConstraint in the NSAnimationContext grouping? Seems like it can go before beginGrouping.
The important thing is that the frames are set inside the grouping. Updating constraints should not cause any frames to be set, only the layoutIfNeeded method should perform layout.
> 2. As you can see in the code, I check to see if the implicit animation setting is there at runtime (added in 10.8). AFAICT there is no simple way to do the animation in 10.7 when the autolayout was added. Apple had an oversight in 10.7 and fixed it in 10.8?
Hm. NSLayoutConstraint conforms to NSAnimatablePropertyContainer, so you could perform an animation by animating the constant, eg. [[collapseConstraint animator] setConstant: 20]. However I don't know for sure if this works on 10.7, it doesn't say in the docs.
> 3. The jitter problem. It's even more severe when the animation duration is shorter. I'm using 0.6 as the production duration.
> 4. (for good measure) Also, watch the focus ring while these animations are happening. I don't know if this is a Cocoa issue, or another symptom of my problematic code. The NSButton has the focus, but that view's frame is definitely not changing as a result of layout, as you can see.
I believe that the reason for the jitter is that frames are set multiple times, but I doubt there is anything you can do about it. You could set a breakpoint on setFrame: to try to debug, but I'm not sure that's worthwhile.
A different way to approach your problem would be to use a (view-based) NSTableView or an NSOutlineView. Animations in table views are much easier to get right in my experience.
Best wishes,
Jakob
_______________________________________________
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