ant-design-vue
Version:
An enterprise-class UI design language and Vue-based implementation
42 lines (30 loc) • 2.17 kB
JavaScript
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.requestAnimationTimeout = exports.cancelAnimationTimeout = void 0;
var _getRequestAnimationFrame = _interopRequireWildcard(require("./getRequestAnimationFrame"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var raf = (0, _getRequestAnimationFrame.default)();
var cancelAnimationTimeout = function cancelAnimationTimeout(frame) {
return (0, _getRequestAnimationFrame.cancelRequestAnimationFrame)(frame.id);
};
exports.cancelAnimationTimeout = cancelAnimationTimeout;
var requestAnimationTimeout = function requestAnimationTimeout(callback) {
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var start = Date.now();
function timeout() {
if (Date.now() - start >= delay) {
callback.call();
} else {
frame.id = raf(timeout);
}
}
var frame = {
id: raf(timeout)
};
return frame;
};
exports.requestAnimationTimeout = requestAnimationTimeout;
;