How to use raf

Comprehensive raf code examples:

How to use raf.call:

863
864
865
866
867
868
869
870
871
872
873


module.exports = function(fn) {
  // Wrap in a new function to prevent
  // `cancel` potentially being assigned
  // to the native rAF function
  return raf.call(root, fn)
}
module.exports.cancel = function() {
  caf.apply(root, arguments)
}

How to use raf.cancel:

377
378
379
380
381
382
383
384
385
386
  } else {
    window.removeEventListener('mousemove', this.onMouseMove)
  }

  window.removeEventListener('resize', this.onWindowResize)
  rqAnFr.cancel(this.raf)
}

calibrate(x, y) {
  this.calibrateX = x === undefined ? this.calibrateX : x