Browse files

cleanup

  • Loading branch information...
1 parent b2a6308 commit e6dda042977c252aa2a59b4ef261b6d7398d2611 @khanlou committed May 11, 2013
Showing with 26 additions and 28 deletions.
  1. +12 −3 README.md
  2. +14 −25 SKBounceAnimation/SKBounceAnimation.m
View
15 README.md
@@ -32,7 +32,16 @@ A is the difference between start and end values, B is the end value, α is dete
`shouldOvershoot` is a property that you can change. It defaults to `YES`; if you set it to `NO`, the animation will bounce as if it were hitting a wall, instead of overshooting the target value and bouncing back. It looks a lot like the Anvil effect in Keynote.
-`shake` is a property that controls the oscilliation function. Setting it to `YES` lets you shake the element instead of moving it. To use it, set the `fromValue` to the maximum amount you want it to go to and `toValue` to its current location. It uses a sine wave for the oscillation intead of cosine, since it starts at 0 (i.e., the current location.)
+`shake` is a property that controls the oscillation function. Setting it to `YES` lets you shake the element instead of moving it. To use it, set the `fromValue` to the maximum amount you want it to go to and `toValue` to its current location. It uses a sine wave for the oscillation instead of cosine, since it starts at 0 (i.e., the current location.)
+
+`stiffness` is a property that determines how stiff the "spring" component should be. Acceptable values are
+
+* `SKBounceAnimationStiffnessLight`
+* `SKBounceAnimationStiffnessMedium`
+* `SKBounceAnimationStiffnessHeavy`
+
+The default is `SKBounceAnimationStiffnessMedium`.
+
## Demo app
@@ -46,6 +55,6 @@ The demo app contains demos for several different animations that are supported
* Scale & Rotate: Using multiple CATransform3Ds on top of each other, we can do super weird effects like scale and rotating. They look really cool.
* Rect: The last demo creates two `SKBounceAnimations` with two different `keyPath`s (`position` and `bounds`) but attaches them to the same layer. The effect looks like a `frame` animation.
-## Future work
+## Other notes
-`SKBounceAnimation` doesn’t support the `byValue` property yet.
+`SKBounceAnimation` doesn’t support the `byValue` property.
View
39 SKBounceAnimation/SKBounceAnimation.m
@@ -90,39 +90,40 @@ - (void) setFromValue:(id)newFromValue {
[self createValueArray];
}
-- (void) setByValue:(id)newByValue {
- [super setValue:newByValue forKey:@"byValueKey"];
- //don't know if this is to spec
- self.toValue = [NSNumber numberWithFloat:[self.fromValue floatValue] + [self.byValue floatValue]];
- [self createValueArray];
+- (id) fromValue {
+ return [super valueForKey:@"fromValueKey"];
}
- (void) setToValue:(id)newToValue {
[super setValue:newToValue forKey:@"toValueKey"];
[self createValueArray];
}
+- (id) toValue {
+ return [super valueForKey:@"toValueKey"];
+}
+
- (void) setDuration:(CFTimeInterval)newDuration {
[super setDuration:newDuration];
[self createValueArray];
}
-- (void) setStiffness:(SKBounceAnimationStiffness)stiffness {
- [super setValue:@(stiffness) forKey:@"stifnessKey"];
+- (void) setNumberOfBounces:(NSUInteger)newNumberOfBounces {
+ [super setValue:[NSNumber numberWithUnsignedInt:newNumberOfBounces] forKey:@"numberOfBouncesKey"];
[self createValueArray];
}
-- (SKBounceAnimationStiffness) stiffness {
- return [[super valueForKey:@"stifnessKey"] integerValue];
+- (NSUInteger) numberOfBounces {
+ return [[super valueForKey:@"numberOfBouncesKey"] unsignedIntValue];
}
-- (void) setNumberOfBounces:(NSUInteger)newNumberOfBounces {
- [super setValue:[NSNumber numberWithUnsignedInt:newNumberOfBounces] forKey:@"numBounces"];
+- (void) setStiffness:(SKBounceAnimationStiffness)stiffness {
+ [super setValue:@(stiffness) forKey:@"stifnessKey"];
[self createValueArray];
}
-- (NSUInteger) numberOfBounces {
- return [[super valueForKey:@"numBounces"] unsignedIntValue];
+- (SKBounceAnimationStiffness) stiffness {
+ return [[super valueForKey:@"stifnessKey"] integerValue];
}
- (void) setShouldOvershoot:(BOOL)newShouldOvershoot {
@@ -143,18 +144,6 @@ - (BOOL) shake {
return [[super valueForKey:@"shakeKey"] boolValue];
}
-- (id) fromValue {
- return [super valueForKey:@"fromValueKey"];
-}
-
-- (id) byValue {
- return [super valueForKey:@"byValueKey"];
-}
-
-- (id) toValue {
- return [super valueForKey:@"toValueKey"];
-}
-
- (void) createValueArray {
if (self.fromValue && self.toValue && self.duration) {
if ([self.fromValue isKindOfClass:[NSNumber class]] && [self.toValue isKindOfClass:[NSNumber class]]) {

0 comments on commit e6dda04

Please sign in to comment.