Slide out and specs

This commit is contained in:
Gant
2014-07-21 22:30:46 -05:00
parent 62464b8a7f
commit 64a8a0ba0d
2 changed files with 50 additions and 3 deletions

View File

@@ -226,7 +226,7 @@ module RubyMotionQuery
bq.move(l: -rmq.device.width)
when :top
bq.move(t: -rmq.device.height)
when :bottom
else :bottom
bq.move(t: rmq.device.height)
end
start_frame
@@ -239,6 +239,45 @@ module RubyMotionQuery
@rmq.animate(opts)
end
# @return [RMQ]
def slide_out(opts = {})
remove_view = opts[:remove_view]
to_direction = opts[:to_direction] || :left
opts = {
duration: 0.5,
options: UIViewAnimationOptionCurveEaseIn,
before: ->(bq) {
start_frame = bq.get.frame
start_frame
},
animations: ->(aq, return_var) {
case to_direction
when :right
aq.move(l: rmq.device.width)
# TODO Rest
when :left
aq.move(l: -rmq.device.width)
when :top
aq.move(t: -rmq.device.height)
else :bottom
aq.move(t: rmq.device.height)
end
},
completion: ->(did_finish, q) {
if did_finish
if remove_view
q.remove
else
q.hide
end
end
}
}.merge(opts)
@rmq.animate(opts)
end
# @return [RMQ]
def start_spinner(style = UIActivityIndicatorViewStyleGray)
spinner = Animations.window_spinner(style)

View File

@@ -11,7 +11,7 @@ describe 'animations' do
after do
UIView.setAnimationsEnabled true
end
it 'should animate' do
@vc.rmq.animate(
@@ -20,7 +20,7 @@ describe 'animations' do
RubyMotionQuery::RMQ.is_blank?(rmq).should == false
},
completion: -> (did_finish, rmq) {
rmq.animate(
rmq.animate(
duration: 0.0,
animations: -> (rmq) {
RubyMotionQuery::RMQ.is_blank?(rmq).should == false
@@ -75,6 +75,14 @@ describe 'animations' do
@viewq.animations.land_and_sink_and_throb.is_a?(RubyMotionQuery::RMQ).should == true
end
it 'should slide in' do
@viewq.animations.slide_in.is_a?(RubyMotionQuery::RMQ).should == true
end
it 'should slide out' do
@viewq.animations.slide_out.is_a?(RubyMotionQuery::RMQ).should == true
end
it 'should start spinner' do
q = @vc.rmq.animations.start_spinner
q.first.get.is_a?(UIActivityIndicatorView).should == true