• Stars
    star
    144
  • Rank 255,590 (Top 6 %)
  • Language
    Ruby
  • License
    Other
  • Created almost 12 years ago
  • Updated over 11 years ago

Reviews

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

Repository Details

Fast, frictionless iOS animations

Walt for RubyMotion

Tired of verbose animation chains in iOS?

With Walt, you can make this:

Walt animation

Using this:

@view = UIView.alloc.initWithFrame(....)

Walt.animate(
  assets: [{
    id: "logo",
    position: [100, 0],
    size: [110, 40],
    url: "http://bit.ly/S98Ta5"
  }],
  animations: [{
    duration: 2,
    operations: [{
      move: "logo",
      to: 150,
      axis: :y
    }],
    after: {
      duration: 2,
      operations: [{
        rotate: "logo",
        to: 360
      }]
    }
  }],
  in: @view
)

Installation

First install the Walt gem:

gem install walt

Add Walt to your Gemfile or require it in your Rakefile:

gem 'walt'
require 'walt'

If you're going to use the image-URL loading component of Walt, add AFNetworking to your pods:

app.pods do
  pod "AFNetworking"
end

Usage

Walt is organized around assets, animations, and operations. Each animation is a collection of operations occuring at the same time and configuration.

Assets

Walt supports arbitrary UIViews as assets, and can also build some types of views from hashes. Constructor hashes include:

# Uses an existing `UIView`
{ id: "my_id", view: UIView.alloc.initWithFrame(...) }

# Creates a new `UIView`
# All Walt::Assets support these options:
# :position, :size, :view, :content_mode, :clips_to_bounds, :background_color
{ id: "my_id", size: [100,100], background_color: "0088cc" }

# Creates a new `UILabel`; also supports:
# :text_color, :background_color, :number_of_lines, :font, :text_alignment
{ id: "my_id", text: "Hello World" }

# Creates a new `UIImageView`
# No animations will start until all
#   remotely-loaded assets have loaded
{ id: "my_id", url: "http://imgur.com/hello.png" }

Operations

Walt comes with a few nifty operations, and adding your own is easy.

Move

  {
    move: "my_id",
    from: [10, 10],
    to: [50, 50]
  }
  {
    move: "my_id",
    from: 0,
    to: 100,
    axis: :y # also supports :x
  }

Rotate

  {
    rotate: "my_id",
    from: 20, # in degrees
    to: 50
  }

Fade

  {
    fade: "my_id",
    from: 1.0,
    to: 0.2
  }

Scale

  {
    scale: "my_id",
    from: 1.0,
    to: 1.3
  }

Adding your own

Create a subclass of Walt::Operation::Base with a name of the form ____Operation (i.e. FancyOperation). In your class, implement def setup(view, animation) and def finalize(view, animation). Then, you can use a hash of the form {fancy: "my_id"} to use that operation.

Example:

module Walt
  module Operation
    class FancyOperation < Base

    # run before animation starts
    def setup(view, animation)
      ...
    end

    # make changes to animate
    def finalize(view, animation)
      ...
    end
  end
end

Walt.animate(...
  {
    fancy: "my_id"
  }
)

Animations

Animations control the timing and configuration of operations. They support :delay and :duration settings which affect timing, and a :options setting which you can pass a list of UIViewAnimationOptions for that animation.

Animations can be chained using an animation's :after property, which takes another animation hash.

# Also applies to Walt.animate
{
  delay: 0.3,
  duration: 2.2,
  options: [:curve_ease_in, :begin_from_current_state],
  operations: [...],
  after: {
    delay: 1.0,
    duration: 1.0,
    ...
  }
}

Contact

Clay Allsopp (http://clayallsopp.com)

License

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

More Repositories

1

routable-ios

Routable, an in-app native URL router, for iOS
Objective-C
1,815
star
2

react.backbone

Plugin for React to make Backbone migration easier
JavaScript
840
star
3

formotion

Making iOS Forms insanely great with RubyMotion
Ruby
609
star
4

routable-android

Routable, an in-app native URL router, for Android
Java
474
star
5

graphqlhub

The GraphQLHub Server
JavaScript
402
star
6

ShotBlocker

Detecting iOS screenshots ala Snapchat and Facebook Poke
Objective-C
257
star
7

rubymotion-tutorial

RubyMotion-Tutorial
Ruby
211
star
8

HybridKit-iOS

HybridKit for iOS
Objective-C
126
star
9

remote_model

JSON API <-> NSObject via RubyMotion
Ruby
97
star
10

geomotion

Better iOS Geometry with RubyMotion
Ruby
90
star
11

Routable

A RubyMotion UIViewController -> URL router
Ruby
86
star
12

graphql-intro

JavaScript
86
star
13

react-vr

Write VR web apps with React JS
JavaScript
83
star
14

motion-toolbox.com

The Motion-Toolbox website
CSS
79
star
15

relay-101

Relay 101
JavaScript
48
star
16

HybridKit-JS

HybridKit for JavaScript
JavaScript
45
star
17

motion-screenshots

Automatic screenshots for your RubyMotion apps
Ruby
41
star
18

twittermotion

RubyMotion wrapper for the iOS Twitter API
Ruby
40
star
19

readme-score

Giving a score to README.md's everywhere
Ruby
40
star
20

motion-smarticons

Automatically generate icon labels for RubyMotion apps
Ruby
39
star
21

maglev

Faster, smoother iOS development
Ruby
36
star
22

motion-require

Dependency management for RubyMotion, using a pseudo `require`
Ruby
34
star
23

motion-env

Sync ENV variables between Rakefile and RubyMotion
Ruby
31
star
24

applebot

Automating iTunes Connect and the iOS Developer Center
JavaScript
31
star
25

react-native-remote-component

Load React Native components over the network
Objective-C
27
star
26

VolumeCamera

iPhone app where camera is triggered by volume buttons
Objective-C
26
star
27

urlp

A command-line URL parser, written in Rust
Rust
22
star
28

CLAFluxDispatcher

A port of Facebook's Flux Dispatcher to Objective-C
Objective-C
22
star
29

mixing-objc-ruby

Mixing Objective-C and Ruby with RubyMotion
Objective-C
20
star
30

typescript-1.8-tutorial

Migrating a JavaScript app to TypeScript 1.8
JavaScript
20
star
31

motion-colorize

Add some color to your RubyMotion output
Ruby
17
star
32

motion-screenspecs

Test your RubyMotion app using screenshot comparison
Ruby
17
star
33

graphql-unions-interfaces

JavaScript
13
star
34

appleload

CLI & Ruby Library to control Apple's Application Loader app
Ruby
12
star
35

motion-weakattr

weak_attr for WeakRefs in RubyMotion
Ruby
10
star
36

appleslice

Easily parse Apple & iTunes Connect emails
Ruby
7
star
37

motion-http

Cross-platform HTTP library for RubyMotion
7
star
38

BrocabularyTutorial

The source to the Android App From Scratch tutorials
Java
7
star
39

relay-102

Relay with Mutations! Powered by GraphQLHub
JavaScript
6
star
40

plottable-examples

HTML
5
star
41

afmotion-rocket

AFMotion extensions for Rocket
Ruby
5
star
42

CYStoreExample

Magically easy in-app purchases on iOS.
Objective-C
4
star
43

MotionCorePlot

Ruby
3
star
44

graphql-directives

JavaScript
3
star
45

motion-tips

Motion Tips blog dump.
Ruby
3
star
46

gumroad-ruby

Ruby binding for Gumroad API
Ruby
3
star
47

smashing-rubymotion

Source code to Smashing's RubyMotion example
Ruby
3
star
48

droidproj

Manage Android projects with a Droidfile
Ruby
2
star
49

readme-score-api

The API for readme-score
Go
2
star
50

FormotionTest

Tests
Ruby
2
star
51

WebActivity

Drop-in Activity to browse the web
Java
1
star
52

new-news

TypeScript
1
star
53

botlib

The shared library for AppleBot and PlayBot
Ruby
1
star
54

clayallsopp.github.com

1
star