Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Demo/GLDTween.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
117AB29E1B8BECDB00CD92C7 /* GLDTweenChain.m in Sources */ = {isa = PBXBuildFile; fileRef = 117AB29B1B8BECDB00CD92C7 /* GLDTweenChain.m */; };
117AB29F1B8BECDB00CD92C7 /* GLDTweenChainAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 117AB29D1B8BECDB00CD92C7 /* GLDTweenChainAction.m */; };
117AB2A21B8BED0800CD92C7 /* GLDTween+Chain.m in Sources */ = {isa = PBXBuildFile; fileRef = 117AB2A11B8BED0800CD92C7 /* GLDTween+Chain.m */; };
3D5366F519DC31D10017C6B8 /* GLDTweenSelector.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D5366F419DC31D10017C6B8 /* GLDTweenSelector.m */; };
3D5366F819DC337F0017C6B8 /* GLDTweenBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D5366F719DC337F0017C6B8 /* GLDTweenBlock.m */; };
3D53670C19DE16270017C6B8 /* TouchDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D53670B19DE16270017C6B8 /* TouchDemoViewController.m */; };
Expand Down Expand Up @@ -34,6 +37,12 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
117AB29A1B8BECDB00CD92C7 /* GLDTweenChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GLDTweenChain.h; path = ../../GLDTween/GLDTweenChain.h; sourceTree = "<group>"; };
117AB29B1B8BECDB00CD92C7 /* GLDTweenChain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GLDTweenChain.m; path = ../../GLDTween/GLDTweenChain.m; sourceTree = "<group>"; };
117AB29C1B8BECDB00CD92C7 /* GLDTweenChainAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GLDTweenChainAction.h; path = ../../GLDTween/GLDTweenChainAction.h; sourceTree = "<group>"; };
117AB29D1B8BECDB00CD92C7 /* GLDTweenChainAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GLDTweenChainAction.m; path = ../../GLDTween/GLDTweenChainAction.m; sourceTree = "<group>"; };
117AB2A01B8BED0800CD92C7 /* GLDTween+Chain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GLDTween+Chain.h"; path = "../../GLDTween/GLDTween+Chain.h"; sourceTree = "<group>"; };
117AB2A11B8BED0800CD92C7 /* GLDTween+Chain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "GLDTween+Chain.m"; path = "../../GLDTween/GLDTween+Chain.m"; sourceTree = "<group>"; };
3D5366F319DC31D10017C6B8 /* GLDTweenSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = GLDTweenSelector.h; path = ../../GLDTween/GLDTweenSelector.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
3D5366F419DC31D10017C6B8 /* GLDTweenSelector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = GLDTweenSelector.m; path = ../../GLDTween/GLDTweenSelector.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
3D5366F619DC337F0017C6B8 /* GLDTweenBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = GLDTweenBlock.h; path = ../../GLDTween/GLDTweenBlock.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
Expand Down Expand Up @@ -81,6 +90,19 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
117AB2A31B8BEF8400CD92C7 /* chain */ = {
isa = PBXGroup;
children = (
117AB2A01B8BED0800CD92C7 /* GLDTween+Chain.h */,
117AB2A11B8BED0800CD92C7 /* GLDTween+Chain.m */,
117AB29A1B8BECDB00CD92C7 /* GLDTweenChain.h */,
117AB29B1B8BECDB00CD92C7 /* GLDTweenChain.m */,
117AB29C1B8BECDB00CD92C7 /* GLDTweenChainAction.h */,
117AB29D1B8BECDB00CD92C7 /* GLDTweenChainAction.m */,
);
name = chain;
sourceTree = "<group>";
};
3D53670219DD57610017C6B8 /* Sample */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -164,6 +186,7 @@
3DAE9D4419DB9DA0003692A1 /* GLDTween.m */,
3DAE9D4A19DBA6D4003692A1 /* core */,
3DAE9D4919DBA11D003692A1 /* plugins */,
117AB2A31B8BEF8400CD92C7 /* chain */,
);
name = GLDTween;
sourceTree = "<group>";
Expand Down Expand Up @@ -301,9 +324,12 @@
3DAE9D1F19DB9D30003692A1 /* main.m in Sources */,
3DAE9D4D19DBB3C9003692A1 /* GLDTweenProperty.m in Sources */,
3DAE9D4519DB9DA0003692A1 /* GLDTween.m in Sources */,
117AB29E1B8BECDB00CD92C7 /* GLDTweenChain.m in Sources */,
3D53675519DEE4550017C6B8 /* GLDTweenPropertyPlugin.m in Sources */,
117AB2A21B8BED0800CD92C7 /* GLDTween+Chain.m in Sources */,
3D5366F819DC337F0017C6B8 /* GLDTweenBlock.m in Sources */,
3DAE9D5319DBB5EE003692A1 /* GLDTweenTween.m in Sources */,
117AB29F1B8BECDB00CD92C7 /* GLDTweenChainAction.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
38 changes: 37 additions & 1 deletion Demo/GLDTween/TouchDemo/TouchDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "TouchDemoViewController.h"
#import "GLDTween.h"

#import "GLDTween+Chain.h"

@implementation TouchDemoViewController

Expand All @@ -19,6 +19,9 @@ - (void)viewDidLoad {
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(screenDidToucth:)];
[self.view addGestureRecognizer:gesture];

UILongPressGestureRecognizer *long_gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(screenDidLongPress:)];
[self.view addGestureRecognizer:long_gesture];

self.box.center = CGPointMake(0, 0);
CGAffineTransform t = CGAffineTransformMakeTranslation(self.view.frame.size.width*0.5, self.view.frame.size.height*0.5);
self.box.transform = t;
Expand Down Expand Up @@ -50,6 +53,39 @@ - (void)screenDidToucth:(UITapGestureRecognizer*)gesture {
@"transform": [NSValue valueWithCGAffineTransform:t]}];
}

- (void)screenDidLongPress:(UILongPressGestureRecognizer*)gesture {
if(gesture.state != UIGestureRecognizerStateBegan){
return;
}
CGPoint pt = [gesture locationInView:gesture.view];
float rotation = arc4random() % 360;
float scale = arc4random() % 100 / 50.0 + 0.5;

CGAffineTransform t1 = CGAffineTransformIdentity;
t1 = CGAffineTransformTranslate(t1, pt.x/2, pt.y/2);
t1 = CGAffineTransformRotate(t1, rotation/2 * M_PI / 180.0);
t1 = CGAffineTransformScale(t1, scale/2, scale/2);

CGAffineTransform t2 = CGAffineTransformIdentity;
t2 = CGAffineTransformTranslate(t2, pt.x, pt.y);
t2 = CGAffineTransformRotate(t2, rotation * M_PI / 180.0);
t2 = CGAffineTransformScale(t2, scale, scale);

NSString* transition = [GLDTween easingNames][[self.picker selectedRowInComponent:0]];

GLDTween.get(self.box)
.remove()
.to(@{@"duration": @0.4,
@"easing": transition,
@"transform": [NSValue valueWithCGAffineTransform:t1]})
.wait(0.2)
.to(@{@"duration": @0.4,
@"easing": transition,
@"transform": [NSValue valueWithCGAffineTransform:t2]})
.call(^(){
NSLog(@"completed!");
});
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
}
Expand Down
16 changes: 16 additions & 0 deletions GLDTween/GLDTween+Chain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// GLDTween+Chain.h
// GLDTween
//
// Created by Ryo Miyake on 2015/08/25.
// Copyright (c) 2014 THE GUILD. All rights reserved.
//

#import "GLDTween.h"
#import "GLDTweenChain.h"

@interface GLDTween (Chain)

+ (GLDTweenChain *(^)(NSObject *target))get;

@end
20 changes: 20 additions & 0 deletions GLDTween/GLDTween+Chain.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// GLDTween+Chain.m
// GLDTween
//
// Created by Ryo Miyake on 2015/08/25.
// Copyright (c) 2014 THE GUILD. All rights reserved.
//

#import "GLDTween+Chain.h"

@implementation GLDTween (Chain)

+ (GLDTweenChain *(^)(NSObject *target))get
{
return ^GLDTweenChain *(NSObject *target){
return [GLDTweenChain get:target];
};
}

@end
52 changes: 52 additions & 0 deletions GLDTween/GLDTweenChain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// GLDTweenChain.h
// GLDTween
//
// Created by Ryo Miyake on 2015/08/25.
// Copyright (c) 2014 THE GUILD. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface GLDTweenChain : NSObject

+ (GLDTweenChain *)get:(NSObject *)target;

- (GLDTweenChain *)set:(NSDictionary *)params;
- (GLDTweenChain *)to:(NSDictionary *)params;
- (GLDTweenChain *)wait:(NSTimeInterval)delay;
- (GLDTweenChain *)call:(void(^)(void))block;

+ (void)remove:(NSObject *)target;
+ (void)remove:(NSObject *)target props:(NSArray *)props;
+ (void)removeAllTweens;

+ (void)pause:(NSObject *)target;
+ (void)pauseAllTweens;

+ (void)resume:(NSObject *)target;
+ (void)resumeAllTweens;

@end

@interface GLDTweenChain(Blocks)

+ (GLDTweenChain *(^)(NSObject *target))get;

- (GLDTweenChain *(^)(NSDictionary *params))set;
- (GLDTweenChain *(^)(NSDictionary *params))to;
- (GLDTweenChain *(^)(NSTimeInterval delay))wait;
- (GLDTweenChain *(^)(void(^block)(void)))call;
- (GLDTweenChain *(^)())remove;

+ (void(^)(NSObject *target))remove;
+ (void(^)(NSObject *target, NSArray *props))removeProps;
+ (void(^)(void))removeAll;

+ (void(^)(NSObject *target))pause;
+ (void(^)(void))pauseAll;

+ (void(^)(NSObject *target))resume;
+ (void(^)(void))resumeAll;

@end
Loading