Animotion 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .DS_Store
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Animotion.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/Animotion/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Silas J. Matson"]
6
+ gem.email = ["silas@clearsightstudio.com"]
7
+ gem.description = "RubyMotion wrapper abstraction for UIView animations."
8
+ gem.summary = "RubyMotion wrapper abstraction for UIView animations."
9
+ gem.homepage = "https://github.com/silaj/Animotion"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "Animotion"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Animotion::VERSION
17
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Animotion.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Silas J. Matson
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
+ # Animotion
2
+
3
+ A RubyMotion wrapper for common UIView animations. Imagine something similar to jQuery animations (i.e. 'fadein', 'fadeout').
4
+
5
+ I don't really have time to be updating this gem right now, so pull requests are welcome.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'Animotion'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install Animotion
20
+
21
+ ## Usage
22
+
23
+ Usage instructions Forthcoming...
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,35 @@
1
+ module Animotion
2
+ def animate(duration, &block)
3
+ return false unless block_given?
4
+
5
+ UIView.beginAnimations(nil, context:nil)
6
+ UIView.setAnimationDuration duration
7
+
8
+ yield
9
+
10
+ UIView.commitAnimations
11
+ end
12
+
13
+ # Taken from bubblewrap
14
+ # -- trying to stay dependency free
15
+ #
16
+ # https://github.com/rubymotion/BubbleWrap
17
+ # https://github.com/rubymotion/BubbleWrap/blob/master/motion/core/app.rb lines 60-66 as of 9-17-12
18
+ #
19
+ def run_after(delay, &block)
20
+ NSTimer.scheduledTimerWithTimeInterval( delay,
21
+ target: block,
22
+ selector: "call:",
23
+ userInfo: nil,
24
+ repeats: false)
25
+ end
26
+
27
+ def hide
28
+ self.alpha = 0
29
+ end
30
+
31
+ def show
32
+ self.alpha = 1
33
+ end
34
+
35
+ end
@@ -0,0 +1,30 @@
1
+ module Animotion
2
+ def fade_out(time=1, opts={})
3
+ animate time do
4
+ self.alpha = 0
5
+ end
6
+ if opts[:remove] && opts[:remove] == true
7
+ run_after time do
8
+ self.removeFromSuperview
9
+ end
10
+ end
11
+ end
12
+
13
+ def fade_in(time=1)
14
+ animate time do
15
+ self.alpha = 1
16
+ end
17
+ end
18
+
19
+ def fade_to(opacity, time=1)
20
+ animate time do
21
+ self.alpha = opacity
22
+ end
23
+ end
24
+
25
+ def fade_toggle(time=1)
26
+ animate time do
27
+ self.alpha = 1 - self.alpha
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ module Animotion
2
+ def slide_to(time, frame)
3
+ animate time do
4
+ UIView.setAnimationTransition(UIViewAnimationTransitionNone, forView:self, cache: true)
5
+ self.setFrame frame
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ class UIView
2
+ include Animotion
3
+ end
@@ -0,0 +1,3 @@
1
+ module Animotion
2
+ VERSION = "0.0.1" unless defined? Animotion::Version
3
+ end
data/lib/Animotion.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "Animotion/version"
2
+
3
+
4
+ Motion::Project::App.setup do |app|
5
+ Dir.glob(File.join(File.dirname(__FILE__), "Animotion/*.rb")).each do |file|
6
+ app.files.unshift(file)
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Animotion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Silas J. Matson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-18 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: RubyMotion wrapper abstraction for UIView animations.
15
+ email:
16
+ - silas@clearsightstudio.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Animotion.gemspec
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - lib/Animotion.rb
28
+ - lib/Animotion/core.rb
29
+ - lib/Animotion/fading_animations.rb
30
+ - lib/Animotion/sliding_animations.rb
31
+ - lib/Animotion/uiview.rb
32
+ - lib/Animotion/version.rb
33
+ homepage: https://github.com/silaj/Animotion
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.22
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: RubyMotion wrapper abstraction for UIView animations.
57
+ test_files: []
58
+ has_rdoc: