sugarcube 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/sugarcube-animations/uiview.rb +35 -0
- data/lib/sugarcube/version.rb +1 -1
- data/spec/uiview_animation_spec.rb +27 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcbd6cc3b891a5629f4076ad76609dd7c5dbc77d
|
4
|
+
data.tar.gz: 58279eb857e9af976a24349e1d61d1f1f0e6f392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 684329a0721adf33fcc0b5c8fee70af989e1fc3a7cc07607335a8766f6b93ee5e44aa7331fb2ed19ae2b050b6f09066fc51389c0b6e2a1b8d0a3dd414fd2504f
|
7
|
+
data.tar.gz: 14fc25bc8e77d8580442921ef792ba40311aa761ff75c26d191514abcfe16cc396a187ca62b6886c97d8474d697f3b588cd18d8cf04a5837a9c98d15439e5073
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -857,6 +857,11 @@ Animations ([wiki][Animations Wiki])
|
|
857
857
|
Careful, once you start using these helpers, you'll never go back.
|
858
858
|
|
859
859
|
```ruby
|
860
|
+
view.move_to [100.0, 100.0] # origin
|
861
|
+
view.center_to [100.0, 100.0] # center
|
862
|
+
view.scale_to 2 # double the size, and preserves existing rotation transform
|
863
|
+
# view.scale_to 4 -> CGAffineTransformMakeScale(4, 4)
|
864
|
+
# view.scale_to [4, 3] -> CGAffineTransformMakeScale(4, 3)
|
860
865
|
view.fade_out
|
861
866
|
view.slide :left, 100
|
862
867
|
view.rotate_to 180.degrees
|
@@ -183,6 +183,41 @@ class UIView
|
|
183
183
|
fade_out(options, &after_remove)
|
184
184
|
end
|
185
185
|
|
186
|
+
def scale_to(scale, options={}, more_options={}, &after)
|
187
|
+
if options.is_a? Numeric
|
188
|
+
options = more_options.merge(duration: options)
|
189
|
+
end
|
190
|
+
|
191
|
+
if scale.is_a?(Numeric)
|
192
|
+
scale_x = scale_y = scale
|
193
|
+
else # this could be an array, or CGSize; either way we'll use []
|
194
|
+
scale_x = scale[0]
|
195
|
+
scale_y = scale[1]
|
196
|
+
end
|
197
|
+
|
198
|
+
options[:after] = after
|
199
|
+
|
200
|
+
animate(options) {
|
201
|
+
radians = Math.atan2(self.transform.b, self.transform.a)
|
202
|
+
# radians = self.valueForKeyPath('layer.transform.rotation.z')
|
203
|
+
rotation_t = CGAffineTransformMakeRotation(radians)
|
204
|
+
scale_t = CGAffineTransformMakeScale(scale_x, scale_y)
|
205
|
+
self.transform = CGAffineTransformConcat(rotation_t, scale_t)
|
206
|
+
}
|
207
|
+
end
|
208
|
+
|
209
|
+
def center_to(center, options={}, more_options={}, &after)
|
210
|
+
if options.is_a? Numeric
|
211
|
+
options = more_options.merge(duration: options)
|
212
|
+
end
|
213
|
+
|
214
|
+
options[:after] = after
|
215
|
+
|
216
|
+
animate(options) {
|
217
|
+
self.center = SugarCube::CoreGraphics::Point(center)
|
218
|
+
}
|
219
|
+
end
|
220
|
+
|
186
221
|
def move_to(position, options={}, more_options={}, &after)
|
187
222
|
if options.is_a? Numeric
|
188
223
|
options = more_options.merge(duration: options)
|
data/lib/sugarcube/version.rb
CHANGED
@@ -11,7 +11,7 @@ describe "UIView animation methods" do
|
|
11
11
|
@view.resize_to([5,6]).frame.should == CGRectMake(1,2,5,6)
|
12
12
|
end
|
13
13
|
|
14
|
-
it 'should reframe_to ' do
|
14
|
+
it 'should reframe_to x:2 y:4 w:5 h:6' do
|
15
15
|
@view.reframe_to([[2,4],[5,6]]).frame.should == CGRectMake(2,4,5,6)
|
16
16
|
end
|
17
17
|
|
@@ -19,6 +19,32 @@ describe "UIView animation methods" do
|
|
19
19
|
@view.move_to([2,4]).frame.should == CGRectMake(2,4,3,4)
|
20
20
|
end
|
21
21
|
|
22
|
+
it 'should center_to x:2 y:4' do
|
23
|
+
@view.center_to([2,4]).center.should == CGPointMake(2,4)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should scale to 4' do
|
27
|
+
radians = Math.atan2(@view.transform.b,
|
28
|
+
@view.transform.a)
|
29
|
+
new_view = @view.scale_to(4)
|
30
|
+
new_radians = Math.atan2(new_view.transform.b,
|
31
|
+
new_view.transform.a)
|
32
|
+
radians.should == new_radians
|
33
|
+
new_view.transform.a.should == 4.to_f
|
34
|
+
new_view.transform.d.should == 4.to_f
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should scale to x:4 y:3' do
|
38
|
+
radians = Math.atan2(@view.transform.b,
|
39
|
+
@view.transform.a)
|
40
|
+
new_view = @view.scale_to([4, 3])
|
41
|
+
new_radians = Math.atan2(new_view.transform.b,
|
42
|
+
new_view.transform.a)
|
43
|
+
radians.should == new_radians
|
44
|
+
new_view.transform.a.should == 4.to_f
|
45
|
+
new_view.transform.d.should == 3.to_f
|
46
|
+
end
|
47
|
+
|
22
48
|
it 'should rotate 45 degrees' do
|
23
49
|
angle = 45.degrees
|
24
50
|
@view.rotate_to(angle)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin T.A. Gray
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-03-
|
14
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: |
|
17
17
|
== Description
|