Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resizilla

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resizilla - npm Package Compare versions

Comparing version 0.5.1 to 0.5.3

2

bower.json
{
"name": "resizilla",
"version": "0.5.1",
"version": "0.5.3",
"description": "Window resize with debounce. e.g., window.resizilla(handler, delay, inception)",

@@ -5,0 +5,0 @@ "main": "resizilla.js",

{
"name": "resizilla",
"version": "0.5.1",
"version": "0.5.3",
"description": "Window resize with debounce. e.g., window.resizilla(handler, delay, inception)",

@@ -5,0 +5,0 @@ "main": "resizilla.js",

@@ -1,2 +0,2 @@

# resizilla v0.5
# resizilla v5
Window resize with debounce & requestAnimationFrame.

@@ -3,0 +3,0 @@

@@ -13,3 +13,3 @@ /* _.-~-.

/..\ /..\__/ ' '::: | _ < __/\__ \ |/ /| | | | (_| | ::'
vVVv vVVv ': |_| \_\___||___/_/___|_|_|_|\__,_| ''v0.3
vVVv vVVv ': |_| \_\___||___/_/___|_|_|_|\__,_| ''

@@ -32,223 +32,222 @@ Copyright (c) 2015 Julien Etienne. MIT License */

*/
function requestFrame
(type) {
// The only vendor prefixes required.
var vendors = ['moz', 'webkit'],
function requestFrame(type) {
// The only vendor prefixes required.
var vendors = ['moz', 'webkit'],
// Disassembled timing function abbreviations.
aF = 'AnimationFrame',
rqAF = 'Request' + aF,
// Disassembled timing function abbreviations.
aF = 'AnimationFrame',
rqAF = 'Request' + aF,
// Final assigned functions.
assignedRequestAnimationFrame,
assignedCancelAnimationFrame,
// Final assigned functions.
assignedRequestAnimationFrame,
assignedCancelAnimationFrame,
// Initial time of the timing lapse.
previousTime = 0,
// Initial time of the timing lapse.
previousTime = 0,
mozRAF = window.mozRequestAnimationFrame,
mozCAF = window.mozCancelAnimationFrame,
mozRAF = window.mozRequestAnimationFrame,
mozCAF = window.mozCancelAnimationFrame,
// Checks for firefox 4 - 10 function pair mismatch.
hasMozMismatch = mozRAF && !mozCAF,
// Checks for firefox 4 - 10 function pair mismatch.
hasMozMismatch = mozRAF && !mozCAF,
func;
func;
// Date.now polyfill, mainly for legacy IE versions.
if (!Date.now) {
Date.now = function() {
return new Date().getTime();
};
}
// Date.now polyfill, mainly for legacy IE versions.
if (!Date.now) {
Date.now = function() {
return new Date().getTime();
};
}
/**
* hasIOS6RequestAnimationFrameBug.
* @See {@Link https://gist.github.com/julienetie/86ac394ec41f1271ff0a}
* - for Commentary.
* @Copyright 2015 - Julien Etienne.
* @License: MIT.
*/
function hasIOS6RequestAnimationFrameBug() {
var webkitRAF = window.webkitRequestAnimationFrame,
rAF = window.requestAnimationFrame,
/**
* hasIOS6RequestAnimationFrameBug.
* @See {@Link https://gist.github.com/julienetie/86ac394ec41f1271ff0a}
* - for Commentary.
* @Copyright 2015 - Julien Etienne.
* @License: MIT.
*/
function hasIOS6RequestAnimationFrameBug() {
var webkitRAF = window.webkitRequestAnimationFrame,
rAF = window.requestAnimationFrame,
// CSS/ Device with max for iOS6 Devices.
hasMobileDeviceWidth = screen.width <= 768 ? true : false,
// CSS/ Device with max for iOS6 Devices.
hasMobileDeviceWidth = screen.width <= 768 ? true : false,
// Only supports webkit prefixed requestAnimtionFrane.
requiresWebkitprefix = !(webkitRAF && rAF),
// Only supports webkit prefixed requestAnimtionFrane.
requiresWebkitprefix = !(webkitRAF && rAF),
// iOS6 webkit browsers don't support performance now.
hasNoNavigationTiming = window.performance ? false : true,
// iOS6 webkit browsers don't support performance now.
hasNoNavigationTiming = window.performance ? false : true,
iOS6Notice = 'setTimeout is being used as a substitiue for' +
'requestAnimationFrame due to a bug within iOS 6 builds',
iOS6Notice = 'setTimeout is being used as a substitiue for' +
'requestAnimationFrame due to a bug within iOS 6 builds',
hasIOS6Bug = requiresWebkitprefix && hasMobileDeviceWidth &&
hasNoNavigationTiming;
hasIOS6Bug = requiresWebkitprefix && hasMobileDeviceWidth &&
hasNoNavigationTiming;
function bugCheckresults(timingFnA, timingFnB, notice) {
if (timingFnA || timingFnB) {
console.warn(notice);
return true;
} else {
return false;
}
}
function displayResults() {
if (hasIOS6Bug) {
return bugCheckresults(webkitRAF, rAF, iOS6Notice);
} else {
return false;
}
}
return displayResults();
function bugCheckresults(timingFnA, timingFnB, notice) {
if (timingFnA || timingFnB) {
console.warn(notice);
return true;
} else {
return false;
}
}
/**
* Native clearTimeout function.
* @return {Function}
*/
function clearTimeoutWithId() {
return clearTimeout;
function displayResults() {
if (hasIOS6Bug) {
return bugCheckresults(webkitRAF, rAF, iOS6Notice);
} else {
return false;
}
}
/**
* Based on a polyfill by Erik, introduced by Paul Irish &
* further improved by Darius Bacon.
* @see {@link http://www.paulirish.com/2011/
* requestanimationframe-for-smart-animating}
* @see {@link https://github.com/darius/requestAnimationFrame/blob/
* master/requestAnimationFrame.js}
* @callback {Number} Timestamp.
* @return {Function} setTimeout Function.
*/
function setTimeoutWithTimestamp(callback) {
var immediateTime = Date.now(),
lapsedTime = Math.max(previousTime + 16, immediateTime);
return setTimeout(function() {
callback(previousTime = lapsedTime);
},
lapsedTime - immediateTime);
}
return displayResults();
}
/**
* Queries the native function, prefixed function
* or use the setTimeoutWithTimestamp function.
* @return {Function}
*/
function queryRequestAnimationFrame() {
if (Array.prototype.filter) {
assignedRequestAnimationFrame = window['request' + aF] ||
window[vendors.filter(function(vendor) {
if (window[vendor + rqAF] !== undefined)
return vendor;
}) + rqAF] || setTimeoutWithTimestamp;
} else {
return setTimeoutWithTimestamp;
}
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedRequestAnimationFrame;
} else {
return setTimeoutWithTimestamp;
}
}
/**
* Native clearTimeout function.
* @return {Function}
*/
function clearTimeoutWithId(id) {
clearTimeout(id);
}
/**
* Queries the native function, prefixed function
* or use the clearTimeoutWithId function.
* @return {Function}
*/
function queryCancelAnimationFrame() {
var cancellationNames = [];
if (Array.prototype.map) {
vendors.map(function(vendor) {
return ['Cancel', 'CancelRequest'].map(
function(cancellationNamePrefix) {
cancellationNames.push(vendor +
cancellationNamePrefix + aF);
});
});
} else {
return clearTimeoutWithId;
}
/**
* Based on a polyfill by Erik, introduced by Paul Irish &
* further improved by Darius Bacon.
* @see {@link http://www.paulirish.com/2011/
* requestanimationframe-for-smart-animating}
* @see {@link https://github.com/darius/requestAnimationFrame/blob/
* master/requestAnimationFrame.js}
* @callback {Number} Timestamp.
* @return {Function} setTimeout Function.
*/
function setTimeoutWithTimestamp(callback) {
var immediateTime = Date.now(),
lapsedTime = Math.max(previousTime + 16, immediateTime);
return setTimeout(function() {
callback(previousTime = lapsedTime);
},
lapsedTime - immediateTime);
}
/**
* Checks for the prefixed cancelAnimationFrame implementation.
* @param {Array} prefixedNames - An array of the prefixed names.
* @param {Number} i - Iteration start point.
* @return {Function} prefixed cancelAnimationFrame function.
*/
function prefixedCancelAnimationFrame(prefixedNames, i) {
var cancellationFunction;
for (; i < prefixedNames.length; i++) {
if (window[prefixedNames[i]]) {
cancellationFunction = window[prefixedNames[i]];
break;
}
}
return cancellationFunction;
}
/**
* Queries the native function, prefixed function
* or use the setTimeoutWithTimestamp function.
* @return {Function}
*/
function queryRequestAnimationFrame() {
if (Array.prototype.filter) {
assignedRequestAnimationFrame = window['request' + aF] ||
window[vendors.filter(function(vendor) {
if (window[vendor + rqAF] !== undefined)
return vendor;
}) + rqAF] || setTimeoutWithTimestamp;
} else {
return setTimeoutWithTimestamp;
}
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedRequestAnimationFrame;
} else {
return setTimeoutWithTimestamp;
}
}
// Use truthly function
assignedCancelAnimationFrame = window['cancel' + aF] ||
prefixedCancelAnimationFrame(cancellationNames, 0) ||
clearTimeoutWithId;
/**
* Queries the native function, prefixed function
* or use the clearTimeoutWithId function.
* @return {Function}
*/
function queryCancelAnimationFrame() {
var cancellationNames = [];
if (Array.prototype.map) {
vendors.map(function(vendor) {
return ['Cancel', 'CancelRequest'].map(
function(cancellationNamePrefix) {
cancellationNames.push(vendor +
cancellationNamePrefix + aF);
});
});
} else {
return clearTimeoutWithId;
}
// Check for iOS 6 bug
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedCancelAnimationFrame;
} else {
return clearTimeoutWithId;
/**
* Checks for the prefixed cancelAnimationFrame implementation.
* @param {Array} prefixedNames - An array of the prefixed names.
* @param {Number} i - Iteration start point.
* @return {Function} prefixed cancelAnimationFrame function.
*/
function prefixedCancelAnimationFrame(prefixedNames, i) {
var cancellationFunction;
for (; i < prefixedNames.length; i++) {
if (window[prefixedNames[i]]) {
cancellationFunction = window[prefixedNames[i]];
break;
}
}
return cancellationFunction;
}
function getRequestFn() {
if (hasMozMismatch) {
return setTimeoutWithTimestamp;
} else {
return queryRequestAnimationFrame();
}
}
// Use truthly function
assignedCancelAnimationFrame = window['cancel' + aF] ||
prefixedCancelAnimationFrame(cancellationNames, 0) ||
clearTimeoutWithId;
function getCancelFn() {
return queryCancelAnimationFrame();
}
// Check for iOS 6 bug
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedCancelAnimationFrame;
} else {
return clearTimeoutWithId;
}
}
function setNativeFn() {
if (hasMozMismatch) {
window.requestAnimationFrame = setTimeoutWithTimestamp;
window.cancelAnimationFrame = clearTimeoutWithId;
} else {
window.requestAnimationFrame = queryRequestAnimationFrame();
window.cancelAnimationFrame = queryCancelAnimationFrame();
}
}
function getRequestFn() {
if (hasMozMismatch) {
return setTimeoutWithTimestamp;
} else {
return queryRequestAnimationFrame();
}
}
/**
* The type value "request" singles out firefox 4 - 10 and
* assigns the setTimeout function if plausible.
*/
function getCancelFn() {
return queryCancelAnimationFrame();
}
switch (type) {
case 'request':
case '':
func = getRequestFn();
break;
function setNativeFn() {
if (hasMozMismatch) {
window.requestAnimationFrame = setTimeoutWithTimestamp;
window.cancelAnimationFrame = clearTimeoutWithId;
} else {
window.requestAnimationFrame = queryRequestAnimationFrame();
window.cancelAnimationFrame = queryCancelAnimationFrame();
}
}
case 'cancel':
func = getCancelFn();
break;
/**
* The type value "request" singles out firefox 4 - 10 and
* assigns the setTimeout function if plausible.
*/
case 'native':
setNativeFn();
break;
default:
throw new Error('RequestFrame parameter is not a type.');
}
return func;
}
switch (type) {
case 'request':
case '':
func = getRequestFn();
break;
case 'cancel':
func = getCancelFn();
break;
case 'native':
setNativeFn();
break;
default:
throw new Error('RequestFrame parameter is not a type.');
}
return func;
}
var request = requestFrame('request');

@@ -255,0 +254,0 @@ var cancel = requestFrame('cancel');

@@ -1,1 +0,1 @@

!function(n){function e(){return Date.now()||(new Date).getTime()}function t(n){function e(){function n(n,e,t){return n||e?(console.warn(t),!0):!1}function e(){return c?n(t,i,u):!1}var t=window.webkitRequestAnimationFrame,i=window.requestAnimationFrame,r=screen.width<=768?!0:!1,a=!(t&&i),o=window.performance?!1:!0,u="setTimeout is being used as a substitiue forrequestAnimationFrame due to a bug within iOS 6 builds",c=a&&r&&o;return e()}function t(){return clearTimeout}function i(n){var e=Date.now(),t=Math.max(h+16,e);return setTimeout(function(){n(h=t)},t-e)}function r(){return Array.prototype.filter?(s=window["request"+f]||window[l.filter(function(n){return void 0!==window[n+d]?n:void 0})+d]||i,e()?i:s):i}function a(){function n(n,e){for(var t;e<n.length;e++)if(window[n[e]]){t=window[n[e]];break}return t}var i=[];return Array.prototype.map?(l.map(function(n){return["Cancel","CancelRequest"].map(function(e){i.push(n+e+f)})}),w=window["cancel"+f]||n(i,0)||t,e()?t:w):t}function o(){return b?i:r()}function u(){return a()}function c(){b?(window.requestAnimationFrame=i,window.cancelAnimationFrame=t):(window.requestAnimationFrame=r(),window.cancelAnimationFrame=a())}var s,w,m,l=["moz","webkit"],f="AnimationFrame",d="Request"+f,h=0,v=window.mozRequestAnimationFrame,p=window.mozCancelAnimationFrame,b=v&&!p;switch(Date.now||(Date.now=function(){return(new Date).getTime()}),n){case"request":case"":m=o();break;case"cancel":m=u();break;case"native":c();break;default:throw new Error("RequestFrame parameter is not a type.")}return m}var i=t("request"),r=t("cancel"),a=function(n,t){function r(n){return this.k=this.k?null:n,this.k+=1}function a(){this.delta=e()-o,this.callHandler=this.delta>=t?n.call():i(a)}var o=e();return i(a),r(0)};n.resizilla=function(n,e,t){function i(){var i;return function(){var o=this,u=arguments,c=function(){i=0,t||n.apply(o,u)};this.instant=t&&!i,r(i),i=a(c,e),this.instant&&n.apply(o,u)}}var o=i(arguments),u=function(n){this.addEventListener?this.addEventListener("resize",n,!0):this.attachEvent("onresize",n)};(screen.width>1023||this.mobile)&&u.call(this,o)},resizilla.enableMobileResize=function(){n.mobile=!0}}(window);
!function(n){function e(){return Date.now()||(new Date).getTime()}function t(n){function e(){function n(n,e,t){return n||e?(console.warn(t),!0):!1}function e(){return c?n(t,i,u):!1}var t=window.webkitRequestAnimationFrame,i=window.requestAnimationFrame,r=screen.width<=768?!0:!1,a=!(t&&i),o=window.performance?!1:!0,u="setTimeout is being used as a substitiue forrequestAnimationFrame due to a bug within iOS 6 builds",c=a&&r&&o;return e()}function t(n){clearTimeout(n)}function i(n){var e=Date.now(),t=Math.max(h+16,e);return setTimeout(function(){n(h=t)},t-e)}function r(){return Array.prototype.filter?(s=window["request"+f]||window[l.filter(function(n){return void 0!==window[n+d]?n:void 0})+d]||i,e()?i:s):i}function a(){function n(n,e){for(var t;e<n.length;e++)if(window[n[e]]){t=window[n[e]];break}return t}var i=[];return Array.prototype.map?(l.map(function(n){return["Cancel","CancelRequest"].map(function(e){i.push(n+e+f)})}),w=window["cancel"+f]||n(i,0)||t,e()?t:w):t}function o(){return b?i:r()}function u(){return a()}function c(){b?(window.requestAnimationFrame=i,window.cancelAnimationFrame=t):(window.requestAnimationFrame=r(),window.cancelAnimationFrame=a())}var s,w,m,l=["moz","webkit"],f="AnimationFrame",d="Request"+f,h=0,v=window.mozRequestAnimationFrame,p=window.mozCancelAnimationFrame,b=v&&!p;switch(Date.now||(Date.now=function(){return(new Date).getTime()}),n){case"request":case"":m=o();break;case"cancel":m=u();break;case"native":c();break;default:throw new Error("RequestFrame parameter is not a type.")}return m}var i=t("request"),r=t("cancel"),a=function(n,t){function r(n){return this.k=this.k?null:n,this.k+=1}function a(){this.delta=e()-o,this.callHandler=this.delta>=t?n.call():i(a)}var o=e();return i(a),r(0)};n.resizilla=function(n,e,t){function i(){var i;return function(){var o=this,u=arguments,c=function(){i=0,t||n.apply(o,u)};this.instant=t&&!i,r(i),i=a(c,e),this.instant&&n.apply(o,u)}}var o=i(arguments),u=function(n){this.addEventListener?this.addEventListener("resize",n,!0):this.attachEvent("onresize",n)};(screen.width>1023||this.mobile)&&u.call(this,o)},resizilla.enableMobileResize=function(){n.mobile=!0}}(window);

@@ -31,223 +31,222 @@ /* _.-~-.

*/
function requestFrame
(type) {
// The only vendor prefixes required.
var vendors = ['moz', 'webkit'],
function requestFrame(type) {
// The only vendor prefixes required.
var vendors = ['moz', 'webkit'],
// Disassembled timing function abbreviations.
aF = 'AnimationFrame',
rqAF = 'Request' + aF,
// Disassembled timing function abbreviations.
aF = 'AnimationFrame',
rqAF = 'Request' + aF,
// Final assigned functions.
assignedRequestAnimationFrame,
assignedCancelAnimationFrame,
// Final assigned functions.
assignedRequestAnimationFrame,
assignedCancelAnimationFrame,
// Initial time of the timing lapse.
previousTime = 0,
// Initial time of the timing lapse.
previousTime = 0,
mozRAF = window.mozRequestAnimationFrame,
mozCAF = window.mozCancelAnimationFrame,
mozRAF = window.mozRequestAnimationFrame,
mozCAF = window.mozCancelAnimationFrame,
// Checks for firefox 4 - 10 function pair mismatch.
hasMozMismatch = mozRAF && !mozCAF,
// Checks for firefox 4 - 10 function pair mismatch.
hasMozMismatch = mozRAF && !mozCAF,
func;
func;
// Date.now polyfill, mainly for legacy IE versions.
if (!Date.now) {
Date.now = function() {
return new Date().getTime();
};
}
// Date.now polyfill, mainly for legacy IE versions.
if (!Date.now) {
Date.now = function() {
return new Date().getTime();
};
}
/**
* hasIOS6RequestAnimationFrameBug.
* @See {@Link https://gist.github.com/julienetie/86ac394ec41f1271ff0a}
* - for Commentary.
* @Copyright 2015 - Julien Etienne.
* @License: MIT.
*/
function hasIOS6RequestAnimationFrameBug() {
var webkitRAF = window.webkitRequestAnimationFrame,
rAF = window.requestAnimationFrame,
/**
* hasIOS6RequestAnimationFrameBug.
* @See {@Link https://gist.github.com/julienetie/86ac394ec41f1271ff0a}
* - for Commentary.
* @Copyright 2015 - Julien Etienne.
* @License: MIT.
*/
function hasIOS6RequestAnimationFrameBug() {
var webkitRAF = window.webkitRequestAnimationFrame,
rAF = window.requestAnimationFrame,
// CSS/ Device with max for iOS6 Devices.
hasMobileDeviceWidth = screen.width <= 768 ? true : false,
// CSS/ Device with max for iOS6 Devices.
hasMobileDeviceWidth = screen.width <= 768 ? true : false,
// Only supports webkit prefixed requestAnimtionFrane.
requiresWebkitprefix = !(webkitRAF && rAF),
// Only supports webkit prefixed requestAnimtionFrane.
requiresWebkitprefix = !(webkitRAF && rAF),
// iOS6 webkit browsers don't support performance now.
hasNoNavigationTiming = window.performance ? false : true,
// iOS6 webkit browsers don't support performance now.
hasNoNavigationTiming = window.performance ? false : true,
iOS6Notice = 'setTimeout is being used as a substitiue for' +
'requestAnimationFrame due to a bug within iOS 6 builds',
iOS6Notice = 'setTimeout is being used as a substitiue for' +
'requestAnimationFrame due to a bug within iOS 6 builds',
hasIOS6Bug = requiresWebkitprefix && hasMobileDeviceWidth &&
hasNoNavigationTiming;
hasIOS6Bug = requiresWebkitprefix && hasMobileDeviceWidth &&
hasNoNavigationTiming;
function bugCheckresults(timingFnA, timingFnB, notice) {
if (timingFnA || timingFnB) {
console.warn(notice);
return true;
} else {
return false;
}
}
function displayResults() {
if (hasIOS6Bug) {
return bugCheckresults(webkitRAF, rAF, iOS6Notice);
} else {
return false;
}
}
return displayResults();
function bugCheckresults(timingFnA, timingFnB, notice) {
if (timingFnA || timingFnB) {
console.warn(notice);
return true;
} else {
return false;
}
}
/**
* Native clearTimeout function.
* @return {Function}
*/
function clearTimeoutWithId() {
return clearTimeout;
function displayResults() {
if (hasIOS6Bug) {
return bugCheckresults(webkitRAF, rAF, iOS6Notice);
} else {
return false;
}
}
/**
* Based on a polyfill by Erik, introduced by Paul Irish &
* further improved by Darius Bacon.
* @see {@link http://www.paulirish.com/2011/
* requestanimationframe-for-smart-animating}
* @see {@link https://github.com/darius/requestAnimationFrame/blob/
* master/requestAnimationFrame.js}
* @callback {Number} Timestamp.
* @return {Function} setTimeout Function.
*/
function setTimeoutWithTimestamp(callback) {
var immediateTime = Date.now(),
lapsedTime = Math.max(previousTime + 16, immediateTime);
return setTimeout(function() {
callback(previousTime = lapsedTime);
},
lapsedTime - immediateTime);
}
return displayResults();
}
/**
* Queries the native function, prefixed function
* or use the setTimeoutWithTimestamp function.
* @return {Function}
*/
function queryRequestAnimationFrame() {
if (Array.prototype.filter) {
assignedRequestAnimationFrame = window['request' + aF] ||
window[vendors.filter(function(vendor) {
if (window[vendor + rqAF] !== undefined)
return vendor;
}) + rqAF] || setTimeoutWithTimestamp;
} else {
return setTimeoutWithTimestamp;
}
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedRequestAnimationFrame;
} else {
return setTimeoutWithTimestamp;
}
}
/**
* Native clearTimeout function.
* @return {Function}
*/
function clearTimeoutWithId(id) {
clearTimeout(id);
}
/**
* Queries the native function, prefixed function
* or use the clearTimeoutWithId function.
* @return {Function}
*/
function queryCancelAnimationFrame() {
var cancellationNames = [];
if (Array.prototype.map) {
vendors.map(function(vendor) {
return ['Cancel', 'CancelRequest'].map(
function(cancellationNamePrefix) {
cancellationNames.push(vendor +
cancellationNamePrefix + aF);
});
});
} else {
return clearTimeoutWithId;
}
/**
* Based on a polyfill by Erik, introduced by Paul Irish &
* further improved by Darius Bacon.
* @see {@link http://www.paulirish.com/2011/
* requestanimationframe-for-smart-animating}
* @see {@link https://github.com/darius/requestAnimationFrame/blob/
* master/requestAnimationFrame.js}
* @callback {Number} Timestamp.
* @return {Function} setTimeout Function.
*/
function setTimeoutWithTimestamp(callback) {
var immediateTime = Date.now(),
lapsedTime = Math.max(previousTime + 16, immediateTime);
return setTimeout(function() {
callback(previousTime = lapsedTime);
},
lapsedTime - immediateTime);
}
/**
* Checks for the prefixed cancelAnimationFrame implementation.
* @param {Array} prefixedNames - An array of the prefixed names.
* @param {Number} i - Iteration start point.
* @return {Function} prefixed cancelAnimationFrame function.
*/
function prefixedCancelAnimationFrame(prefixedNames, i) {
var cancellationFunction;
for (; i < prefixedNames.length; i++) {
if (window[prefixedNames[i]]) {
cancellationFunction = window[prefixedNames[i]];
break;
}
}
return cancellationFunction;
}
/**
* Queries the native function, prefixed function
* or use the setTimeoutWithTimestamp function.
* @return {Function}
*/
function queryRequestAnimationFrame() {
if (Array.prototype.filter) {
assignedRequestAnimationFrame = window['request' + aF] ||
window[vendors.filter(function(vendor) {
if (window[vendor + rqAF] !== undefined)
return vendor;
}) + rqAF] || setTimeoutWithTimestamp;
} else {
return setTimeoutWithTimestamp;
}
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedRequestAnimationFrame;
} else {
return setTimeoutWithTimestamp;
}
}
// Use truthly function
assignedCancelAnimationFrame = window['cancel' + aF] ||
prefixedCancelAnimationFrame(cancellationNames, 0) ||
clearTimeoutWithId;
/**
* Queries the native function, prefixed function
* or use the clearTimeoutWithId function.
* @return {Function}
*/
function queryCancelAnimationFrame() {
var cancellationNames = [];
if (Array.prototype.map) {
vendors.map(function(vendor) {
return ['Cancel', 'CancelRequest'].map(
function(cancellationNamePrefix) {
cancellationNames.push(vendor +
cancellationNamePrefix + aF);
});
});
} else {
return clearTimeoutWithId;
}
// Check for iOS 6 bug
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedCancelAnimationFrame;
} else {
return clearTimeoutWithId;
/**
* Checks for the prefixed cancelAnimationFrame implementation.
* @param {Array} prefixedNames - An array of the prefixed names.
* @param {Number} i - Iteration start point.
* @return {Function} prefixed cancelAnimationFrame function.
*/
function prefixedCancelAnimationFrame(prefixedNames, i) {
var cancellationFunction;
for (; i < prefixedNames.length; i++) {
if (window[prefixedNames[i]]) {
cancellationFunction = window[prefixedNames[i]];
break;
}
}
return cancellationFunction;
}
function getRequestFn() {
if (hasMozMismatch) {
return setTimeoutWithTimestamp;
} else {
return queryRequestAnimationFrame();
}
}
// Use truthly function
assignedCancelAnimationFrame = window['cancel' + aF] ||
prefixedCancelAnimationFrame(cancellationNames, 0) ||
clearTimeoutWithId;
function getCancelFn() {
return queryCancelAnimationFrame();
}
// Check for iOS 6 bug
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedCancelAnimationFrame;
} else {
return clearTimeoutWithId;
}
}
function setNativeFn() {
if (hasMozMismatch) {
window.requestAnimationFrame = setTimeoutWithTimestamp;
window.cancelAnimationFrame = clearTimeoutWithId;
} else {
window.requestAnimationFrame = queryRequestAnimationFrame();
window.cancelAnimationFrame = queryCancelAnimationFrame();
}
}
function getRequestFn() {
if (hasMozMismatch) {
return setTimeoutWithTimestamp;
} else {
return queryRequestAnimationFrame();
}
}
/**
* The type value "request" singles out firefox 4 - 10 and
* assigns the setTimeout function if plausible.
*/
function getCancelFn() {
return queryCancelAnimationFrame();
}
switch (type) {
case 'request':
case '':
func = getRequestFn();
break;
function setNativeFn() {
if (hasMozMismatch) {
window.requestAnimationFrame = setTimeoutWithTimestamp;
window.cancelAnimationFrame = clearTimeoutWithId;
} else {
window.requestAnimationFrame = queryRequestAnimationFrame();
window.cancelAnimationFrame = queryCancelAnimationFrame();
}
}
case 'cancel':
func = getCancelFn();
break;
/**
* The type value "request" singles out firefox 4 - 10 and
* assigns the setTimeout function if plausible.
*/
case 'native':
setNativeFn();
break;
default:
throw new Error('RequestFrame parameter is not a type.');
}
return func;
}
switch (type) {
case 'request':
case '':
func = getRequestFn();
break;
case 'cancel':
func = getCancelFn();
break;
case 'native':
setNativeFn();
break;
default:
throw new Error('RequestFrame parameter is not a type.');
}
return func;
}
var request = requestFrame('request');

@@ -254,0 +253,0 @@ var cancel = requestFrame('cancel');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc