Best animation questions in November 2011

Why are iOS animations slow the first time they are run?

11 votes

It seems to me that the first time I run an animation (animating the frame of a UIView, or the position of a CALayer, etc) it is quite choppy, and subsequent animations are smooth.

What would be causing this, and is there any way to pre-cache the animation?

Note: this question is quite similar to this one: UIImageView animations lag at first run, but UIImages are not being used in my animations.

Assuming you are using [UIImage imageNamed: @"herp.png"] the image will be cached. If the image is drawn a lot it will be unpacked into memory, else it will do a lazy load of the image and cause a stutter.

CSS3 Animate Out of :hover

10 votes

I'm setting up a simple animation that brings up a little additional information when you hover over an image. The jQuery backup part is written and works fine, though the issue I'm having trouble with is getting the CSS3 animation to go in reverse when the user hovers out.

Here's the code and example for your perusal: http://jsfiddle.net/7LxLQ/

So when you hover in it works great, but as soon as you hover out the elements just disappear. What I'd like to know is if there's a way to get them to animate backwards when the mouse hovers elsewhere. Thanks a lot!

You don't need keyframes for something as simple as this.

I made you a demo (with only -webkit vender prefixes to keep things simple).