• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐍 ObjectiveC library for magical scroll interactions.

Ouroboros

CI Status Version License Platform

This is an Objective-C library for magical scroll interactions. Ouroboros is inspired by javascript third-party framework scrollmagic. You can create magical scroll interactions with Ouroboros in iOS App.

Features

  • Different scroll direction support
  • UIView / Layer animation
  • Overlapping animation detect
  • Measure guide for UIView
  • Animation curve support
  • Mac OS X support

Demo

To run the example project, clone the repo, and run pod install from the Example directory first.

Demo

Installation with CocoaPods

Ouroboros is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Ouroboros"

Usage

#import "Ouroboros.h"

Animate

Add animation to a view is extremely easy. Ouroboros provides a bunch of convience APIs on UIView through category. Directly invoke our_animateWithProperty:configureBlock: method of UIView instance.

view.backgroundColor = [UIColor redColor];
[view our_animateWithProperty:OURAnimationPropertyViewBackgroundColor
               configureBlock:^(Ouroboros *ouroboros) {
                   ouroboros.toValue = [UIColor blueColor];
                   ouroboros.trigger = 0;
                   ouroboros.offset = 100;
               }];

You should pass a type of OURAnimationProperty to this method, and set up the ouroboros instance in the block. And that's it.

trigger is the point when the animation start and offset is the distance the animation occurs.

Different kinds of animation needs different kinds of toValue. The fromValue for each view is the start value of it. i.e. the above Ouroboros animation's fromValue is [UIColor redColor]. So you do not need to pass a fromValue parameter to ouroboros object.

Pin

If you would like to pin a view to some position, call our_pinWithConfigureBlock: method directly. The default trigger for this pin animation is 0 and offset is INT_MAX. This method just animate view's center according to OURScrollDirection and

[yellowView our_pinWithConfigureBlock:^(Scale * _Nonnull scale) {
    scale.trigger = 100;
    scale.offset = 200;
}];

AnimationType

typedef NS_ENUM(NSUInteger, OURAnimationProperty) {
    OURAnimationPropertyViewFrame,
    OURAnimationPropertyViewBounds,
    OURAnimationPropertyViewSize,
    OURAnimationPropertyViewCenter,
    OURAnimationPropertyViewPosition,
    OURAnimationPropertyViewOrigin,
    OURAnimationPropertyViewOriginX,
    OURAnimationPropertyViewOriginY,
    OURAnimationPropertyViewWidth,
    OURAnimationPropertyViewHeight,
    OURAnimationPropertyViewCenterX,
    OURAnimationPropertyViewCenterY,
    OURAnimationPropertyViewBackgroundColor,
    OURAnimationPropertyViewTintColor,
    OURAnimationPropertyViewAlpha,
    OURAnimationPropertyViewTransform,
    OURAnimationPropertyLayerFrame,
    OURAnimationPropertyLayerBounds,
    OURAnimationPropertyLayerPosition,
    OURAnimationPropertyLayerZPosition,
    OURAnimationPropertyLayerAnchorPoint,
    OURAnimationPropertyLayerAnchorPointZ,
    OURAnimationPropertyLayerTransform,
    OURAnimationPropertyLayerBackgroundColor,
    OURAnimationPropertyLayerCornerRadius,
    OURAnimationPropertyLayerBorderWidth,
    OURAnimationPropertyLayerBorderColor,
    OURAnimationPropertyLayerOpacity,
};

Direction

There are two animation directions for scrollView, if you want to animate according to contentOffset.x. You should change the scrollView property ou_scrollDirection to OURScrollDirectionHorizontal.

typedef NS_ENUM(NSUInteger, OURScrollDirection) {
    OURScrollDirectionVertical,
    OURScrollDirectionHorizontal,
};

OURScrollDirectionVertical is the default behavior for each scrollView which will animate when contentOffset.y of scrollView changes.

Author

Draveness, [email protected]

License

Ouroboros is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

analyze

Draven's Blog
Objective-C
8,101
star
2

DKNightVersion

Manage Colors, Integrate Night/Multiple Themes. (Unmaintained)
Objective-C
3,556
star
3

DKChainableAnimationKit

A DSL to make animation easy on iOS with Swift.
Swift
1,894
star
4

NightNight

Elegant way to integrate night mode to swift projects
Swift
776
star
5

Typeset

Deal with AttributedString efficiently
Objective-C
450
star
6

RbSwift

Extensions for Swift with hundreds of handy methods.
Swift
320
star
7

go-internal

《Go 语言设计与实现》示例代码
Go
268
star
8

blog-comments

面向信仰编程
140
star
9

ATProperty

☀️ Create @property with shortcut
Objective-C
135
star
10

proxier

A better approach to expose application in Kubernetes.
Go
109
star
11

linux-archive

Linux archive for studying the process scheduler. 调度系统设计精要 http://draveness.me/system-design-scheduler
C
88
star
12

JSONCop

A better way to deal with JSON parsing in Swift.
Ruby
30
star
13

Mineral

A library used to separate concerns from the original UIKit framework.
Swift
29
star
14

ChainableKit

Chainable UIKit in Objective-C
Objective-C
27
star
15

oceanbook

A Modern Matching Engine without documentation YET [alpha]
Go
25
star
16

Crotalus

Elegant approach to create AttributedString in swift
Swift
19
star
17

SpaceShuttle

🚀 A library manages Inter-View value passing
Objective-C
13
star
18

go-utils

Go
11
star
19

OKObserver

A lightweight wrapper for KVO, bind view and model easily
Objective-C
11
star
20

draveness

10
star
21

git-ignore

Rust
3
star
22

tmpwatch-controller

Dockerfile
2
star
23

gitbook-plugin-gitalk

JavaScript
2
star
24

Daytabase

An key/value store database built atop sqlite
Swift
1
star