Class: Browser::AnimationFrame
- Defined in:
- opal/browser/animation_frame.rb
Overview
Allows you to wrap a block to use in an animation rendering cycle.
Class Method Summary collapse
Instance Method Summary collapse
-
#cancel ⇒ Object
Cancel the animation frame request.
-
#initialize(window, &block) ⇒ AnimationFrame
constructor
Execute the block to update an animation before the next repaint.
-
#request ⇒ Object
Request the animation frame.
Constructor Details
permalink #initialize(window, &block) ⇒ AnimationFrame
Execute the block to update an animation before the next repaint.
21 22 23 24 25 |
# File 'opal/browser/animation_frame.rb', line 21 def initialize(window, &block) @window = window @native = window.to_n @id = request(block) end |
Class Method Details
permalink .supported? ⇒ Boolean
8 9 10 11 12 13 14 15 16 |
# File 'opal/browser/animation_frame.rb', line 8 def self.supported? ['Animation.request', 'Animation.request (Chrome)', 'Animation.request (Firefox)', 'Animation.request (Opera)', 'Animation.request (Internet Explorer)'].any? {|feature| Browser.supports? feature } end |
Instance Method Details
permalink #cancel ⇒ Object
Cancel the animation frame request.
92 93 94 |
# File 'opal/browser/animation_frame.rb', line 92 def cancel `#@native.cancelAnimationFrame(#@id)` end |
permalink #request ⇒ Object
Request the animation frame.
49 50 51 |
# File 'opal/browser/animation_frame.rb', line 49 def request(block) `#@native.requestAnimationFrame(#{block.to_n})` end |