Skip to content

Commit

Permalink
Merge pull request #1497
Browse files Browse the repository at this point in the history
  • Loading branch information
jhersh committed Mar 8, 2015
2 parents d3f87ee + fdf1163 commit 418bb68
Show file tree
Hide file tree
Showing 11 changed files with 936 additions and 843 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
osx_image: xcode611
language: objective-c
before_install: gem install cocoapods xcpretty obcd slather -N
cache: cocoapods
podfile: Example/Podfile
env:
- LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8
Expand Down
2 changes: 2 additions & 0 deletions Example/JazzHandsDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,640 changes: 826 additions & 814 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions JazzHands/IFTTTAnimationFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@property (nonatomic, assign) CGRect frame;
@property (nonatomic, assign) CGFloat alpha;
@property (nonatomic, assign) CGFloat cornerRadius;
@property (nonatomic, assign) BOOL hidden;
@property (nonatomic, copy) UIColor *color;
@property (nonatomic, assign) CGFloat angle;
Expand Down
3 changes: 3 additions & 0 deletions JazzHands/IFTTTAnimationKeyFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// values into keyframe objects.
//
+ (NSArray *)keyFramesWithTimesAndAlphas:(NSInteger)pairCount,...;
+ (NSArray *)keyFramesWithTimesAndCornerRadius:(NSInteger)pairCount,...;
+ (NSArray *)keyFramesWithTimesAndFrames:(NSInteger)pairCount,...;
+ (NSArray *)keyFramesWithTimesAndHiddens:(NSInteger)pairCount,...;
+ (NSArray *)keyFramesWithTimesAndColors:(NSInteger)pairCount,...;
Expand All @@ -29,6 +30,7 @@
+ (NSArray *)keyFramesWithTimesAndConstraint:(NSInteger)pairCount,...;

+ (instancetype)keyFrameWithTime:(NSInteger)time andAlpha:(CGFloat)alpha;
+ (instancetype)keyFrameWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius;
+ (instancetype)keyFrameWithTime:(NSInteger)time andFrame:(CGRect)frame;
+ (instancetype)keyFrameWithTime:(NSInteger)time andHidden:(BOOL)hidden;
+ (instancetype)keyFrameWithTime:(NSInteger)time andColor:(UIColor*)color;
Expand All @@ -38,6 +40,7 @@
+ (instancetype)keyFrameWithTime:(NSInteger)time andConstraint:(CGFloat)constraint;

- (id)initWithTime:(NSInteger)time andAlpha:(CGFloat)alpha;
- (id)initWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius;
- (id)initWithTime:(NSInteger)time andFrame:(CGRect)frame;
- (id)initWithTime:(NSInteger)time andHidden:(BOOL)hidden;
- (id)initWithTime:(NSInteger)time andColor:(UIColor*)color;
Expand Down
81 changes: 53 additions & 28 deletions JazzHands/IFTTTAnimationKeyFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@ + (NSArray *)keyFramesWithTimesAndAlphas:(NSInteger)pairCount,...
}
}

+ (NSArray *)keyFramesWithTimesAndCornerRadius:(NSInteger)pairCount,...
{
va_list argumentList;
NSInteger time;
CGFloat cornerRadius;
if (pairCount > 0) {
NSMutableArray *keyFrames = [NSMutableArray arrayWithCapacity:(NSUInteger)pairCount];

va_start(argumentList, pairCount);

for (int i=0; i<pairCount; i++) {
time = va_arg(argumentList, NSInteger);
cornerRadius = (CGFloat)va_arg(argumentList, double); // use double to suppress a va_arg conversion warning
IFTTTAnimationKeyFrame *keyFrame = [IFTTTAnimationKeyFrame keyFrameWithTime:time
andCornerRadius:cornerRadius];
[keyFrames addObject:keyFrame];
}

va_end(argumentList);

return [NSArray arrayWithArray:keyFrames];
}
else {
return nil;
}
}

+ (NSArray *)keyFramesWithTimesAndFrames:(NSInteger)pairCount,...
{
va_list argumentList;
Expand Down Expand Up @@ -226,6 +253,13 @@ + (instancetype)keyFrameWithTime:(NSInteger)time andAlpha:(CGFloat)alpha
return keyFrame;
}

+ (instancetype)keyFrameWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius
{
IFTTTAnimationKeyFrame *keyFrame = [[self alloc] initWithTime:time
andCornerRadius:cornerRadius];
return keyFrame;
}

+ (instancetype)keyFrameWithTime:(NSInteger)time andFrame:(CGRect)frame
{
IFTTTAnimationKeyFrame *keyFrame = [[self alloc] initWithTime:time
Expand Down Expand Up @@ -279,10 +313,8 @@ + (instancetype)keyFrameWithTime:(NSInteger)time andConstraint:(CGFloat)constrai
}

- (id)initWithTime:(NSInteger)time
{
self = [super init];

if (self) {
{
if ((self = [self init])) {
self.time = time;
self.easingFunction = IFTTTEasingFunctionLinear;
}
Expand All @@ -292,20 +324,25 @@ - (id)initWithTime:(NSInteger)time

- (id)initWithTime:(NSInteger)time andAlpha:(CGFloat)alpha
{
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.alpha = alpha;
}

return self;
}

- (id)initWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius
{
if ((self = [self initWithTime:time])) {
self.cornerRadius = cornerRadius;
}

return self;
}

- (id)initWithTime:(NSInteger)time andFrame:(CGRect)frame
{
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.frame = frame;
}

Expand All @@ -314,9 +351,7 @@ - (id)initWithTime:(NSInteger)time andFrame:(CGRect)frame

- (id)initWithTime:(NSInteger)time andHidden:(BOOL)hidden
{
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.hidden = hidden;
}

Expand All @@ -325,9 +360,7 @@ - (id)initWithTime:(NSInteger)time andHidden:(BOOL)hidden

- (id)initWithTime:(NSInteger)time andColor:(UIColor*)color
{
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.color = color;
}

Expand All @@ -336,9 +369,7 @@ - (id)initWithTime:(NSInteger)time andColor:(UIColor*)color

- (id)initWithTime:(NSInteger)time andAngle:(CGFloat)angle
{
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.angle = angle;
}

Expand All @@ -347,29 +378,23 @@ - (id)initWithTime:(NSInteger)time andAngle:(CGFloat)angle

- (id)initWithTime:(NSInteger)time andTransform3D:(IFTTTTransform3D *)transform
{
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.transform = transform;
}

return self;
}

- (id)initWithTime:(NSInteger)time andScale:(CGFloat)scale {
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.scale = scale;
}

return self;
}

- (id)initWithTime:(NSInteger)time andConstraint:(CGFloat)constraint {
self = [self initWithTime:time];

if (self) {
if ((self = [self initWithTime:time])) {
self.constraintConstant = constraint;
}

Expand Down
13 changes: 13 additions & 0 deletions JazzHands/IFTTTCornerRadiusAnimation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// IFTTTCornerRadiusAnimation.h
// JazzHands
//
// Created by Nuno Gonçalves on 3/8/15.
// Copyright (c) 2015 IFTTT Inc. All rights reserved.
//

#import "IFTTTAnimation.h"

@interface IFTTTCornerRadiusAnimation : IFTTTAnimation

@end
35 changes: 35 additions & 0 deletions JazzHands/IFTTTCornerRadiusAnimation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// IFTTTCornerRadiusAnimation.m
// JazzHands
//
// Created by Nuno Gonçalves on 3/8/13.
// Copyright (c) 2015 IFTTT Inc. All rights reserved.
//

#import "IFTTTJazzHands.h"

@implementation IFTTTCornerRadiusAnimation

- (void)animate:(NSInteger)time
{
if (self.keyFrames.count <= 1) return;

IFTTTAnimationFrame *animationFrame = [self animationFrameForTime:time];
self.view.layer.cornerRadius = animationFrame.cornerRadius;
}

- (IFTTTAnimationFrame *)frameForTime:(NSInteger)time
startKeyFrame:(IFTTTAnimationKeyFrame *)startKeyFrame
endKeyFrame:(IFTTTAnimationKeyFrame *)endKeyFrame
{
IFTTTAnimationFrame *animationFrame = [IFTTTAnimationFrame new];
animationFrame.cornerRadius = [self tweenValueForStartTime:startKeyFrame.time
endTime:endKeyFrame.time
startValue:startKeyFrame.cornerRadius
endValue:endKeyFrame.cornerRadius
atTime:time];

return animationFrame;
}

@end
1 change: 1 addition & 0 deletions JazzHands/IFTTTJazzHands.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "IFTTTAnimatedScrollViewController.h"

#import "IFTTTAlphaAnimation.h"
#import "IFTTTCornerRadiusAnimation.h"
#import "IFTTTFrameAnimation.h"
#import "IFTTTHideAnimation.h"
#import "IFTTTColorAnimation.h"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Jazz Hands supports several types of animations:

+ **IFTTTFrameAnimation** moves and sizes views.
+ **IFTTTAlphaAnimation** creates fade effects.
+ **IFTTTCornerRadiusAnimation** animates the `layer.cornerRadius` of a view.
+ **IFTTTHideAnimation** hides and shows views.
+ **IFTTTAngleAnimation** for rotation effects.
+ **IFTTTTransform3DAnimation** for 3D transforms.
Expand Down

0 comments on commit 418bb68

Please sign in to comment.