Skip to content

Double the RBBSpringAnimation "sampling rate" for smoother animations. #21

@orj

Description

@orj

While using RBBSpringAnimation I noticed that movement was quite jerky in the initial phases of the spring animation.

To combat this I increased the "sampling rate" specified in RBBAnimation's values method from 60 to 120. Eg:

- (NSArray *)values {
    RBBAnimationBlock block = [self.animationBlock copy];

    CFTimeInterval duration = self.duration;

    return [RBBBlockBasedArray arrayWithCount:(NSUInteger)(duration * 120) block:^id(NSUInteger idx) {
        return block(idx / 120.0f, (CGFloat)duration);
    }];
}

The results seem to be smoother animations.

I'm not a math/signal processing whiz but I think this is an example of the Nyquist rate.

Perhaps this could be made a property on RBBSpringAnimation. As in some situations I think 60 would be fine but others a higher value is going to produce smoother results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions