mirror of
https://github.com/zhigang1992/rmq.git
synced 2026-04-29 13:15:36 +08:00
Slide out and specs
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user