creepyface
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.creepyFace=t()}(this,function(){"use strict";function n(t){if(!t)return Promise.reject();if("string"==typeof t){var e=t;(t=new Image).src=e}else{if(void 0!==t.length){var r=[].map.call(t,function(t){return n(t).catch(function(n){return n})});return Promise.all(r).then(function(n){var t=n.filter(function(n){return n.naturalWidth});return t.length===n.length?t:Promise.reject({loaded:t,errored:n.filter(function(n){return!n.naturalWidth})})})}if("IMG"!==t.tagName)return Promise.reject()}var o=new Promise(function(n,e){function r(){t.naturalWidth?n(t):e(t),t.removeEventListener("load",r),t.removeEventListener("error",r)}t.naturalWidth?n(t):t.complete?e(t):(t.addEventListener("load",r),t.addEventListener("error",r))});return o.image=t,o}function t(n){n.forEach(function(n){n.style.position="fixed",n.style.height="0px";var t=document.body;t&&(t.appendChild(n),setTimeout(function(){return t.removeChild(n)},1e3))})}function e(n,e){return a(s(e)).then(function(e){n.creepyFaceReachableImages=e,f&&t(e)})}function r(n){return function(t){var e;return e=/^data\-/.test(t.name),void 0===n?e:e&&n.test(t.name.slice(5))}}function o(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function i(n){var t=l(n),e=t.src,r=void 0===e?{}:e,o=t.fieldofvision,i=t.timetodefault,u={src:n.getAttribute("src")};return i&&(u.timeToDefault=parseFloat(i)),o&&(u.fieldOfVision=parseFloat(o)),r.hover&&(u.hover=r.hover),r.look&&(u.looks=O(r.look)),u}function u(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=Object.assign({},i(n),t);if(!e.src)throw new Error("A default URL must be specified");return{fieldOfVision:e.fieldOfVision||150,src:e.src,hover:e.hover||"",points:e.points||D([h,x]),looks:e.looks||[],timeToDefault:e.timeToDefault||1e3,onDebug:e.onDebug||function(){},onAttach:e.onAttach||function(){},onDetach:e.onDetach||function(){}}}function c(n,t){var e=function(){},r=X(n,function(){e=W(n,t)},function(){e()});return function(){r(),e()}}var a=n,f="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=function(n){var t=n.looks.map(function(n){return n.src});return n.src&&t.push(n.src),n.hover&&t.push(n.hover),t},l=function(n,t){var e={};return void 0===(t=t||{}).separator&&(t.separator="-"),Array.prototype.slice.call(n.attributes).filter(r(t.pattern)).forEach(function(n){n.name.slice(5).split(t.separator).reduce(function(t,e,r,o){return"data"===e?t:(r===o.length-1?t[e]=n.value:t[e]=t[e]||{},t[e])},e)}),e},d=function(){function n(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}}(),v=function(){function n(t){o(this,n),this.subscriber=function(n){return function(){}},this.subscriber=t}return d(n,[{key:"subscribe",value:function(n){var t={next:n},e=this.subscriber(t);return"function"==typeof e?{unsubscribe:e}:e}}]),n}(),h=new v(function(n){var t=function(t){return n.next([t.clientX,t.clientY])};return document.addEventListener("mousemove",t,!0),function(){return document.removeEventListener("mousemove",t,!0)}}),m=function(n,t){return n.map(function(n,e){return n-t[e]})},b=function(n,t){return n.map(function(n,e){return n+t[e]})},p=function(n){return n?n<0?-1:1:0},y=function(n){return n*Math.PI/180},g=function(n){return 180*n/Math.PI},w=function(n,t){return(t+n%t)%t},E=function(n){return g(w(Math.atan2(n[1],n[0]),2*Math.PI))},M=function(n,t){return[n[0]*Math.cos(y(t))-n[1]*Math.sin(y(t)),n[0]*Math.sin(y(t))+n[1]*Math.cos(y(t))]},x=new v(function(n){var t=function(t){var e=[0,0],r=!0,o=!1,i=void 0;try{for(var u,c=t.touches[Symbol.iterator]();!(r=(u=c.next()).done);r=!0){var a=u.value;e=b(e,[a.clientX,a.clientY])}}catch(n){o=!0,i=n}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}n.next(e)};return document.addEventListener("touchmove",t,!0),function(){return document.removeEventListener("touchmove",t,!0)}}),D=function(n){return new v(function(t){var e=t.next.bind(t),r=n.map(function(n){return n.subscribe(e)});return function(){return r.forEach(function(n){return n.unsubscribe()})}})},O=function(n){var t=[],e=!0,r=!1,o=void 0;try{for(var i,u=Object.keys(n)[Symbol.iterator]();!(e=(i=u.next()).done);e=!0){var c=i.value,a=n[c];a&&t.push({angle:parseFloat(c),src:a})}}catch(n){r=!0,o=n}finally{try{!e&&u.return&&u.return()}finally{if(r)throw o}}return t},L=function(n){var t=n.getBoundingClientRect();return{y:t.top+window.pageYOffset+t.height/2,x:t.left+window.pageXOffset+t.width/2}},T=function(n){var t=L(n);return[t.x,t.y]},j=function(n,t){return E(M(m(b([window.scrollX,window.scrollY],t),T(n)),90))},k=function(){function n(n,t){var e=[],r=!0,o=!1,i=void 0;try{for(var u,c=n[Symbol.iterator]();!(r=(u=c.next()).done)&&(e.push(u.value),!t||e.length!==t);r=!0);}catch(n){o=!0,i=n}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return e}return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return n(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=function(n){return Math.abs(n)>180?n-360*p(n):n},P=function(n){return function(t,e){return Math.abs(I(t.angle-n))-Math.abs(I(e.angle-n))}},A=function(n,t){return t.slice(0).sort(P(n))[0]},F=function(n,t,e){return n>=t&&n<=e},N=function(n,t){var e=n.left,r=n.top,o=n.right,i=n.bottom,u=k(t,2),c=u[0],a=u[1];return F(c,e,o)&&F(a,r,i)},S=function(n,t){var e=k(t,2),r=e[0],o=e[1];return document.elementFromPoint?document.elementFromPoint(r,o)===n:N(n.getBoundingClientRect(),[r,o])},C=function(n,t,e,r){var o=r.looks,i=r.hover,u=r.fieldOfVision,c=r.src;if(i&&S(n,t))c=i;else{var a=A(e,o);a&&Math.abs(I(a.angle-e))<u/2&&(c=a.src)}return c},R=function(n,t,e){function r(){var f=Date.now()-c;f<t&&f>=0?o=setTimeout(r,t-f):(o=null,e||(a=n.apply(u,i),u=i=null))}var o,i,u,c,a;null==t&&(t=100);var f=function(){u=this,i=arguments,c=Date.now();var f=e&&!o;return o||(o=setTimeout(r,t)),f&&(a=n.apply(u,i),u=i=null),a};return f.clear=function(){o&&(clearTimeout(o),o=null)},f},V=function(n,t){return new v(function(e){var r=R(function(){return e.next({src:t.src,options:t})},t.timeToDefault);return t.points.subscribe(function(o){var i=j(n,o),u=C(n,o,i,t);e.next({point:o,angle:i,src:u,options:t}),r()})})},W=function(n,t){var r=u(n,t),o=function(t){n.src=t},i=e(n,r).then(function(){return r.onAttach(),V(n,r).subscribe(function(n){o(n.src),r.onDebug(n)})});return function(){return i.then(function(n){n.unsubscribe(),o(r.src),r.onDetach()})}},X=function(n,t,e){var r=function(n){return n?t():e()},o=window.IntersectionObserver,i=window.MutationObserver;if(o){var u=new o(function(n){n.length>0&&r(n[0].isIntersecting)},{});return u.observe(n),function(){return u.disconnect()}}if(i){var c=document.body&&document.body.contains(n);c&&r(!0);var a=new i(function(t){var e=document.body&&document.body.contains(n);!e&&c?(r(!1),c=!1):e&&!c&&(r(!0),c=!0)});return a.observe(document,{childList:!0,subtree:!0}),function(){return a.disconnect()}}return document.body&&document.body.contains(n)&&r(!0),n.addEventListener("DOMNodeInserted",function(){return r(!0)},!1),n.addEventListener("DOMNodeRemoved",function(){return r(!1)},!1),function(){}},Y=function(n){return!(!n||"object"!=typeof n)&&("object"==typeof window&&"object"==typeof window.Node?n instanceof window.Node:"number"==typeof n.nodeType&&"string"==typeof n.nodeName)};return function(n){return Y(n)?[n]:"string"==typeof n?[].slice.call(document.querySelectorAll(n)):void 0}("img[data-creepy]").forEach(function(n){n instanceof HTMLImageElement&&c(n)}),c}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.creepyFace=t()}(this,function(){"use strict";function n(t){if(!t)return Promise.reject();if("string"==typeof t){var e=t;(t=new Image).src=e}else{if(void 0!==t.length){var r=[].map.call(t,function(t){return n(t).catch(function(n){return n})});return Promise.all(r).then(function(n){var t=n.filter(function(n){return n.naturalWidth});return t.length===n.length?t:Promise.reject({loaded:t,errored:n.filter(function(n){return!n.naturalWidth})})})}if("IMG"!==t.tagName)return Promise.reject()}var o=new Promise(function(n,e){function r(){t.naturalWidth?n(t):e(t),t.removeEventListener("load",r),t.removeEventListener("error",r)}t.naturalWidth?n(t):t.complete?e(t):(t.addEventListener("load",r),t.addEventListener("error",r))});return o.image=t,o}function t(n){n.forEach(function(n){n.style.position="fixed",n.style.height="0px";var t=document.body;t&&(t.appendChild(n),setTimeout(function(){return t.removeChild(n)},1e3))})}function e(n,e){return a(s(e)).then(function(e){n.creepyFaceReachableImages=e,f&&t(e)})}function r(n){return function(t){var e;return e=/^data\-/.test(t.name),void 0===n?e:e&&n.test(t.name.slice(5))}}function o(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}function i(n){var t=l(n),e=t.src,r=void 0===e?{}:e,o=t.fieldofvision,i=t.timetodefault,u={src:n.getAttribute("src")};return i&&(u.timeToDefault=parseFloat(i)),o&&(u.fieldOfVision=parseFloat(o)),r.hover&&(u.hover=r.hover),r.look&&(u.looks=O(r.look)),u}function u(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=Object.assign({},i(n),t);if(!e.src)throw new Error("A default URL must be specified");return{fieldOfVision:e.fieldOfVision||150,src:e.src,hover:e.hover||"",points:e.points||D([h,x]),looks:e.looks||[],timeToDefault:e.timeToDefault||1e3,onDebug:e.onDebug||function(){},onAttach:e.onAttach||function(){},onDetach:e.onDetach||function(){}}}function c(n,t){var e=function(){},r=X(n,function(){e=W(n,t)},function(){e()});return function(){r(),e()}}var a=n,f="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=function(n){var t=n.looks.map(function(n){return n.src});return n.src&&t.push(n.src),n.hover&&t.push(n.hover),t},l=function(n,t){var e={};return void 0===(t=t||{}).separator&&(t.separator="-"),Array.prototype.slice.call(n.attributes).filter(r(t.pattern)).forEach(function(n){n.name.slice(5).split(t.separator).reduce(function(t,e,r,o){return"data"===e?t:(r===o.length-1?t[e]=n.value:t[e]=t[e]||{},t[e])},e)}),e},d=function(){function n(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}}(),v=function(){function n(t){o(this,n),this.subscriber=function(n){return function(){}},this.subscriber=t}return d(n,[{key:"subscribe",value:function(n){var t={next:n},e=this.subscriber(t);return"function"==typeof e?{unsubscribe:e}:e}}]),n}(),h=new v(function(n){var t=function(t){return n.next([t.clientX,t.clientY])};return document.addEventListener("mousemove",t,!0),function(){return document.removeEventListener("mousemove",t,!0)}}),m=function(n,t){return n.map(function(n,e){return n-t[e]})},p=function(n,t){return n.map(function(n,e){return n+t[e]})},b=function(n){return n?n<0?-1:1:0},y=function(n){return n*Math.PI/180},g=function(n){return 180*n/Math.PI},w=function(n,t){return(t+n%t)%t},E=function(n){return g(w(Math.atan2(n[1],n[0]),2*Math.PI))},M=function(n,t){return[n[0]*Math.cos(y(t))-n[1]*Math.sin(y(t)),n[0]*Math.sin(y(t))+n[1]*Math.cos(y(t))]},x=new v(function(n){var t=function(t){var e=[0,0],r=!0,o=!1,i=void 0;try{for(var u,c=t.touches[Symbol.iterator]();!(r=(u=c.next()).done);r=!0){var a=u.value;e=p(e,[a.clientX,a.clientY])}}catch(n){o=!0,i=n}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}n.next(e)};return document.addEventListener("touchmove",t,!0),function(){return document.removeEventListener("touchmove",t,!0)}}),D=function(n){return new v(function(t){var e=t.next.bind(t),r=n.map(function(n){return n.subscribe(e)});return function(){return r.forEach(function(n){return n.unsubscribe()})}})},O=function(n){var t=[],e=!0,r=!1,o=void 0;try{for(var i,u=Object.keys(n)[Symbol.iterator]();!(e=(i=u.next()).done);e=!0){var c=i.value,a=n[c];a&&t.push({angle:parseFloat(c),src:a})}}catch(n){r=!0,o=n}finally{try{!e&&u.return&&u.return()}finally{if(r)throw o}}return t},L=function(n){var t=n.getBoundingClientRect();return{y:t.top+window.pageYOffset+t.height/2,x:t.left+window.pageXOffset+t.width/2}},T=function(n){var t=L(n);return[t.x,t.y]},j=function(n,t){return E(M(m(p([window.scrollX,window.scrollY],t),T(n)),90))},k=function(){function n(n,t){var e=[],r=!0,o=!1,i=void 0;try{for(var u,c=n[Symbol.iterator]();!(r=(u=c.next()).done)&&(e.push(u.value),!t||e.length!==t);r=!0);}catch(n){o=!0,i=n}finally{try{!r&&c.return&&c.return()}finally{if(o)throw i}}return e}return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return n(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=function(n){return Math.abs(n)>180?n-360*b(n):n},P=function(n){return function(t,e){return Math.abs(I(t.angle-n))-Math.abs(I(e.angle-n))}},A=function(n,t){return t.slice(0).sort(P(n))[0]},F=function(n,t,e){return n>=t&&n<=e},N=function(n,t){var e=n.left,r=n.top,o=n.right,i=n.bottom,u=k(t,2),c=u[0],a=u[1];return F(c,e,o)&&F(a,r,i)},S=function(n,t){var e=k(t,2),r=e[0],o=e[1];return document.elementFromPoint?document.elementFromPoint(r,o)===n:N(n.getBoundingClientRect(),[r,o])},C=function(n,t,e,r){var o=r.looks,i=r.hover,u=r.fieldOfVision,c=r.src;if(i&&S(n,t))c=i;else{var a=A(e,o);a&&Math.abs(I(a.angle-e))<u/2&&(c=a.src)}return c},R=function(n,t,e){function r(){var f=Date.now()-c;f<t&&f>=0?o=setTimeout(r,t-f):(o=null,e||(a=n.apply(u,i),u=i=null))}var o,i,u,c,a;null==t&&(t=100);var f=function(){u=this,i=arguments,c=Date.now();var f=e&&!o;return o||(o=setTimeout(r,t)),f&&(a=n.apply(u,i),u=i=null),a};return f.clear=function(){o&&(clearTimeout(o),o=null)},f.flush=function(){o&&(a=n.apply(u,i),u=i=null,clearTimeout(o),o=null)},f},V=function(n,t){return new v(function(e){var r=R(function(){return e.next({src:t.src,options:t})},t.timeToDefault);return t.points.subscribe(function(o){var i=j(n,o),u=C(n,o,i,t);e.next({point:o,angle:i,src:u,options:t}),r()})})},W=function(n,t){var r=u(n,t),o=function(t){n.src=t},i=e(n,r).then(function(){return r.onAttach(),V(n,r).subscribe(function(n){o(n.src),r.onDebug(n)})});return function(){return i.then(function(n){n.unsubscribe(),o(r.src),r.onDetach()})}},X=function(n,t,e){var r=function(n){return n?t():e()},o=window.IntersectionObserver,i=window.MutationObserver;if(o){var u=new o(function(n){n.length>0&&r(n[0].isIntersecting)},{});return u.observe(n),function(){return u.disconnect()}}if(i){var c=document.body&&document.body.contains(n);c&&r(!0);var a=new i(function(t){var e=document.body&&document.body.contains(n);!e&&c?(r(!1),c=!1):e&&!c&&(r(!0),c=!0)});return a.observe(document,{childList:!0,subtree:!0}),function(){return a.disconnect()}}return document.body&&document.body.contains(n)&&r(!0),n.addEventListener("DOMNodeInserted",function(){return r(!0)},!1),n.addEventListener("DOMNodeRemoved",function(){return r(!1)},!1),function(){}},Y=function(n){return!(!n||"object"!=typeof n)&&("object"==typeof window&&"object"==typeof window.Node?n instanceof window.Node:"number"==typeof n.nodeType&&"string"==typeof n.nodeName)};return function(n){return Y(n)?[n]:"string"==typeof n?[].slice.call(document.querySelectorAll(n)):void 0}("img[data-creepy]").forEach(function(n){n instanceof HTMLImageElement&&c(n)}),c}); |
{ | ||
"name": "creepyface", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"author": "Alejandro Tardín <alejandro@tardin.com>", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"babel-eslint": "^8.0.1", | ||
"babel-eslint": "7.2.1", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
@@ -16,0 +16,0 @@ "babel-preset-env": "^1.6.0", |
# Creepy Face | ||
Creepy Face is a little JavaScript tool (<3K minified & gzipped) for making your face follow the mouse (or fingers). It is ideal for resumes, team presentation sites, etc... | ||
Creepy Face is a little JavaScript tool (<3K minified & gzipped) that makes your face follow the mouse (or fingers). It is ideal for resumes, team presentation sites, etc... | ||
@@ -39,3 +39,3 @@ ![Example animated gif of a face following the pointer](example.gif) | ||
Creepy Face will automatically detect your image (thanks to the `data-creepy` attribute) and make it follow the mouse or fingers depending on which device you are. | ||
Creepy Face will automatically detect your image (thanks to the `data-creepy` attribute) and make it follow the mouse or fingers depending on which device you are using. | ||
@@ -42,0 +42,0 @@ You can add as many creepy faces as you want as long as they all have the `data-creepy` attribute. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37104