Sha256: 331294bb6cf6eef5b2202a68a253a083ab1cc3c5261aec0472897029a7437fb4

Contents?: true

Size: 690 Bytes

Versions: 1

Compression:

Stored size: 690 Bytes

Contents

require 'browser/compatibility/animation_frame'

module Browser

# FIXME: drop the method_defined? checks when require order is fixed
class AnimationFrame
  def initialize(window, &block)
    @window = window
    @native = window.to_n
    @id     = request(block)
  end

  def request
    raise NotImplementedError, 'window requestAnimationFrame unsupported'
  end unless method_defined? :request

  def cancel
    raise NotImplementedError, 'window cancelAnimationFrame unsupported'
  end unless method_defined? :cancel
end

end

class Proc
  # Execute a block to update an animation before the next repaint.
  def animation_frame
    Browser::AnimationFrame.new($window, &self)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/animation_frame.rb