Sha256: e47c7cbf36c8feda4b71d470c80bf9c9d7c1496159a6bd3777a4baee3c58b384

Contents?: true

Size: 682 Bytes

Versions: 19

Compression:

Stored size: 682 Bytes

Contents

lastTime = 0
vendors = ['webkit', 'moz']

for vendor in vendors when !window.requestAnimationFrame
  window.requestAnimationFrame = window["#{vendor}RequestAnimationFrame"]
  window.cancelAnimationFrame = window["#{vendor}CancelAnimationFrame"] || window["#{vendor}CancelRequestAnimationFrame"];

unless window.requestAnimationFrame
  window.requestAnimationFrame = (callback, element) ->
    currTime = Date.now()
    timeToCall = Math.max(0, 16 - (currTime - lastTime))
    id = setTimeout ->
      callback(currTime + timeToCall)
    , timeToCall
    lastTime = currTime + timeToCall
    id

unless window.cancelAnimationFrame
  window.cancelAnimationFrame = window.clearTimeout

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 app/js/vendor/request_animation_frame.coffee
ela-4.1.5 app/js/vendor/request_animation_frame.coffee
ela-4.1.4 app/js/vendor/request_animation_frame.coffee
ela-4.1.3 app/js/vendor/request_animation_frame.coffee
ela-4.1.2 app/js/vendor/request_animation_frame.coffee
ela-4.1.1 app/js/vendor/request_animation_frame.coffee
ela-4.1.0 app/js/vendor/request_animation_frame.coffee
ela-4.0.0 app/js/vendor/request_animation_frame.coffee
ela-3.4.3 app/js/vendor/request_animation_frame.coffee
ela-3.4.2 app/js/vendor/request_animation_frame.coffee
ela-3.4.0 app/js/vendor/request_animation_frame.coffee
ela-3.3.1 app/js/vendor/request_animation_frame.coffee
ela-3.3.0 app/js/vendor/request_animation_frame.coffee
ela-3.2.0 app/js/vendor/request_animation_frame.coffee
ela-3.1.1 app/js/vendor/request_animation_frame.coffee
ela-3.1.0 app/js/vendor/request_animation_frame.coffee
ela-3.0.0 app/js/vendor/request_animation_frame.coffee
ela-2.0.0 app/js/vendor/request_animation_frame.coffee
ela-1.1.0 app/js/vendor/request_animation_frame.coffee