Repository URL to install this package:
|
Version:
1.2.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.raf = exports.requestAnimationFrame = requestAnimationFrame;
exports.default = void 0;
var _exotic = require("../../exotic");
const IS_BROWSER = typeof window === 'object';
const IS_TEST = process.env.NODE_ENV === 'test';
/**
* @type {window.requestAnimationFrame}
* @param {Function} fn
*
* @api https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions
* @tutorial http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
* @tutorial http://creativejs.com/resources/requestanimationframe/
* @see https://stackoverflow.com/questions/13076540/requestanimationframe-for-begining-a-css-transition
* @see https://www.npmjs.com/package/raf
* @see http://caniuse.com/#search=requestanimationframe
*
* and for transition events
* @polyfill https://gist.github.com/foolyoghurt/b76988ef05fbeaaf04ae
* @example https://codepen.io/MadeByMike/pen/sBjzn
* @example http://jsfiddle.net/RwtHn/5/
*/
function requestAnimationFrame(fn) {
if (IS_BROWSER && (0, _exotic.isFunction)(window.requestAnimationFrame)) {
window.requestAnimationFrame(fn);
} else {
setTimeout(fn, 4);
}
}
var _default = requestAnimationFrame;
exports.default = _default;