Method: SugarCube::AnimationChain#do_next

Defined in:
lib/ios/sugarcube-animations/animation_chain.rb

#do_nextObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ios/sugarcube-animations/animation_chain.rb', line 43

def do_next
  return nil if @block_index >= @blocks.length

  options, block = @blocks[@block_index]
  @after_block = ->(completed) do
    if @abort || ! self.do_next
      @running = false
      if @loop
        start
      else
        AnimationChain.stop_chain(self)
      end
    end
  end.weak!
  options[:after] = @after_block

  UIView.animate(options) do
    Thread.current[:sugarcube_chaining] = true
    block.call if block
    Thread.current[:sugarcube_chaining] = nil
    @block_index += 1
  end
  true
end