Giter Site home page Giter Site logo

jiexishede / mmtweenanimation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adad184/mmtweenanimation

0.0 1.0 0.0 712 KB

A extension of POP(from facebook) custom animation. Inspired by tweaner(https://code.google.com/p/tweaner), MMTweanerAnimation provide 10 types of custom animation while using POP.

License: MIT License

Objective-C 87.51% Ruby 12.49%

mmtweenanimation's Introduction

MMTweenAnimation

CocoaPods CocoaPods CocoaPods

demo

MMTweenAnimation is a extension of POP(from facebook) custom animation. Inspired by tweaner(https://code.google.com/p/tweaner), MMTweanerAnimation provide 10 types of custom animation while using POP.

Animation functions are based on Easing functions

Easing functions specify the rate of change of a parameter over time and allow you to apply custom mathematical formulas to your animations.

Installation

The preferred way of installation is via CocoaPods. Just add

pod 'MMTweenAnimation'

and run pod install. It will install the most recent version of MMTweenAnimation.

If you would like to use the latest code of MMTweenAnimation use:

pod 'MMTweenAnimation', :head

Type

There are 10 concrete animation types:

Back Bounce Circ Cubic Elastic
Expo Quad Quart Quint Sine

Usage

To apply a MMTweenAnimation, you must configure it by:

@property (nonatomic, copy)   MMTweenAnimationBlock  animationBlock;

@property (nonatomic, assign) NSArray *fromValue;
@property (nonatomic, assign) NSArray *toValue;
@property (nonatomic, assign) double duration;  //default: 0.3

@property (nonatomic, assign) MMTweenFunctionType functionType; //default: MMTweenFunctionBounce
@property (nonatomic, assign) MMTweenEasingType   easingType;   //default: MMTweenEasingOut

for example:

MMTweenAnimation *anim = [MMTweenAnimation animation];
anim.functionType   = MMTweenFunctionBounce;
anim.easingType     = MMTweenEasingOut;
anim.duration       = 2.0f;
anim.fromValue      = @[@0];
anim.toValue        = @[@200];
anim.animationBlock = ^(double c,double d,NSArray *v,id target,MMTweenAnimation *animation)
{
    //c: current time, from the beginning of animation
    //d: duration, always bigger than c
    //v: value, after the change at current time

    double value = [v[0] doubleValue];
    UIView *t = (UIView*)target;
    t.center = CGPointMake(t.x, value);
};

[targetView pop_addAnimation:anim forKey:@"center.y"];

Changelog

v1.1 you can animate several values at the same time

typedef void(^MMTweenAnimationBlock)(double c,   
                                     double d,  
                                     NSArray *v, // change to array
                                     id target,
                                     MMTweenAnimation *animation
                                     );

@property (nonatomic, strong) NSArray *fromValue;	// change to array
@property (nonatomic, strong) NSArray *toValue;		// change to array

v1.0 you can custom or simply use it by

@interface MMTweenAnimation : POPCustomAnimation

@property (nonatomic, copy)   MMTweenAnimationBlock  animationBlock;

@property (nonatomic, assign) double fromValue;
@property (nonatomic, assign) double toValue;
@property (nonatomic, assign) double duration;

@property (nonatomic, assign) MMTweenFunctionType functionType;
@property (nonatomic, assign) MMTweenEasingType   easingType;

+ (instancetype)animation;

@end

mmtweenanimation's People

Contributors

adad184 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.