Module: Kernel

Defined in:
opal/fron/core_ext/kernel.rb

Overview

Kernel

Instance Method Summary collapse

Instance Method Details

#requestAnimationFrameObject

Requests an animation frame from the browser and runs the givel block if given.


5
6
7
8
9
# File 'opal/fron/core_ext/kernel.rb', line 5

def requestAnimationFrame
  return unless block_given?
  return unless `!!window.requestAnimationFrame`
  `window.requestAnimationFrame(function(){ #{yield} })`
end

#timeout(ms = 0) ⇒ Object

Runs the given block after the given number of milliseconds.

Parameters:

  • ms (Integer) (defaults to: 0)

    The milliseconds


14
15
16
# File 'opal/fron/core_ext/kernel.rb', line 14

def timeout(ms = 0)
  `setTimeout(function(){#{yield}},#{ms})`
end