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.6.2 to 0.6.3

bump.js

621

dist/resizilla.js

@@ -0,379 +1,314 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.resizilla = factory());
}(this, (function () { 'use strict';
var version = '0.6.2';
/**
* resizilla
* Version: 0.6.0
* License: MIT
* Copyright Julien Etienne 2015 - 2016 All Rights Reserved.
* github: https://github.com/julienetie/resizilla
*‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
* volve - Tiny, Performant Debounce and Throttle Functions,
* License: MIT
* Copyright Julien Etienne 2016 All Rights Reserved.
* github: https://github.com/julienetie/volve
*‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
*/
/* _.-~-.
7'' Q..\
_7 (_
_7 _/ _q. /
_7 . ___ /VVvv-'_ .
7/ / /~- \_\\ '-._ .-' / //
./ ( /-~-/ ||'=.__ '::. '-~'' { ___ / // ./{
V V-~-~| || __''_ ':::. ''~-~.___.-'' _/ // / {_ / { /
VV/-~-~-| / \ .'__'. '. ':: ____ _ _ _ ''.
/ /~~~~|| VVV/ / \ ) \ | _ \ ___ ___(_)___(_) | | __ _ .::'
/ (~-~-~\\.-' / \' \::::. | |_) / _ \/ __| |_ / | | |/ _` | :::'
/..\ /..\__/ ' '::: | _ < __/\__ \ |/ /| | | | (_| | ::'
vVVv vVVv ': |_| \_\___||___/_/___|_|_|_|\__,_| ''
Copyright (c) 2015 Julien Etienne. MIT License */
(function (window) {
/**
* Date.now polyfill.
* {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/now}
*/
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
/**
* Debounce a function call during repetiton.
* @param {Function} callback - Callback function.
* @param {Number} delay - Delay in milliseconds.
* @param {Boolean} lead - Leading or trailing.
* @return {Function} - The debounce function.
*/
function debounce(callback, delay, lead) {
var debounceRange = 0;
var currentTime;
var lastCall;
var setDelay;
var timeoutId;
/*! A fix for the iOS orientationchange zoom bug.
Script by @scottjehl, rebound by @wilto.
MIT / GPLv2 License.
*/
(function(w){
// This fix addresses an iOS bug, so return early if the UA claims it's something else.
var ua = navigator.userAgent;
if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf( "AppleWebKit" ) > -1 ) ){
return;
}
var call = function call(parameters) {
callback(parameters);
};
var doc = w.document;
return function (parameters) {
if (lead) {
currentTime = Date.now();
if (currentTime > debounceRange) {
callback(parameters);
}
debounceRange = currentTime + delay;
} else {
/**
* setTimeout is only used with the trail option.
*/
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
call(parameters);
}, delay);
}
};
}
if( !doc.querySelector ){ return; }
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var meta = doc.querySelector( "meta[name=viewport]" ),
initialContent = meta && meta.getAttribute( "content" ),
disabledZoom = initialContent + ",maximum-scale=1",
enabledZoom = initialContent + ",maximum-scale=10",
enabled = true,
x, y, z, aig;
if( !meta ){ return; }
function restoreZoom(){
meta.setAttribute( "content", enabledZoom );
enabled = true;
var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function disableZoom(){
meta.setAttribute( "content", disabledZoom );
enabled = false;
}
function checkTilt( e ){
aig = e.accelerationIncludingGravity;
x = Math.abs( aig.x );
y = Math.abs( aig.y );
z = Math.abs( aig.z );
// If portrait orientation and in one of the danger zones
if( (!w.orientation || w.orientation === 180) && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
if( enabled ){
disableZoom();
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
else if( !enabled ){
restoreZoom();
}
} catch (err) {
settle("throw", err);
}
}
w.addEventListener( "orientationchange", restoreZoom, false );
w.addEventListener( "devicemotion", checkTilt, false );
})( this );
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
/**
* request-frame - requestAnimationFrame & cancelAnimationFrame polyfill for
* optimal cross-browser development.
* Version: v1.4.0
* License: MIT
* Copyright Julien Etienne 2015 All Rights Reserved.
* github: https://github.com/julienetie/request-frame
*‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
*/
(function (window) {
case "throw":
front.reject(value);
break;
/**
* @param {String} type - request | cancel | native.
* @return {Function} Timing function.
*/
function requestFrame(type) {
// The only vendor prefixes required.
var vendors = ['moz', 'webkit'],
default:
front.resolve({
value: value,
done: false
});
break;
}
// Disassembled timing function abbreviations.
aF = 'AnimationFrame',
rqAF = 'Request' + aF,
front = front.next;
// Final assigned functions.
assignedRequestAnimationFrame,
assignedCancelAnimationFrame,
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
// Initial time of the timing lapse.
previousTime = 0,
this._invoke = send;
mozRAF = window.mozRequestAnimationFrame,
mozCAF = window.mozCancelAnimationFrame,
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
// Checks for firefox 4 - 10 function pair mismatch.
hasMozMismatch = mozRAF && !mozCAF,
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
func;
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
// Date.now polyfill, mainly for legacy IE versions.
if (!Date.now) {
Date.now = function() {
return new Date().getTime();
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
/**
* 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,
// Only supports webkit prefixed requestAnimtionFrane.
requiresWebkitprefix = !(webkitRAF && rAF),
// 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',
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();
}
/**
* Native clearTimeout function.
* @return {Function}
*/
function clearTimeoutWithId(id) {
clearTimeout(id);
}
/**
* 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);
}
/**
* 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;
}
}
/**
* 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;
}
/**
* 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;
}
// Use truthly function
assignedCancelAnimationFrame = window['cancel' + aF] ||
prefixedCancelAnimationFrame(cancellationNames, 0) ||
clearTimeoutWithId;
var get = function get(object, property, receiver) {
if (object === null) object = Function.prototype;
var desc = Object.getOwnPropertyDescriptor(object, property);
// Check for iOS 6 bug
if (!hasIOS6RequestAnimationFrameBug()) {
return assignedCancelAnimationFrame;
} else {
return clearTimeoutWithId;
}
}
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
function getRequestFn() {
if (hasMozMismatch) {
return setTimeoutWithTimestamp;
} else {
return queryRequestAnimationFrame();
}
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
function getCancelFn() {
return queryCancelAnimationFrame();
if (getter === undefined) {
return undefined;
}
function setNativeFn() {
if (hasMozMismatch) {
window.requestAnimationFrame = setTimeoutWithTimestamp;
window.cancelAnimationFrame = clearTimeoutWithId;
} else {
window.requestAnimationFrame = queryRequestAnimationFrame();
window.cancelAnimationFrame = queryCancelAnimationFrame();
}
}
return getter.call(receiver);
}
};
/**
* The type value "request" singles out firefox 4 - 10 and
* assigns the setTimeout function if plausible.
*/
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;
}
// Node.js/ CommonJS
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = requestFrame;
}
// AMD
else if (typeof define === 'function' && define.amd) {
define(function() {
return requestFrame;
});
}
// Default to window as global
else if (typeof window === 'object') {
window.requestFrame = requestFrame;
}
/* global -module, -exports, -define */
}((typeof window === "undefined" ? {} : window)));
var request = requestFrame('request');
var cancel = requestFrame('cancel');
var self = this;
var store = {};
function requestTimeout(fn, delay) {
var start = Date.now();
function increment(d) {
store.k = !store.k ? d : null;
return store.k += 1;
var set = function set(object, property, value, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent !== null) {
set(parent, property, value, receiver);
}
} else if ("value" in desc && desc.writable) {
desc.value = value;
} else {
var setter = desc.set;
function loop() {
store.delta = Date.now() - start;
store.callHandler = store.delta >= delay ? fn.call() : request(loop);
if (setter !== undefined) {
setter.call(receiver, value);
}
}
request(loop);
return increment(0);
}
return value;
};
/* _.-~-.
7'' Q..\
_7 (_
_7 _/ _q. /
_7 . ___ /VVvv-'_ .
7/ / /~- \_\\ '-._ .-' / //
./ ( /-~-/ ||'=.__ '::. '-~'' { ___ / // ./{
V V-~-~| || __''_ ':::. ''~-~.___.-'' _/ // / {_ / { /
VV/-~-~-| / \ .'__'. '. ':: ____ _ _ _ ''.
/ /~~~~|| VVV/ / \ ) \ | _ \ ___ ___(_)___(_) | | __ _ .::'
/ (~-~-~\\.-' / \' \::::. | |_) / _ \/ __| |_ / | | |/ _` | :::'
/..\ /..\__/ ' '::: | _ < __/\__ \ |/ /| | | | (_| | ::'
vVVv vVVv ': |_| \_\___||___/_/___|_|_|_|\__,_| '' */
function handlerCallback(handler, delay, incept) {
handler.apply(self, handler, delay, incept);
}
/**
* Check if value is an Array.
* @param {Array} type.
* @return {Boolean}
*/
var isArray = Array.isArray || function (value) {
return toString.call(value) == '[object Array]';
};
/**
* Check if value is an object.
* @param {Object} value.
* @return {Boolean}
*/
var isObject = function isObject(value) {
return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && isArray(value) === false;
};
function resizilla(optionsHandler, delay, incept) {
/**
* resizilla function
* @public
* @param {Function | Object} optionsHandler The handler or options as an
* object literal.
* @param {Number} delay Delay in MS
* @param {Boolean} incept Incept from start of delay or till the end.
*/
function resizilla$1(optionsHandler, delay, incept) {
var options = {};
resizilla.options = options;
// Defaults
options.orientationChange = true;
options.useCapture = true;
options.incept = false;
resizilla$1.options = options;
if(optionsHandler.constructor === {}.constructor){
// Defaults
options.orientationChange = true;
options.useCapture = true;
options.incept = false;
if (isObject(optionsHandler)) {
options.handler = optionsHandler.handler;

@@ -384,3 +319,3 @@ options.delay = optionsHandler.delay;

options.useCapture = optionsHandler.useCapture;
}else{
} else {
options.handler = optionsHandler;

@@ -391,44 +326,18 @@ options.delay = delay;

window.addEventListener('resize', debounce(options.handler, options.delay, options.incept), options.useCapture);
function debounce(handler, delay, incept) {
var timeout;
return function() {
var lastCall = function() {
timeout = 0;
if (!incept) {
handlerCallback(handler, delay, incept);
}
};
store.instant = incept && !timeout;
cancel(timeout);
timeout = requestTimeout(lastCall, delay);
if (store.instant) {
handlerCallback(handler, delay, incept);
}
};
if (options.orientationChange) {
window.addEventListener('orientationchange', options.handler, options.useCapture);
}
function addWindowEvent(handler) {
self.addEventListener('resize', handler, options.useCapture);
}
addWindowEvent(debounce(options.handler, options.delay, options.incept));
if(options.orientationChange){
self.addEventListener('orientationchange', options.handler, options.useCapture);
}
}
resizilla.destroy = function(type) {
if(!type || type === 'all'){
/**
* Remove all or one of the event listeners
* @param {String} type.
*/
resizilla$1.destroy = function (type) {
if (!type || type === 'all') {
window.removeEventListener('resize', this.options.handler, this.options.useCapture);
window.removeEventListener('orientationchange', this.options.handler, this.options.useCapture);
}else{
} else {
window.removeEventListener(type, this.options.handler, this.options.useCapture);

@@ -438,20 +347,6 @@ }

// Node.js/ CommonJS
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = exports = resizilla;
}
resizilla$1.VERSION = version;
// AMD
else if (typeof define === 'function' && define.amd) {
define(function() {
return resizilla;
});
}
return resizilla$1;
// Default to window as global
else if (typeof window === 'object') {
window.resizilla = resizilla;
}
/* global -module, -exports, -define */
}((typeof window === "undefined" ? {} : window)));
})));
{
"name": "resizilla",
"version": "0.6.2",
"description": "A Better Window Resize",
"main": "resizilla.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "gulp"
},
"repository": {
"type": "git",
"url": "https://github.com/julienetie/resizilla"
},
"keywords": [
"resize",
"window.onresize",
"debounce",
"window",
"event"
],
"author": "Julien Etienne",
"license": "MIT",
"bugs": {
"url": "https://github.com/julienetie/resizilla/issues"
},
"homepage": "https://github.com/julienetie/resizilla",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-bump": "^2.2.0",
"gulp-concat": "^2.6.0",
"gulp-header": "^1.8.7",
"gulp-notify": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.4"
}
}
"name": "resizilla",
"version": "0.6.3",
"description": "A Better Window Resize",
"main": "resizilla.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "gulp",
"bump": "node ./bump.js",
"build": "rollup -c ./rollup/rollup.config.umd.js && rollup -c ./rollup/rollup.config.es.js"
},
"repository": {
"type": "git",
"url": "https://github.com/julienetie/resizilla"
},
"keywords": [
"resize",
"window.onresize",
"debounce",
"window",
"event",
"window resize",
"resize events",
"mobile resize"
],
"author": "Julien Etienne",
"license": "MIT",
"bugs": {
"url": "https://github.com/julienetie/resizilla/issues"
},
"homepage": "https://github.com/julienetie/resizilla",
"devDependencies": {
"babel-preset-es2015": "^6.18.0",
"babel-preset-es2015-rollup": "^1.2.0",
"colors": "^1.1.2",
"mz": "^2.4.0",
"rollup": "^0.36.3",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-watch": "^2.5.0"
},
"dependencies": {
"set-animation-frame": "^0.1.1",
"set-animation-interval": "^0.0.2",
"volve": "^0.0.8"
}
}
![img](http://oi68.tinypic.com/33m0pbr.jpg)
```php
*** Important API Changes***
```
#### For:
- resizilla.js
- resizilla.es.js
version 0.7+ requires the Request-frame or an alternative requestAnimationFrame & cancelAnimationFrame polyfill.
If you need to use both Request-frame and Resizilla check out [4d](https://github.com/envidia/4d) which includes both libraries and weighs under 2kB gzipped.
- [4d](https://github.com/envidia/4d)
- [requestFrame](https://github.com/julienetie/request-frame)
#### For:
- resizilla.polyfilljs
- resizilla.polyfill.es.js
These distributions include the Request-frame polyfill.
## resizilla

@@ -4,0 +25,0 @@ ### A Better Window Resize

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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