@daybrush/utils
Advanced tools
Comparing version
@@ -24,1 +24,3 @@ import { ObjectInterface } from "./consts"; | ||
export declare function decamelize(str: string): string; | ||
export declare function now(): number; | ||
export declare const requestAnimationFrame: any; |
@@ -135,2 +135,17 @@ var prefixes = ["webkit", "ms", "moz", "o"]; | ||
} | ||
function now() { | ||
return Date.now ? Date.now() : new Date().getTime(); | ||
} | ||
var requestAnimationFrame = | ||
/*#__PURE__*/ | ||
function () { | ||
var firstTime = now(); | ||
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { | ||
var currTime = now(); | ||
var id = window.setTimeout(function () { | ||
callback(currTime - firstTime); | ||
}, 1000 / 60); | ||
return id; | ||
}; | ||
}(); | ||
@@ -343,3 +358,3 @@ /** | ||
export { COLOR_MODELS, cutHex, hexToRGBA, hex3to6, hslToRGBA, stringToRGBA, RGB, RGBA, HSL, HSLA, TRANSFORM, FILTER, ANIMATION, KEYFRAMES, isUndefined, isObject, isArray, isString, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, hasClass, addClass, removeClass, fromCSS }; | ||
export { COLOR_MODELS, cutHex, hexToRGBA, hex3to6, hslToRGBA, stringToRGBA, RGB, RGBA, HSL, HSLA, TRANSFORM, FILTER, ANIMATION, KEYFRAMES, isUndefined, isObject, isArray, isString, splitSpace, splitComma, splitBracket, splitUnit, camelize, decamelize, now, requestAnimationFrame, hasClass, addClass, removeClass, fromCSS }; | ||
//# sourceMappingURL=utils.esm.js.map |
@@ -139,2 +139,17 @@ 'use strict'; | ||
} | ||
function now() { | ||
return Date.now ? Date.now() : new Date().getTime(); | ||
} | ||
var requestAnimationFrame = | ||
/*#__PURE__*/ | ||
function () { | ||
var firstTime = now(); | ||
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) { | ||
var currTime = now(); | ||
var id = window.setTimeout(function () { | ||
callback(currTime - firstTime); | ||
}, 1000 / 60); | ||
return id; | ||
}; | ||
}(); | ||
@@ -371,2 +386,4 @@ /** | ||
exports.decamelize = decamelize; | ||
exports.now = now; | ||
exports.requestAnimationFrame = requestAnimationFrame; | ||
exports.hasClass = hasClass; | ||
@@ -373,0 +390,0 @@ exports.addClass = addClass; |
{ | ||
"name": "@daybrush/utils", | ||
"version": "0.0.5", | ||
"version": "0.1.0", | ||
"description": "utils for daybrush", | ||
@@ -5,0 +5,0 @@ "main": "dist/utils.js", |
@@ -80,1 +80,18 @@ import { ObjectInterface } from "./consts"; | ||
} | ||
export function now() { | ||
return Date.now ? Date.now() : new Date().getTime(); | ||
} | ||
export const requestAnimationFrame = /*#__PURE__*/(() => { | ||
const firstTime = now(); | ||
return (window as any).requestAnimationFrame || | ||
(window as any).webkitRequestAnimationFrame || | ||
(window as any).mozRequestAnimationFrame || | ||
((callback: (time: number) => void) => { | ||
const currTime = now(); | ||
const id = window.setTimeout(() => { | ||
callback(currTime - firstTime); | ||
}, 1000 / 60); | ||
return id; | ||
}); | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
68577
5.86%1148
4.55%