animation-frame-polyfill
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.cancelAnimationFrame = exports.requestAnimationFrame = void 0; | ||
var prefix = ['webkit', 'moz', 'ms', 'o']; | ||
var requestAnimationFrame = exports.requestAnimationFrame = function () { | ||
var requestAnimationFrame = function () { | ||
for (var i = 0, limit = prefix.length; i < limit && !window.requestAnimationFrame; ++i) { | ||
@@ -16,17 +16,13 @@ window.requestAnimationFrame = window[prefix[i] + 'RequestAnimationFrame']; | ||
if (!window.requestAnimationFrame) { | ||
(function () { | ||
var lastTime = 0; | ||
var lastTime = 0; | ||
window.requestAnimationFrame = function (callback) { | ||
var now = new Date().getTime(); | ||
var ttc = Math.max(0, 16 - now - lastTime); | ||
var timer = window.setTimeout(function () { | ||
return callback(now + ttc); | ||
}, ttc); | ||
lastTime = now + ttc; | ||
return timer; | ||
}; | ||
})(); | ||
window.requestAnimationFrame = function (callback) { | ||
var now = new Date().getTime(); | ||
var ttc = Math.max(0, 16 - now - lastTime); | ||
var timer = window.setTimeout(function () { | ||
return callback(now + ttc); | ||
}, ttc); | ||
lastTime = now + ttc; | ||
return timer; | ||
}; | ||
} | ||
@@ -37,4 +33,5 @@ | ||
var cancelAnimationFrame = exports.cancelAnimationFrame = function () { | ||
exports.requestAnimationFrame = requestAnimationFrame; | ||
var cancelAnimationFrame = function () { | ||
for (var i = 0, limit = prefix.length; i < limit && !window.cancelAnimationFrame; ++i) { | ||
@@ -52,1 +49,3 @@ window.cancelAnimationFrame = window[prefix[i] + 'CancelAnimationFrame'] || window[prefix[i] + 'CancelRequestAnimationFrame']; | ||
}(); | ||
exports.cancelAnimationFrame = cancelAnimationFrame; |
var prefix = ['webkit', 'moz', 'ms', 'o']; | ||
export var requestAnimationFrame = function () { | ||
for (var i = 0, limit = prefix.length; i < limit && !window.requestAnimationFrame; ++i) { | ||
@@ -10,17 +8,13 @@ window.requestAnimationFrame = window[prefix[i] + 'RequestAnimationFrame']; | ||
if (!window.requestAnimationFrame) { | ||
(function () { | ||
var lastTime = 0; | ||
var lastTime = 0; | ||
window.requestAnimationFrame = function (callback) { | ||
var now = new Date().getTime(); | ||
var ttc = Math.max(0, 16 - now - lastTime); | ||
var timer = window.setTimeout(function () { | ||
return callback(now + ttc); | ||
}, ttc); | ||
lastTime = now + ttc; | ||
return timer; | ||
}; | ||
})(); | ||
window.requestAnimationFrame = function (callback) { | ||
var now = new Date().getTime(); | ||
var ttc = Math.max(0, 16 - now - lastTime); | ||
var timer = window.setTimeout(function () { | ||
return callback(now + ttc); | ||
}, ttc); | ||
lastTime = now + ttc; | ||
return timer; | ||
}; | ||
} | ||
@@ -30,5 +24,3 @@ | ||
}(); | ||
export var cancelAnimationFrame = function () { | ||
for (var i = 0, limit = prefix.length; i < limit && !window.cancelAnimationFrame; ++i) { | ||
@@ -35,0 +27,0 @@ window.cancelAnimationFrame = window[prefix[i] + 'CancelAnimationFrame'] || window[prefix[i] + 'CancelRequestAnimationFrame']; |
@@ -5,3 +5,3 @@ { | ||
"description": "Polyfill requestAnimationFrame and cancelAnimationFrame", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
@@ -32,3 +32,8 @@ "author": { | ||
"main": "lib/animation-frame-polyfill.cjs.js", | ||
"module": "lib/animation-frame-polyfill.module.js", | ||
"jsnext:main": "lib/animation-frame-polyfill.module.js", | ||
"browserslist": [ | ||
"IE 11", | ||
"last 3 versions" | ||
], | ||
"files": [ | ||
@@ -39,5 +44,7 @@ "lib/", | ||
"scripts": { | ||
"lint": "eslint -c eslint-config-webdeveric --fix src", | ||
"build:cjs": "babel src -o lib/animation-frame-polyfill.cjs.js --no-babelrc --presets es2015", | ||
"clean": "rimraf ./lib", | ||
"lint": "eslint --fix src", | ||
"build:cjs": "babel src -o lib/animation-frame-polyfill.cjs.js --no-babelrc --presets=@babel/preset-env", | ||
"build:module": "babel src -o lib/animation-frame-polyfill.module.js", | ||
"prebuild": "npm run clean", | ||
"build": "npm run build:cjs && npm run build:module", | ||
@@ -48,8 +55,11 @@ "prepublish": "npm run lint && npm run build" | ||
"devDependencies": { | ||
"babel-cli": "^6.0", | ||
"babel-eslint": "^7.0", | ||
"babel-preset-es2015": "^6.0", | ||
"eslint": "^3.0", | ||
"eslint-config-webdeveric": "^0.1.0" | ||
"@babel/cli": "^7.12.1", | ||
"@babel/core": "^7.12.3", | ||
"@babel/eslint-parser": "^7.12.1", | ||
"@babel/preset-env": "^7.12.1", | ||
"core-js": "^3.7.0", | ||
"eslint": "^7.13.0", | ||
"eslint-config-webdeveric": "^0.7.0", | ||
"rimraf": "^3.0.2" | ||
} | ||
} |
const prefix = [ 'webkit', 'moz', 'ms', 'o' ]; | ||
export const requestAnimationFrame = (() => { | ||
for ( let i = 0, limit = prefix.length ; i < limit && ! window.requestAnimationFrame ; ++i ) { | ||
@@ -27,3 +26,2 @@ window.requestAnimationFrame = window[ prefix[ i ] + 'RequestAnimationFrame' ]; | ||
export const cancelAnimationFrame = (() => { | ||
for ( let i = 0, limit = prefix.length ; i < limit && ! window.cancelAnimationFrame ; ++i ) { | ||
@@ -30,0 +28,0 @@ window.cancelAnimationFrame = window[ prefix[ i ] + 'CancelAnimationFrame' ] || window[ prefix[ i ] + 'CancelRequestAnimationFrame' ]; |
6777
6
8
95