Class: MotionWizard::AnimationStrategy::SlideAnimation

Inherits:
BaseAnimationStrategy show all
Defined in:
lib/motion-wizard/animation_strategy/slide_animation.rb

Instance Attribute Summary collapse

Attributes inherited from BaseAnimationStrategy

#already_on_final_position, #duration

Instance Method Summary collapse

Methods inherited from BaseAnimationStrategy

#hide_view, #initialize, #show_view

Constructor Details

This class inherits a constructor from MotionWizard::AnimationStrategy::BaseAnimationStrategy

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



4
5
6
# File 'lib/motion-wizard/animation_strategy/slide_animation.rb', line 4

def direction
  @direction
end

Instance Method Details

#animateObject



6
7
8
9
# File 'lib/motion-wizard/animation_strategy/slide_animation.rb', line 6

def animate
  do_slide_animation(@show_view, @direction*App.frame.size.width, 0, @show_view_after_block)
  do_slide_animation(@hide_view, 0, -@direction*App.frame.size.width, @hide_view_after_block)
end

#do_slide_animation(view, initial_position, final_position, after_block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/motion-wizard/animation_strategy/slide_animation.rb', line 11

def do_slide_animation(view, initial_position, final_position, after_block)
  view.origin = [initial_position, view.origin.y]
  UIView.animateWithDuration(@duration, animations: -> {
    view.origin = [final_position, view.origin.y]
  },completion: ->(finished) {
    after_block.call(view) if after_block
  })
end