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
#initialize(window, &block) ⇒ AnimationFrame
Execute the block to update an animation before the next repaint.
20 21 22 23 24 |
# File 'opal/browser/animation_frame.rb', line 20 def initialize(window, &block) @window = window @native = window.to_n @id = request(block) end |
Class Method Details
.supported? ⇒ Boolean
7 8 9 10 11 12 13 14 15 |
# File 'opal/browser/animation_frame.rb', line 7 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
#cancel ⇒ Object
Cancel the animation frame request.
91 92 93 |
# File 'opal/browser/animation_frame.rb', line 91 def cancel `#@native.cancelAnimationFrame(#@id)` end |
#request ⇒ Object
Request the animation frame.
48 49 50 |
# File 'opal/browser/animation_frame.rb', line 48 def request(block) `#@native.requestAnimationFrame(#{block.to_n})` end |