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

flipping

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flipping - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

.awcache/07678136b7d29e04a567faffd105962c4195bc483408d53cfd593c20296fb0771731aca9afd3aa532437d40f99588d49a5213ed03e9724637c804bb427d98aa6.json.gzip

2

dist/flipping.animationFrame.js

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

!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Flipping=n():t.Flipping=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=3)}([function(t,n,e){"use strict";function r(t,n){for(var e=0;e<t.length;e++)n(t[e],e,t)}function o(t,n){return t.height?n.height?{top:t.top-n.top,left:t.left-n.left,width:t.width/n.width,height:t.height/n.height}:n:t}var i=this&&this.__assign||Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t};n.__esModule=!0;var u=function(t){return t},c=function(t){var n=t.getBoundingClientRect();return{top:n.top,left:n.left,width:n.width,height:n.height}},s=function(t){return t.querySelectorAll("[data-key]")},f=function(t){return t.getAttribute("data-key")},a=function(){function t(t){void 0===t&&(t={}),this.selector=t.selector||s,this.getBounds=t.getBounds||c,this.getDelta=t.getDelta||o,this.getKey=t.getKey||f,this.onFlip=t.onFlip||u,this.onRead=t.onRead||u,this.flipListeners={},this.readListeners={},this.bounds={},this.animations={},this.listeners={}}return t.prototype.on=function(t,n){(this.listeners[t]||(this.listeners[t]=[])).push(n)},t.prototype.off=function(t,n){var e,r=this.listeners[t];r&&-1!==(e=r.indexOf(n))&&r.splice(e,1)},t.prototype.emit=function(t,n){var e=this.listeners[t];e&&e.length&&e.forEach(function(t){return t(n)})},t.prototype.read=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),o={};r(e,function(t){var e=n.getKey(t),r=n.bounds[e]=n.getBounds(t),i=n.animations[e],u={key:e,node:t,bounds:r,animation:i};o[e]=u,n.onRead(u)}),this.emit("read",o)},t.prototype.flip=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),o={};r(e,function(e){var r=n.getKey(e),u=n.bounds[r],c=n.getBounds(e),s=n.animations[r],f={key:r,node:e,first:u,last:c,delta:n.getDelta(u,c),type:u?c?"MOVE":"LEAVE":"ENTER",animation:s},a=n.onFlip(f,function(){return n.read(t)});o[r]=i({},f,{animation:a}),n.animations[r]=a}),this.emit("flip",o)},t.prototype.wrap=function(t){var n=this;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];n.read();var o=t.apply(void 0,e);return n.flip(),o}},t}();n.default=a},function(t,n){function e(t){return-.5*(Math.cos(Math.PI*t)-1)}t.exports=e},function(t,n,e){t.exports=e(7).Observable},function(t,n,e){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),o=this&&this.__assign||Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},i=e(0),u=e(1),c=e(2),s=Date.now,f=function(t){return new c(function(n){var e=s(),r=!0,o=function(){var i=(s()-e)/t;i>=1||!r?(n.next(1),n.complete()):(n.next(i),requestAnimationFrame(o))},i=function(){r=!1};return o(),i})},a=function(t){return function(n,e){var r=n.delta,o=n.node;return s(),t.easing,f(t.duration).subscribe(function(t){var n=(u(t),t*Math.PI/2),e=r.left-r.left*Math.sin(n),i=r.top*Math.cos(n);o.style.setProperty("transform","translate("+e+"px, "+i+"px)")},function(){},function(){o.style.setProperty("transform","none"),e()})}},l=function(t){var n=t.animation;t.node.style.setProperty("transform","none"),n&&n.unsubscribe()},p={duration:300,easing:u},h=function(t){function n(n){var e={duration:n.duration||p.duration,easing:n.easing||p.easing};return t.call(this,o({onRead:l,onFlip:a(e)},n))||this}return r(n,t),n}(i.default);t.exports=h},,,function(t,n){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,n,e){"use strict";(function(t){!function(t,e){!function(t,n){function e(t){return"function"==typeof Symbol&&Boolean(Symbol[t])}function r(t){return e(t)?Symbol[t]:"@@"+t}function o(t,n){var e=t[n];if(null!=e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}}function i(t){var n=t.constructor;return void 0!==n&&null===(n=n[r("species")])&&(n=void 0),void 0!==n?n:h}function u(t,n){Object.keys(n).forEach(function(e){var r=Object.getOwnPropertyDescriptor(n,e);r.enumerable=!1,Object.defineProperty(t,e,r)})}function c(t){var n=t._cleanup;n&&(t._cleanup=void 0,n())}function s(t){return void 0===t._observer}function f(t){s(t)||(t._observer=void 0,c(t))}function a(t){return function(){t.unsubscribe()}}function l(t,n){if(Object(t)!==t)throw new TypeError("Observer must be an object");this._cleanup=void 0,this._observer=t;var e=o(t,"start");if(e&&e.call(t,this),!s(this)){t=new p(this);try{var r=n.call(void 0,t);if(null!=r){if("function"==typeof r.unsubscribe)r=a(r);else if("function"!=typeof r)throw new TypeError(r+" is not a function");this._cleanup=r}}catch(n){return void t.error(n)}s(this)&&c(this)}}function p(t){this._subscription=t}function h(t){if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}"function"!=typeof Symbol||Symbol.observable||(Symbol.observable=Symbol("observable")),u(l.prototype={},{get closed(){return s(this)},unsubscribe:function(){f(this)}}),u(p.prototype={},{get closed(){return s(this._subscription)},next:function(t){var n=this._subscription;if(!s(n)){var e=n._observer,r=o(e,"next");if(r)return r.call(e,t)}},error:function(t){var n=this._subscription;if(s(n))throw t;var e=n._observer;n._observer=void 0;try{var r=o(e,"error");if(!r)throw t;t=r.call(e,t)}catch(t){try{c(n)}finally{throw t}}return c(n),t},complete:function(t){var n=this._subscription;if(!s(n)){var e=n._observer;n._observer=void 0;try{var r=o(e,"complete");t=r?r.call(e,t):void 0}catch(t){try{c(n)}finally{throw t}}return c(n),t}}}),u(h.prototype,{subscribe:function(t){for(var n=[],e=1;e<arguments.length;++e)n.push(arguments[e]);return"function"==typeof t&&(t={next:t,error:n[0],complete:n[1]}),new l(t,this._subscriber)},forEach:function(t){var n=this;return new Promise(function(e,r){if("function"!=typeof t)return Promise.reject(new TypeError(t+" is not a function"));n.subscribe({_subscription:null,start:function(t){if(Object(t)!==t)throw new TypeError(t+" is not an object");this._subscription=t},next:function(n){var e=this._subscription;if(!e.closed)try{return t(n)}catch(t){r(t),e.unsubscribe()}},error:r,complete:e})})},map:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");return new(i(this))(function(e){return n.subscribe({next:function(n){if(!e.closed){try{n=t(n)}catch(t){return e.error(t)}return e.next(n)}},error:function(t){return e.error(t)},complete:function(t){return e.complete(t)}})})},filter:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");return new(i(this))(function(e){return n.subscribe({next:function(n){if(!e.closed){try{if(!t(n))return}catch(t){return e.error(t)}return e.next(n)}},error:function(t){return e.error(t)},complete:function(){return e.complete()}})})},reduce:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=i(this),r=arguments.length>1,o=!1,u=arguments[1],c=u;return new e(function(e){return n.subscribe({next:function(n){if(!e.closed){var i=!o;if(o=!0,!i||r)try{c=t(c,n)}catch(t){return e.error(t)}else c=n}},error:function(t){e.error(t)},complete:function(){if(!o&&!r)return void e.error(new TypeError("Cannot reduce an empty sequence"));e.next(c),e.complete()}})})},flatMap:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");return new(i(this))(function(e){function r(){o&&0===i.length&&e.complete()}var o=!1,i=[],u=n.subscribe({next:function(n){if(t)try{n=t(n)}catch(t){return void e.error(t)}h.from(n).subscribe({_subscription:null,start:function(t){i.push(this._subscription=t)},next:function(t){e.next(t)},error:function(t){e.error(t)},complete:function(){var t=i.indexOf(this._subscription);t>=0&&i.splice(t,1),r()}})},error:function(t){return e.error(t)},complete:function(){o=!0,r()}});return function(){i.forEach(function(t){return t.unsubscribe()}),u.unsubscribe()}})}}),Object.defineProperty(h.prototype,r("observable"),{value:function(){return this},writable:!0,configurable:!0}),u(h,{from:function(t){var n="function"==typeof this?this:h;if(null==t)throw new TypeError(t+" is not an object");var i=o(t,r("observable"));if(i){var u=i.call(t);if(Object(u)!==u)throw new TypeError(u+" is not an object");return u.constructor===n?u:new n(function(t){return u.subscribe(t)})}if(e("iterator")&&(i=o(t,r("iterator"))))return new n(function(n){for(var e,r=i.call(t)[Symbol.iterator]();e=r.next(),!e.done;){var o=e.value;if(n.next(o),n.closed)return}n.complete()});if(Array.isArray(t))return new n(function(n){for(var e=0;e<t.length;++e)if(n.next(t[e]),n.closed)return;n.complete()});throw new TypeError(t+" is not observable")},of:function(){for(var t=[],n=0;n<arguments.length;++n)t.push(arguments[n]);return new("function"==typeof this?this:h)(function(n){for(var e=0;e<t.length;++e)if(n.next(t[e]),n.closed)return;n.complete()})}}),Object.defineProperty(h,r("species"),{get:function(){return this},configurable:!0}),t.Observable=h}(n)}()}).call(n,e(6)(t))}])});
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Flipping=n():t.Flipping=n()}(this,function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=3)}([function(t,n,e){"use strict";function r(t,n){for(var e=0;e<t.length;e++)n(t[e],e,t)}function o(t,n){return t.height?n.height?{top:t.top-n.top,left:t.left-n.left,width:t.width/n.width,height:t.height/n.height}:n:t}var i=this&&this.__assign||Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t};n.__esModule=!0;var u=function(t){return t},c=function(t){var n=t.getBoundingClientRect();return{top:n.top,left:n.left,width:n.width,height:n.height}},s=function(t){return t.querySelectorAll("[data-key]")},f=function(t){return t.getAttribute("data-key")},a=function(t){return!!t.top||!!t.left||1!==t.width||1!==t.height},l=function(){function t(t){void 0===t&&(t={}),this.selector=t.selector||s,this.getBounds=t.getBounds||c,this.getDelta=t.getDelta||o,this.getKey=t.getKey||f,this.onFlip=t.onFlip||u,this.onRead=t.onRead||u,this.flipListeners={},this.readListeners={},this.bounds={},this.animations={},this.listeners={}}return t.prototype.on=function(t,n){(this.listeners[t]||(this.listeners[t]=[])).push(n)},t.prototype.off=function(t,n){var e,r=this.listeners[t];r&&-1!==(e=r.indexOf(n))&&r.splice(e,1)},t.prototype.emit=function(t,n){var e=this.listeners[t];e&&e.length&&e.forEach(function(t){return t(n)})},t.prototype.read=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),o={};r(e,function(t){var e=n.getKey(t),r=n.bounds[e]=n.getBounds(t),i=n.animations[e],u={key:e,node:t,bounds:r,animation:i};o[e]=u,n.onRead(u)}),this.emit("read",o)},t.prototype.flip=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),o={},u=!1;r(e,function(e){var r=n.getKey(e),c=n.bounds[r],s=n.getBounds(e),f=n.animations[r],l=n.getDelta(c,s);if(a(l)){u=!0;var p={key:r,node:e,first:c,last:s,delta:n.getDelta(c,s),type:c?s?"MOVE":"LEAVE":"ENTER",animation:f},h=n.onFlip(p,function(){return n.read(t)});o[r]=i({},p,{animation:h}),n.animations[r]=h}}),u&&this.emit("flip",o)},t.prototype.wrap=function(t){var n=this;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];n.read();var o=t.apply(void 0,e);return n.flip(),o}},t}();n.default=l},function(t,n){function e(t){return-.5*(Math.cos(Math.PI*t)-1)}t.exports=e},function(t,n,e){t.exports=e(7).Observable},function(t,n,e){"use strict";var r=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),o=this&&this.__assign||Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},i=e(0),u=e(1),c=e(2),s=Date.now,f=function(t){return new c(function(n){var e=s(),r=!0,o=function(){var i=(s()-e)/t;i>=1||!r?(n.next(1),n.complete()):(n.next(i),requestAnimationFrame(o))},i=function(){r=!1};return o(),i})},a=function(t){return function(n,e){var r=n.delta,o=n.node;return s(),t.easing,f(t.duration).subscribe(function(t){var n=(u(t),t*Math.PI/2),e=r.left-r.left*Math.sin(n),i=r.top*Math.cos(n);o.style.setProperty("transform","translate("+e+"px, "+i+"px)")},function(){},function(){o.style.setProperty("transform","none"),e()})}},l=function(t){var n=t.animation;t.node.style.setProperty("transform","none"),n&&n.unsubscribe()},p={duration:300,easing:u},h=function(t){function n(n){var e={duration:n.duration||p.duration,easing:n.easing||p.easing};return t.call(this,o({onRead:l,onFlip:a(e)},n))||this}return r(n,t),n}(i.default);t.exports=h},,,function(t,n){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,n,e){"use strict";(function(t){!function(t,e){!function(t,n){function e(t){return"function"==typeof Symbol&&Boolean(Symbol[t])}function r(t){return e(t)?Symbol[t]:"@@"+t}function o(t,n){var e=t[n];if(null!=e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}}function i(t){var n=t.constructor;return void 0!==n&&null===(n=n[r("species")])&&(n=void 0),void 0!==n?n:h}function u(t,n){Object.keys(n).forEach(function(e){var r=Object.getOwnPropertyDescriptor(n,e);r.enumerable=!1,Object.defineProperty(t,e,r)})}function c(t){var n=t._cleanup;n&&(t._cleanup=void 0,n())}function s(t){return void 0===t._observer}function f(t){s(t)||(t._observer=void 0,c(t))}function a(t){return function(){t.unsubscribe()}}function l(t,n){if(Object(t)!==t)throw new TypeError("Observer must be an object");this._cleanup=void 0,this._observer=t;var e=o(t,"start");if(e&&e.call(t,this),!s(this)){t=new p(this);try{var r=n.call(void 0,t);if(null!=r){if("function"==typeof r.unsubscribe)r=a(r);else if("function"!=typeof r)throw new TypeError(r+" is not a function");this._cleanup=r}}catch(n){return void t.error(n)}s(this)&&c(this)}}function p(t){this._subscription=t}function h(t){if("function"!=typeof t)throw new TypeError("Observable initializer must be a function");this._subscriber=t}"function"!=typeof Symbol||Symbol.observable||(Symbol.observable=Symbol("observable")),u(l.prototype={},{get closed(){return s(this)},unsubscribe:function(){f(this)}}),u(p.prototype={},{get closed(){return s(this._subscription)},next:function(t){var n=this._subscription;if(!s(n)){var e=n._observer,r=o(e,"next");if(r)return r.call(e,t)}},error:function(t){var n=this._subscription;if(s(n))throw t;var e=n._observer;n._observer=void 0;try{var r=o(e,"error");if(!r)throw t;t=r.call(e,t)}catch(t){try{c(n)}finally{throw t}}return c(n),t},complete:function(t){var n=this._subscription;if(!s(n)){var e=n._observer;n._observer=void 0;try{var r=o(e,"complete");t=r?r.call(e,t):void 0}catch(t){try{c(n)}finally{throw t}}return c(n),t}}}),u(h.prototype,{subscribe:function(t){for(var n=[],e=1;e<arguments.length;++e)n.push(arguments[e]);return"function"==typeof t&&(t={next:t,error:n[0],complete:n[1]}),new l(t,this._subscriber)},forEach:function(t){var n=this;return new Promise(function(e,r){if("function"!=typeof t)return Promise.reject(new TypeError(t+" is not a function"));n.subscribe({_subscription:null,start:function(t){if(Object(t)!==t)throw new TypeError(t+" is not an object");this._subscription=t},next:function(n){var e=this._subscription;if(!e.closed)try{return t(n)}catch(t){r(t),e.unsubscribe()}},error:r,complete:e})})},map:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");return new(i(this))(function(e){return n.subscribe({next:function(n){if(!e.closed){try{n=t(n)}catch(t){return e.error(t)}return e.next(n)}},error:function(t){return e.error(t)},complete:function(t){return e.complete(t)}})})},filter:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");return new(i(this))(function(e){return n.subscribe({next:function(n){if(!e.closed){try{if(!t(n))return}catch(t){return e.error(t)}return e.next(n)}},error:function(t){return e.error(t)},complete:function(){return e.complete()}})})},reduce:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");var e=i(this),r=arguments.length>1,o=!1,u=arguments[1],c=u;return new e(function(e){return n.subscribe({next:function(n){if(!e.closed){var i=!o;if(o=!0,!i||r)try{c=t(c,n)}catch(t){return e.error(t)}else c=n}},error:function(t){e.error(t)},complete:function(){if(!o&&!r)return void e.error(new TypeError("Cannot reduce an empty sequence"));e.next(c),e.complete()}})})},flatMap:function(t){var n=this;if("function"!=typeof t)throw new TypeError(t+" is not a function");return new(i(this))(function(e){function r(){o&&0===i.length&&e.complete()}var o=!1,i=[],u=n.subscribe({next:function(n){if(t)try{n=t(n)}catch(t){return void e.error(t)}h.from(n).subscribe({_subscription:null,start:function(t){i.push(this._subscription=t)},next:function(t){e.next(t)},error:function(t){e.error(t)},complete:function(){var t=i.indexOf(this._subscription);t>=0&&i.splice(t,1),r()}})},error:function(t){return e.error(t)},complete:function(){o=!0,r()}});return function(){i.forEach(function(t){return t.unsubscribe()}),u.unsubscribe()}})}}),Object.defineProperty(h.prototype,r("observable"),{value:function(){return this},writable:!0,configurable:!0}),u(h,{from:function(t){var n="function"==typeof this?this:h;if(null==t)throw new TypeError(t+" is not an object");var i=o(t,r("observable"));if(i){var u=i.call(t);if(Object(u)!==u)throw new TypeError(u+" is not an object");return u.constructor===n?u:new n(function(t){return u.subscribe(t)})}if(e("iterator")&&(i=o(t,r("iterator"))))return new n(function(n){for(var e,r=i.call(t)[Symbol.iterator]();e=r.next(),!e.done;){var o=e.value;if(n.next(o),n.closed)return}n.complete()});if(Array.isArray(t))return new n(function(n){for(var e=0;e<t.length;++e)if(n.next(t[e]),n.closed)return;n.complete()});throw new TypeError(t+" is not observable")},of:function(){for(var t=[],n=0;n<arguments.length;++n)t.push(arguments[n]);return new("function"==typeof this?this:h)(function(n){for(var e=0;e<t.length;++e)if(n.next(t[e]),n.closed)return;n.complete()})}}),Object.defineProperty(h,r("species"),{get:function(){return this},configurable:!0}),t.Observable=h}(n)}()}).call(n,e(6)(t))}])});

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Flipping=e():t.Flipping=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,n){"use strict";function i(t,e){for(var n=0;n<t.length;n++)e(t[n],n,t)}function o(t,e){return t.height?e.height?{top:t.top-e.top,left:t.left-e.left,width:t.width/e.width,height:t.height/e.height}:e:t}var r=this&&this.__assign||Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t};e.__esModule=!0;var s=function(t){return t},u=function(t){var e=t.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},a=function(t){return t.querySelectorAll("[data-key]")},f=function(t){return t.getAttribute("data-key")},c=function(){function t(t){void 0===t&&(t={}),this.selector=t.selector||a,this.getBounds=t.getBounds||u,this.getDelta=t.getDelta||o,this.getKey=t.getKey||f,this.onFlip=t.onFlip||s,this.onRead=t.onRead||s,this.flipListeners={},this.readListeners={},this.bounds={},this.animations={},this.listeners={}}return t.prototype.on=function(t,e){(this.listeners[t]||(this.listeners[t]=[])).push(e)},t.prototype.off=function(t,e){var n,i=this.listeners[t];i&&-1!==(n=i.indexOf(e))&&i.splice(n,1)},t.prototype.emit=function(t,e){var n=this.listeners[t];n&&n.length&&n.forEach(function(t){return t(e)})},t.prototype.read=function(t){var e=this;void 0===t&&(t=document.documentElement);var n=this.selector(t),o={};i(n,function(t){var n=e.getKey(t),i=e.bounds[n]=e.getBounds(t),r=e.animations[n],s={key:n,node:t,bounds:i,animation:r};o[n]=s,e.onRead(s)}),this.emit("read",o)},t.prototype.flip=function(t){var e=this;void 0===t&&(t=document.documentElement);var n=this.selector(t),o={};i(n,function(n){var i=e.getKey(n),s=e.bounds[i],u=e.getBounds(n),a=e.animations[i],f={key:i,node:n,first:s,last:u,delta:e.getDelta(s,u),type:s?u?"MOVE":"LEAVE":"ENTER",animation:a},c=e.onFlip(f,function(){return e.read(t)});o[i]=r({},f,{animation:c}),e.animations[i]=c}),this.emit("flip",o)},t.prototype.wrap=function(t){var e=this;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];e.read();var o=t.apply(void 0,n);return e.flip(),o}},t}();e.default=c},,,,function(t,e,n){"use strict";var i=n(0);t.exports=i.default}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Flipping=e():t.Flipping=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,n){"use strict";function i(t,e){for(var n=0;n<t.length;n++)e(t[n],n,t)}function o(t,e){return t.height?e.height?{top:t.top-e.top,left:t.left-e.left,width:t.width/e.width,height:t.height/e.height}:e:t}var r=this&&this.__assign||Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t};e.__esModule=!0;var s=function(t){return t},u=function(t){var e=t.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}},a=function(t){return t.querySelectorAll("[data-key]")},f=function(t){return t.getAttribute("data-key")},c=function(t){return!!t.top||!!t.left||1!==t.width||1!==t.height},l=function(){function t(t){void 0===t&&(t={}),this.selector=t.selector||a,this.getBounds=t.getBounds||u,this.getDelta=t.getDelta||o,this.getKey=t.getKey||f,this.onFlip=t.onFlip||s,this.onRead=t.onRead||s,this.flipListeners={},this.readListeners={},this.bounds={},this.animations={},this.listeners={}}return t.prototype.on=function(t,e){(this.listeners[t]||(this.listeners[t]=[])).push(e)},t.prototype.off=function(t,e){var n,i=this.listeners[t];i&&-1!==(n=i.indexOf(e))&&i.splice(n,1)},t.prototype.emit=function(t,e){var n=this.listeners[t];n&&n.length&&n.forEach(function(t){return t(e)})},t.prototype.read=function(t){var e=this;void 0===t&&(t=document.documentElement);var n=this.selector(t),o={};i(n,function(t){var n=e.getKey(t),i=e.bounds[n]=e.getBounds(t),r=e.animations[n],s={key:n,node:t,bounds:i,animation:r};o[n]=s,e.onRead(s)}),this.emit("read",o)},t.prototype.flip=function(t){var e=this;void 0===t&&(t=document.documentElement);var n=this.selector(t),o={},s=!1;i(n,function(n){var i=e.getKey(n),u=e.bounds[i],a=e.getBounds(n),f=e.animations[i],l=e.getDelta(u,a);if(c(l)){s=!0;var p={key:i,node:n,first:u,last:a,delta:e.getDelta(u,a),type:u?a?"MOVE":"LEAVE":"ENTER",animation:f},h=e.onFlip(p,function(){return e.read(t)});o[i]=r({},p,{animation:h}),e.animations[i]=h}}),s&&this.emit("flip",o)},t.prototype.wrap=function(t){var e=this;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];e.read();var o=t.apply(void 0,n);return e.flip(),o}},t}();e.default=l},,,,function(t,e,n){"use strict";var i=n(0);t.exports=i.default}])});

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

!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Flipping=n():t.Flipping=n()}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=5)}({0:function(t,n,e){"use strict";function o(t,n){for(var e=0;e<t.length;e++)n(t[e],e,t)}function r(t,n){return t.height?n.height?{top:t.top-n.top,left:t.left-n.left,width:t.width/n.width,height:t.height/n.height}:n:t}var i=this&&this.__assign||Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};n.__esModule=!0;var s=function(t){return t},a=function(t){var n=t.getBoundingClientRect();return{top:n.top,left:n.left,width:n.width,height:n.height}},u=function(t){return t.querySelectorAll("[data-key]")},f=function(t){return t.getAttribute("data-key")},c=function(){function t(t){void 0===t&&(t={}),this.selector=t.selector||u,this.getBounds=t.getBounds||a,this.getDelta=t.getDelta||r,this.getKey=t.getKey||f,this.onFlip=t.onFlip||s,this.onRead=t.onRead||s,this.flipListeners={},this.readListeners={},this.bounds={},this.animations={},this.listeners={}}return t.prototype.on=function(t,n){(this.listeners[t]||(this.listeners[t]=[])).push(n)},t.prototype.off=function(t,n){var e,o=this.listeners[t];o&&-1!==(e=o.indexOf(n))&&o.splice(e,1)},t.prototype.emit=function(t,n){var e=this.listeners[t];e&&e.length&&e.forEach(function(t){return t(n)})},t.prototype.read=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),r={};o(e,function(t){var e=n.getKey(t),o=n.bounds[e]=n.getBounds(t),i=n.animations[e],s={key:e,node:t,bounds:o,animation:i};r[e]=s,n.onRead(s)}),this.emit("read",r)},t.prototype.flip=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),r={};o(e,function(e){var o=n.getKey(e),s=n.bounds[o],a=n.getBounds(e),u=n.animations[o],f={key:o,node:e,first:s,last:a,delta:n.getDelta(s,a),type:s?a?"MOVE":"LEAVE":"ENTER",animation:u},c=n.onFlip(f,function(){return n.read(t)});r[o]=i({},f,{animation:c}),n.animations[o]=c}),this.emit("flip",r)},t.prototype.wrap=function(t){var n=this;return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];n.read();var r=t.apply(void 0,e);return n.flip(),r}},t}();n.default=c},5:function(t,n,e){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])};return function(n,e){function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),r=this&&this.__assign||Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i=e(0),s=function(t){return function(n){var e=n.delta,o=n.node;return console.log(t),o.animate([{transformOrigin:"top left",transform:"translate("+e.left+"px, "+e.top+"px)"},{transformOrigin:"top left",transform:"translate(0,0) scale(1)"}],t)}},a=function(t){var n=t.animation;return n&&n.cancel&&n.cancel()},u={duration:3e3,easing:"ease"},f=function(t){function n(n){var e={duration:n.duration||u.duration,easing:n.easing||u.easing};return t.call(this,r({onRead:a,onFlip:s(e)},n))||this}return o(n,t),n}(i.default);t.exports=f}})});
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Flipping=n():t.Flipping=n()}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var e={};return n.m=t,n.c=e,n.i=function(t){return t},n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=5)}({0:function(t,n,e){"use strict";function o(t,n){for(var e=0;e<t.length;e++)n(t[e],e,t)}function r(t,n){return t.height?n.height?{top:t.top-n.top,left:t.left-n.left,width:t.width/n.width,height:t.height/n.height}:n:t}var i=this&&this.__assign||Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};n.__esModule=!0;var a=function(t){return t},s=function(t){var n=t.getBoundingClientRect();return{top:n.top,left:n.left,width:n.width,height:n.height}},u=function(t){return t.querySelectorAll("[data-key]")},f=function(t){return t.getAttribute("data-key")},c=function(t){return!!t.top||!!t.left||1!==t.width||1!==t.height},l=function(){function t(t){void 0===t&&(t={}),this.selector=t.selector||u,this.getBounds=t.getBounds||s,this.getDelta=t.getDelta||r,this.getKey=t.getKey||f,this.onFlip=t.onFlip||a,this.onRead=t.onRead||a,this.flipListeners={},this.readListeners={},this.bounds={},this.animations={},this.listeners={}}return t.prototype.on=function(t,n){(this.listeners[t]||(this.listeners[t]=[])).push(n)},t.prototype.off=function(t,n){var e,o=this.listeners[t];o&&-1!==(e=o.indexOf(n))&&o.splice(e,1)},t.prototype.emit=function(t,n){var e=this.listeners[t];e&&e.length&&e.forEach(function(t){return t(n)})},t.prototype.read=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),r={};o(e,function(t){var e=n.getKey(t),o=n.bounds[e]=n.getBounds(t),i=n.animations[e],a={key:e,node:t,bounds:o,animation:i};r[e]=a,n.onRead(a)}),this.emit("read",r)},t.prototype.flip=function(t){var n=this;void 0===t&&(t=document.documentElement);var e=this.selector(t),r={},a=!1;o(e,function(e){var o=n.getKey(e),s=n.bounds[o],u=n.getBounds(e),f=n.animations[o],l=n.getDelta(s,u);if(c(l)){a=!0;var p={key:o,node:e,first:s,last:u,delta:n.getDelta(s,u),type:s?u?"MOVE":"LEAVE":"ENTER",animation:f},h=n.onFlip(p,function(){return n.read(t)});r[o]=i({},p,{animation:h}),n.animations[o]=h}}),a&&this.emit("flip",r)},t.prototype.wrap=function(t){var n=this;return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];n.read();var r=t.apply(void 0,e);return n.flip(),r}},t}();n.default=l},5:function(t,n,e){"use strict";var o=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])};return function(n,e){function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}(),r=this&&this.__assign||Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++){n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},i=e(0),a=function(t){return function(n){var e=n.delta,o=n.node;return console.log(t),o.animate([{transformOrigin:"top left",transform:"translate("+e.left+"px, "+e.top+"px)"},{transformOrigin:"top left",transform:"translate(0,0) scale(1)"}],t)}},s=function(t){var n=t.animation;return n&&n.cancel&&n.cancel()},u={duration:3e3,easing:"ease"},f=function(t){function n(n){var e={duration:n.duration||u.duration,easing:n.easing||u.easing};return t.call(this,r({onRead:s,onFlip:a(e)},n))||this}return o(n,t),n}(i.default);t.exports=f}})});
{
"name": "flipping",
"version": "0.4.1",
"version": "0.4.2",
"description": "Flipping awesome animations.",

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

@@ -72,2 +72,8 @@ type Bounds = {

node.getAttribute('data-key');
const deltaChanged = (delta: Bounds): boolean => {
return !!delta.top
|| !!delta.left
|| (delta.width !== 1)
|| (delta.height !== 1);
};

@@ -146,2 +152,3 @@ class Flipping {

const fullState: {[key: string]: FlipState} = {};
let flipped = false;

@@ -153,3 +160,8 @@ forEach(nodes, (node) => {

const animation = this.animations[key];
const delta = this.getDelta(first, last)
if (!deltaChanged(delta)) return;
flipped = true;
const state: FlipState = {

@@ -171,3 +183,3 @@ key,

this.emit('flip', fullState);
if (flipped) this.emit('flip', fullState);
}

@@ -174,0 +186,0 @@ wrap(fn: Function): Function {

@@ -100,8 +100,6 @@ import Flipping, { FlippingOptions } from '../src/flipping';

describe('on flip', () => {
const mockNode = createMockNode();
const MockFlip = createMockFlip(mockNode, {
it('can subscribe to "flip" events and return the state', () => {
const mockNode = createMockNode();
const MockFlip = createMockFlip(mockNode, {});
});
it('can subscribe to "flip" events and return the state', () => {
MockFlip.on('flip', (state) => {

@@ -128,3 +126,16 @@ assert.property(state, 'test');

});
it('only flips if delta has changed', () => {
const mockNode = createMockNode();
const MockFlip = createMockFlip(mockNode, {});
MockFlip.on('flip', (state) => {
throw new Error('Fuck')
});
MockFlip.read(null);
MockFlip.flip(null);
});
});
});
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