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

creepyface

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

creepyface - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

14

dist/creepyface.cjs.js

@@ -32,3 +32,3 @@ 'use strict';

});
if (options.default) srcs.push(options.default);
if (options.src) srcs.push(options.src);
if (options.hover) srcs.push(options.hover);

@@ -210,3 +210,3 @@ return srcs;

var options = {
default: element.getAttribute('src')
src: element.getAttribute('src')
};

@@ -227,7 +227,7 @@

if (!userOptions.default) throw new Error('A default URL must be specified');
if (!userOptions.src) throw new Error('A default URL must be specified');
return {
fieldOfVision: userOptions.fieldOfVision || 150,
default: userOptions.default,
src: userOptions.src,
hover: userOptions.hover || '',

@@ -295,3 +295,3 @@ points: userOptions.points || combined([mousePoints, fingerPoints]),

var src = options.default;
var src = options.src;

@@ -313,3 +313,3 @@ if (hover && elementContains(img, point)) {

var backToDefault = debounce(function () {
return observer.next({ src: options.default, options: options });
return observer.next({ src: options.src, options: options });
}, options.timeToDefault);

@@ -340,3 +340,3 @@ return options.points.subscribe(function (point) {

subscription.unsubscribe();
setSrc(options.default);
setSrc(options.src);
});

@@ -343,0 +343,0 @@ };

@@ -28,3 +28,3 @@ import loadImages from 'image-promise';

});
if (options.default) srcs.push(options.default);
if (options.src) srcs.push(options.src);
if (options.hover) srcs.push(options.hover);

@@ -206,3 +206,3 @@ return srcs;

var options = {
default: element.getAttribute('src')
src: element.getAttribute('src')
};

@@ -223,7 +223,7 @@

if (!userOptions.default) throw new Error('A default URL must be specified');
if (!userOptions.src) throw new Error('A default URL must be specified');
return {
fieldOfVision: userOptions.fieldOfVision || 150,
default: userOptions.default,
src: userOptions.src,
hover: userOptions.hover || '',

@@ -291,3 +291,3 @@ points: userOptions.points || combined([mousePoints, fingerPoints]),

var src = options.default;
var src = options.src;

@@ -309,3 +309,3 @@ if (hover && elementContains(img, point)) {

var backToDefault = debounce(function () {
return observer.next({ src: options.default, options: options });
return observer.next({ src: options.src, options: options });
}, options.timeToDefault);

@@ -336,3 +336,3 @@ return options.points.subscribe(function (point) {

subscription.unsubscribe();
setSrc(options.default);
setSrc(options.src);
});

@@ -339,0 +339,0 @@ };

@@ -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 c(l(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 u(n){var t=s(n),e=t.src,r=void 0===e?{}:e,o=t.fieldofvision,u=t.timetodefault,i={default:n.getAttribute("src")};return u&&(i.timeToDefault=parseFloat(u)),o&&(i.fieldOfVision=parseFloat(o)),r.hover&&(i.hover=r.hover),r.look&&(i.looks=T(r.look)),i}function i(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=Object.assign({},u(n),t);if(!e.default)throw new Error("A default URL must be specified");return{fieldOfVision:e.fieldOfVision||150,default:e.default,hover:e.hover||"",points:e.points||O([h,M]),looks:e.looks||[],timeToDefault:e.timeToDefault||1e3,debug:e.debug||function(){}}}function a(n,t){var e=function(){},r=X(n,function(){e=W(n,t)},function(){e()});return function(){r(),e()}}var c=n,f="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),l=function(n){var t=n.looks.map(function(n){return n.src});return n.default&&t.push(n.default),n.hover&&t.push(n.hover),t},s=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},x=function(n){return g(w(Math.atan2(n[1],n[0]),2*Math.PI))},E=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))]},M=new v(function(n){var t=function(t){var e=[0,0],r=!0,o=!1,u=void 0;try{for(var i,a=t.touches[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var c=i.value;e=p(e,[c.clientX,c.clientY])}}catch(n){o=!0,u=n}finally{try{!r&&a.return&&a.return()}finally{if(o)throw u}}n.next(e)};return document.addEventListener("touchmove",t,!0),function(){return document.removeEventListener("touchmove",t,!0)}}),O=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()})}})},T=function(n){var t=[],e=!0,r=!1,o=void 0;try{for(var u,i=Object.keys(n)[Symbol.iterator]();!(e=(u=i.next()).done);e=!0){var a=u.value,c=n[a];c&&t.push({angle:parseFloat(a),src:c})}}catch(n){r=!0,o=n}finally{try{!e&&i.return&&i.return()}finally{if(r)throw o}}return t},j=function(n){var t=n.getBoundingClientRect();return{y:t.top+window.pageYOffset+t.height/2,x:t.left+window.pageXOffset+t.width/2}},k=function(n){var t=j(n);return[t.x,t.y]},L=function(n,t){return x(E(m(t,k(n)),90))},P=function(){function n(n,t){var e=[],r=!0,o=!1,u=void 0;try{for(var i,a=n[Symbol.iterator]();!(r=(i=a.next()).done)&&(e.push(i.value),!t||e.length!==t);r=!0);}catch(n){o=!0,u=n}finally{try{!r&&a.return&&a.return()}finally{if(o)throw u}}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")}}(),F=function(n){return Math.abs(n)>180?n-360*b(n):n},I=function(n){return function(t,e){return Math.abs(F(t.angle-n))-Math.abs(F(e.angle-n))}},A=function(n,t){return t.slice(0).sort(I(n))[0]},N=function(n,t,e){return n>=t&&n<=e},D=function(n,t){var e=n.left,r=n.top,o=n.right,u=n.bottom,i=P(t,2),a=i[0],c=i[1];return N(a,e,o)&&N(c,r,u)},S=function(n,t){var e=P(t,2),r=e[0],o=e[1];return document.elementFromPoint?document.elementFromPoint(r,o)===n:D(n.getBoundingClientRect(),[r,o])},C=function(n,t,e,r){var o=r.looks,u=r.hover,i=r.fieldOfVision,a=r.default;if(u&&S(n,t))a=u;else{var c=A(e,o);c&&Math.abs(F(c.angle-e))<i/2&&(a=c.src)}return a},R=function(n,t,e){function r(){var f=Date.now()-a;f<t&&f>=0?o=setTimeout(r,t-f):(o=null,e||(c=n.apply(i,u),i=u=null))}var o,u,i,a,c;null==t&&(t=100);var f=function(){i=this,u=arguments,a=Date.now();var f=e&&!o;return o||(o=setTimeout(r,t)),f&&(c=n.apply(i,u),i=u=null),c};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.default,options:t})},t.timeToDefault);return t.points.subscribe(function(o){var u=L(n,o),i=C(n,o,u,t);e.next({point:o,angle:u,src:i,options:t}),r()})})},W=function(n,t){var r=i(n,t),o=function(t){n.src=t},u=e(n,r).then(function(){return V(n,r).subscribe(function(n){o(n.src),r.debug(n)})});return function(){return u.then(function(n){n.unsubscribe(),o(r.default)})}},X=function(n,t,e){var r=!!n.parentNode;if(r&&t(),!window.MutationObserver)return function(){};var o=new window.MutationObserver(function(o){!n.parentNode&&r?(e(),r=!1):n.parentNode&&!r&&(t(),r=!0)});return o.observe(document,{childList:!0,subtree:!0}),function(){return o.disconnect()}},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&&a(n)}),a});
!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=T(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||O([h,M]),looks:e.looks||[],timeToDefault:e.timeToDefault||1e3,debug:e.debug||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},x=function(n){return g(w(Math.atan2(n[1],n[0]),2*Math.PI))},E=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))]},M=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)}}),O=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()})}})},T=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},j=function(n){var t=n.getBoundingClientRect();return{y:t.top+window.pageYOffset+t.height/2,x:t.left+window.pageXOffset+t.width/2}},k=function(n){var t=j(n);return[t.x,t.y]},L=function(n,t){return x(E(m(t,k(n)),90))},P=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")}}(),F=function(n){return Math.abs(n)>180?n-360*b(n):n},I=function(n){return function(t,e){return Math.abs(F(t.angle-n))-Math.abs(F(e.angle-n))}},A=function(n,t){return t.slice(0).sort(I(n))[0]},N=function(n,t,e){return n>=t&&n<=e},D=function(n,t){var e=n.left,r=n.top,o=n.right,i=n.bottom,u=P(t,2),c=u[0],a=u[1];return N(c,e,o)&&N(a,r,i)},S=function(n,t){var e=P(t,2),r=e[0],o=e[1];return document.elementFromPoint?document.elementFromPoint(r,o)===n:D(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(F(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=L(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 V(n,r).subscribe(function(n){o(n.src),r.debug(n)})});return function(){return i.then(function(n){n.unsubscribe(),o(r.src)})}},X=function(n,t,e){var r=!!n.parentNode;if(r&&t(),!window.MutationObserver)return function(){};var o=new window.MutationObserver(function(o){!n.parentNode&&r?(e(),r=!1):n.parentNode&&!r&&(t(),r=!0)});return o.observe(document,{childList:!0,subtree:!0}),function(){return o.disconnect()}},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": "2.0.0",
"version": "3.0.0",
"author": "Alejandro Tardín <alejandro@tardin.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

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