anim-event
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -9,6 +9,5 @@ /* ================================================ | ||
* | ||
* Copyright (c) 2018 anseki | ||
* Copyright (c) 2021 anseki | ||
* Licensed under the MIT license. | ||
*/ | ||
var MSPF = 1000 / 60, | ||
@@ -18,3 +17,2 @@ // ms/frame (FPS: 60) | ||
/** | ||
@@ -28,6 +26,6 @@ * @typedef {Object} task | ||
tasks = []; | ||
/* [DEBUG/] | ||
const | ||
[DEBUG/] */ | ||
var // [DEBUG/] | ||
@@ -42,7 +40,7 @@ requestAnim = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { | ||
var lastFrameTime = Date.now(), | ||
requestID = void 0; | ||
requestID; // [DEBUG] | ||
// [DEBUG] | ||
var requestAnimSave = requestAnim, | ||
cancelAnimSave = cancelAnim; | ||
window.AnimEventByTimer = function (byTimer) { | ||
@@ -53,2 +51,3 @@ if (byTimer) { | ||
}; | ||
cancelAnim = function cancelAnim(requestID) { | ||
@@ -61,8 +60,7 @@ return clearTimeout(requestID); | ||
} | ||
}; | ||
// [/DEBUG] | ||
}; // [/DEBUG] | ||
function step() { | ||
var called = void 0, | ||
next = void 0; | ||
var called, next; | ||
@@ -75,5 +73,7 @@ if (requestID) { | ||
tasks.forEach(function (task) { | ||
var event = void 0; | ||
var event; | ||
if (event = task.event) { | ||
task.event = null; // Clear it before `task.listener()` because that might fire another event. | ||
task.listener(event); | ||
@@ -91,2 +91,3 @@ called = true; | ||
} | ||
if (next) { | ||
@@ -104,2 +105,3 @@ requestID = requestAnim.call(window, step); | ||
} | ||
return false; | ||
@@ -116,7 +118,11 @@ }); | ||
add: function add(listener) { | ||
var task = void 0; | ||
var task; | ||
if (indexOfTasks(listener) === -1) { | ||
tasks.push(task = { listener: listener }); | ||
tasks.push(task = { | ||
listener: listener | ||
}); | ||
return function (event) { | ||
task.event = event; | ||
if (!requestID) { | ||
@@ -127,8 +133,11 @@ step(); | ||
} | ||
return null; | ||
}, | ||
remove: function remove(listener) { | ||
var iRemove = void 0; | ||
var iRemove; | ||
if ((iRemove = indexOfTasks(listener)) > -1) { | ||
tasks.splice(iRemove, 1); | ||
if (!tasks.length && requestID) { | ||
@@ -141,3 +150,2 @@ cancelAnim.call(window, requestID); | ||
}; | ||
export default AnimEvent; |
@@ -9,6 +9,5 @@ /* ================================================ | ||
* | ||
* Copyright (c) 2018 anseki | ||
* Copyright (c) 2021 anseki | ||
* Licensed under the MIT license. | ||
*/ | ||
var MSPF = 1000 / 60, | ||
@@ -18,3 +17,2 @@ // ms/frame (FPS: 60) | ||
/** | ||
@@ -37,7 +35,6 @@ * @typedef {Object} task | ||
var lastFrameTime = Date.now(), | ||
requestID = void 0; | ||
requestID; | ||
function step() { | ||
var called = void 0, | ||
next = void 0; | ||
var called, next; | ||
@@ -50,5 +47,7 @@ if (requestID) { | ||
tasks.forEach(function (task) { | ||
var event = void 0; | ||
var event; | ||
if (event = task.event) { | ||
task.event = null; // Clear it before `task.listener()` because that might fire another event. | ||
task.listener(event); | ||
@@ -66,2 +65,3 @@ called = true; | ||
} | ||
if (next) { | ||
@@ -79,2 +79,3 @@ requestID = requestAnim.call(window, step); | ||
} | ||
return false; | ||
@@ -91,7 +92,11 @@ }); | ||
add: function add(listener) { | ||
var task = void 0; | ||
var task; | ||
if (indexOfTasks(listener) === -1) { | ||
tasks.push(task = { listener: listener }); | ||
tasks.push(task = { | ||
listener: listener | ||
}); | ||
return function (event) { | ||
task.event = event; | ||
if (!requestID) { | ||
@@ -102,8 +107,11 @@ step(); | ||
} | ||
return null; | ||
}, | ||
remove: function remove(listener) { | ||
var iRemove = void 0; | ||
var iRemove; | ||
if ((iRemove = indexOfTasks(listener)) > -1) { | ||
tasks.splice(iRemove, 1); | ||
if (!tasks.length && requestID) { | ||
@@ -116,3 +124,2 @@ cancelAnim.call(window, requestID); | ||
}; | ||
export default AnimEvent; |
@@ -1,2 +0,2 @@ | ||
/*! AnimEvent v1.0.16 (c) anseki https://github.com/anseki/anim-event */ | ||
var AnimEvent=function(n){var e={};function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(r,o,function(e){return n[e]}.bind(null,o));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r=500,o=[],i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(n){return setTimeout(n,1e3/60)},u=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||function(n){return clearTimeout(n)},a=Date.now(),l=void 0;function c(){var n=void 0,e=void 0;l&&(u.call(window,l),l=null),o.forEach(function(e){var t;(t=e.event)&&(e.event=null,e.listener(t),n=!0)}),n?(a=Date.now(),e=!0):Date.now()-a<r&&(e=!0),e&&(l=i.call(window,c))}function f(n){var e=-1;return o.some(function(t,r){return t.listener===n&&(e=r,!0)}),e}var d={add:function(n){var e=void 0;return-1===f(n)?(o.push(e={listener:n}),function(n){e.event=n,l||c()}):null},remove:function(n){var e;(e=f(n))>-1&&(o.splice(e,1),!o.length&&l&&(u.call(window,l),l=null))}};e.default=d}]).default; | ||
/*! AnimEvent v1.0.17 (c) anseki https://github.com/anseki/anim-event */ | ||
var AnimEvent=function(n){var e={};function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(r,o,function(e){return n[e]}.bind(null,o));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r,o=[],i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(n){return setTimeout(n,1e3/60)},u=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||function(n){return clearTimeout(n)},a=Date.now();function l(){var n,e;r&&(u.call(window,r),r=null),o.forEach((function(e){var t;(t=e.event)&&(e.event=null,e.listener(t),n=!0)})),n?(a=Date.now(),e=!0):Date.now()-a<500&&(e=!0),e&&(r=i.call(window,l))}function c(n){var e=-1;return o.some((function(t,r){return t.listener===n&&(e=r,!0)})),e}var f={add:function(n){var e;return-1===c(n)?(o.push(e={listener:n}),function(n){e.event=n,r||l()}):null},remove:function(n){var e;(e=c(n))>-1&&(o.splice(e,1),!o.length&&r&&(u.call(window,r),r=null))}};e.default=f}]).default; |
{ | ||
"name": "anim-event", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "Event Manager for Animation", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
{ | ||
"name": "anim-event", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"title": "AnimEvent", | ||
@@ -26,11 +26,11 @@ "description": "Event Manager for Animation", | ||
"devDependencies": { | ||
"babel-core": "^6.26.3", | ||
"babel-loader": "^7.1.4", | ||
"babel-preset-es2015": "^6.24.1", | ||
"cross-env": "^5.1.6", | ||
"@babel/core": "^7.14.3", | ||
"@babel/preset-env": "^7.14.2", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-loader": "^7.1.5", | ||
"cross-env": "^7.0.3", | ||
"pre-proc": "^1.0.2", | ||
"pre-proc-loader": "^3.0.3", | ||
"skeleton-loader": "^2.0.0", | ||
"webpack": "^4.10.2", | ||
"webpack-cli": "^2.1.4" | ||
"webpack": "^4.46.0", | ||
"webpack-cli": "^3.3.12" | ||
}, | ||
@@ -37,0 +37,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
13006