motion-linear-animate 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +14 -0
- data/app/app_delegate.rb +8 -0
- data/app/controllers/screen_controller.rb +37 -0
- data/lib/motion-linear-animate.rb +9 -0
- data/lib/motion-linear-animate/animate.rb +12 -0
- data/motion-linear-animate.gemspec +22 -0
- data/resources/Default-568h@2x.png +0 -0
- data/spec/main_spec.rb +9 -0
- data/spec/motion_animator_spec.rb +13 -0
- data/spec/screen_controller_spec.rb +15 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzZiZjEwYjE0NDRhZDk2MTRhMjJlMDlhZWFkMzYxZjc0ZDc0MDBiNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDdiMDdhMDZlYjFlMmJkOGY1Y2U5ZGQ3ZmYxODU1MTMwMTk5ZjMzYg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGIzZjQxOGM1ZTExOTNjMGYyMjVlMzE2M2RhM2Y3ZGViZjlmZGUyOGNmYzcx
|
10
|
+
YjE0ZjAzMTVhZGZhYzIxYTM4NTFkZTI4OGNhOTUzZmVkMjk1NGEyYTMwNjEw
|
11
|
+
NGRhZGQxNjhjMzRhOTE1ZTI0MTUzNTA0Y2VlOTc3NDljOTkxNzA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTg2MjVjMzc4ZDBhMzA3YjBhNDZhYzRkZjcyNGY4YjU0MmU0ZTFiYmE1MGE4
|
14
|
+
NWFkZmJiNDQxNzUyNjZjYzc5NzQxYmE4ZjMzMTc3M2NjYjBjNjY5YjQ5ODJj
|
15
|
+
MGQ2NDdhZjE1MDllYWE2OTMzYWM5YWRjYjBmZjc2YTU3NjE1Yjk=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Multunus Software Pvt Ltd
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
iOS (RubyMotion) Animation Library
|
2
|
+
============================
|
3
|
+
|
4
|
+
This is a simple wrapper for linear iOS animations. Currently, only simple animations are supported. We promise to add much more fascination animations to this library, so please bear with us until then :)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
```ruby
|
10
|
+
gem 'motion-linear-animate'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
```ruby
|
15
|
+
bundle
|
16
|
+
```
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
```ruby
|
20
|
+
gem install motion-linear-animate
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
We have included a sample app you can use for reference, but here is the basic setup to ease work for you:
|
25
|
+
```ruby
|
26
|
+
animator = MotionAnimator.new
|
27
|
+
animator.linear_animate(view, to: final_point, duration: time_period, completion: completion_block)
|
28
|
+
```
|
29
|
+
|
30
|
+
* ```final_point``` should be an instance of ```CGPoint``` or any other object with ```x``` and ```y``` attributes set to the final *(x, y)* position the view should be in after the animation.
|
31
|
+
* ```time_period``` is the duration allocated for the animation to take place.
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
$:.unshift("/Library/RubyMotion/lib")
|
3
|
+
require 'motion/project/template/ios'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.require
|
8
|
+
rescue LoadError
|
9
|
+
end
|
10
|
+
|
11
|
+
Motion::Project::App.setup do |app|
|
12
|
+
# Use `rake config' to see complete project settings.
|
13
|
+
app.name = 'sample_animate_app'
|
14
|
+
end
|
data/app/app_delegate.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
class AppDelegate
|
2
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
3
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
4
|
+
@window.makeKeyAndVisible
|
5
|
+
@window.rootViewController = ScreenController.alloc.initWithNibName(nil, bundle: nil)
|
6
|
+
true
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class ScreenController < UIViewController
|
2
|
+
def viewDidLoad
|
3
|
+
super
|
4
|
+
self.view.backgroundColor = UIColor.whiteColor
|
5
|
+
@title_label = setup_title_label
|
6
|
+
@animator_button = setup_animator_button
|
7
|
+
self.view.addSubview(@title_label)
|
8
|
+
self.view.addSubview(@animator_button)
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup_title_label
|
12
|
+
title_label = UILabel.alloc.initWithFrame(CGRectMake(0.0 , 100.0, self.view.frame.size.width, 21.0))
|
13
|
+
title_label.setFont(UIFont.fontWithName("Helvetica-Bold", size: 18))
|
14
|
+
title_label.setBackgroundColor(UIColor.clearColor)
|
15
|
+
title_label.setTextColor(UIColor.colorWithRed(157.0/255.0, green:157.0/255.0, blue:157.0/255.0, alpha:1.0))
|
16
|
+
title_label.setText("Awesome Stuff @ Multunus!!")
|
17
|
+
title_label.setTextAlignment(NSTextAlignmentCenter)
|
18
|
+
title_label
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup_animator_button
|
22
|
+
animator_button = UIButton.buttonWithType(UIButtonTypeCustom)
|
23
|
+
animator_button.layer.cornerRadius = 10.0
|
24
|
+
animator_button.addTarget(self, action: "animate_title_label:", forControlEvents:UIControlEventTouchDown)
|
25
|
+
animator_button.backgroundColor = UIColor.blackColor
|
26
|
+
animator_button.setTitle("Click To Animate!!", forState:UIControlStateNormal)
|
27
|
+
animator_button.frame = CGRectMake(80.0, 30.0, 160.0, 40.0)
|
28
|
+
animator_button
|
29
|
+
end
|
30
|
+
|
31
|
+
def animate_title_label sender
|
32
|
+
animator = MotionAnimator.new
|
33
|
+
final_point = @title_label.frame.origin
|
34
|
+
final_point.y += 50
|
35
|
+
animator.linear_animate(@title_label, to: final_point, duration: 0.3, completion: nil)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
Motion::Project::App.setup do |app|
|
6
|
+
Dir.glob(File.join(File.dirname(__FILE__), "motion-linear-animate/*.rb")).each do |file|
|
7
|
+
app.files.unshift(file)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class MotionAnimator
|
2
|
+
def linear_animate(view, to: final_point, duration: time_period, completion: completion_block)
|
3
|
+
frame = view.frame
|
4
|
+
frame.origin.x = final_point.x
|
5
|
+
frame.origin.y = final_point.y
|
6
|
+
UIView.animateWithDuration(time_period,
|
7
|
+
animations: lambda{
|
8
|
+
view.frame = frame
|
9
|
+
},
|
10
|
+
completion: completion_block)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "motion-linear-animate"
|
7
|
+
spec.version = "1.0"
|
8
|
+
spec.authors = ["Multunus"]
|
9
|
+
spec.email = ["info@multunus.com"]
|
10
|
+
spec.summary = %q{Wrapper for linear animations in RubyMotion}
|
11
|
+
spec.description = %q{Wrapper for linear animations in RubyMotion}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
end
|
Binary file
|
data/spec/main_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
describe MotionAnimator do
|
2
|
+
before do
|
3
|
+
@title_label = UILabel.alloc.initWithFrame(CGRectMake(0.0 , 100.0, 320, 21.0))
|
4
|
+
@motion_animator = MotionAnimator.new
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should move the given view to the final point" do
|
8
|
+
point = @title_label.frame.origin
|
9
|
+
point.y = 200
|
10
|
+
@motion_animator.linear_animate(@title_label, to: point, duration: 0, completion: nil)
|
11
|
+
@title_label.frame.origin.y.should == 200
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe ScreenController do
|
2
|
+
before do
|
3
|
+
@screen_controller = ScreenController.new
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should setup the title label" do
|
7
|
+
title_label = @screen_controller.setup_title_label
|
8
|
+
title_label.class.should == UILabel
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should setup the animation button" do
|
12
|
+
animator_button = @screen_controller.setup_animator_button
|
13
|
+
animator_button.class.should == UIButton
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-linear-animate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Multunus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Wrapper for linear animations in RubyMotion
|
42
|
+
email:
|
43
|
+
- info@multunus.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- app/app_delegate.rb
|
54
|
+
- app/controllers/screen_controller.rb
|
55
|
+
- lib/motion-linear-animate.rb
|
56
|
+
- lib/motion-linear-animate/animate.rb
|
57
|
+
- motion-linear-animate.gemspec
|
58
|
+
- resources/Default-568h@2x.png
|
59
|
+
- spec/main_spec.rb
|
60
|
+
- spec/motion_animator_spec.rb
|
61
|
+
- spec/screen_controller_spec.rb
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.2.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Wrapper for linear animations in RubyMotion
|
86
|
+
test_files:
|
87
|
+
- spec/main_spec.rb
|
88
|
+
- spec/motion_animator_spec.rb
|
89
|
+
- spec/screen_controller_spec.rb
|