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 4.1.4 to 4.1.5

dist/observables/util/debounce.d.ts

7

dist/creepyface.js

@@ -23,8 +23,9 @@ import attach from './util/attach';

document.addEventListener('DOMContentLoaded', () => {
;
[...document.querySelectorAll('img[data-creepy]')].forEach(el => {
const elements = document.querySelectorAll('img[data-creepy]');
for (let i = 0; i < elements.length; i++) {
const el = elements[i];
if (el instanceof HTMLImageElement)
creepyface(el);
});
}
});
export default creepyface;

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).creepyface=t()}(this,function(){"use strict";function o(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)}}function h(n,t){return function(n){if(Array.isArray(n))return n}(n)||function(n,t){var e=[],r=!0,o=!1,i=void 0;try{for(var u,a=n[Symbol.iterator]();!(r=(u=a.next()).done)&&(e.push(u.value),!t||e.length!==t);r=!0);}catch(n){o=!0,i=n}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return e}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function n(n){return function(n){if(Array.isArray(n)){for(var t=0,e=new Array(n.length);t<n.length;t++)e[t]=n[t];return e}}(n)||function(n){if(Symbol.iterator in Object(n)||"[object Arguments]"===Object.prototype.toString.call(n))return Array.from(n)}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var f=function t(r){if(!r)return Promise.reject();if("string"==typeof r){var n=r;(r=new Image).src=n}else{if(void 0!==r.length){var e=[].map.call(r,function(n){return t(n).catch(function(n){return n})});return Promise.all(e).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"!==r.tagName)return Promise.reject()}var o=new Promise(function(n,t){function e(){r.naturalWidth?n(r):t(r),r.removeEventListener("load",e),r.removeEventListener("error",e)}r.naturalWidth?n(r):r.complete?t(r):(r.addEventListener("load",e),r.addEventListener("error",e))});return o.image=r,o};var v=function(n,t){var e,r={};return void 0===(t=t||{}).separator&&(t.separator="-"),Array.prototype.slice.call(n.attributes).filter((e=t.pattern,function(n){var t;return t=/^data\-/.test(n.name),void 0===e?t:t&&e.test(n.name.slice(5))})).forEach(function(o){o.name.slice(5).split(t.separator).reduce(function(n,t,e,r){return"data"===t?n:(e===r.length-1?n[t]=o.value:n[t]=n[t]||{},n[t])},r)}),r};var p=function(){function t(n){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.subscriber=n}var n,e,r;return n=t,(e=[{key:"subscribe",value:function(n){return{unsubscribe:this.subscriber({next:n})}}}])&&o(n.prototype,e),r&&o(n,r),t}(),e=[];document.addEventListener("mousemove",function(t){return e.forEach(function(n){return n.next([t.clientX,t.clientY])})},!0);var m=new p(function(n){return e.push(n),function(){e.splice(e.indexOf(n),1)}}),l=function(n,e){return n.map(function(n,t){return n+e[t]})},a=function(n){return n*Math.PI/180},c=function(n){return t=Math.atan2(n[1],n[0]),e=2*Math.PI,180*((e+t%e)%e)/Math.PI;var t,e},t=[];document.addEventListener("touchmove",function(c){return t.forEach(function(n){var t=[0,0],e=!0,r=!1,o=void 0;try{for(var i,u=c.touches[Symbol.iterator]();!(e=(i=u.next()).done);e=!0){var a=i.value;t=l(t,[a.clientX,a.clientY])}}catch(n){r=!0,o=n}finally{try{e||null==u.return||u.return()}finally{if(r)throw o}}n.next(t)})},!0);var b=new p(function(n){return t.push(n),function(){t.splice(t.indexOf(n),1)}}),y=function(){},g=function(n){for(var t=[],e=Object.keys(n),r=0;r<e.length;r++){var o=e[r],i=n[o];i&&t.push({angle:parseFloat(o),src:i})}return t};function s(n){var t,e,r,o,i,u,a,c,f,l,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},d=Object.assign({},(e=v(t=n),r=e.src,o=void 0===r?{}:r,i=e.fieldofvision,u=e.timetodefault,a=e.resetoncancel,c=e.throttle,f={src:t.getAttribute("src")||void 0},u&&(f.timeToDefault=parseFloat(u)),c&&(f.throttle=parseFloat(c)),i&&(f.fieldOfVision=parseFloat(i)),a&&(f.resetOnCancel="true"===a),o.hover&&(f.hover=o.hover),o.look&&(f.looks=g(o.look)),f),s);if(!d.src)throw new Error("A default URL must be specified");return{fieldOfVision:d.fieldOfVision||150,src:d.src,hover:d.hover||"",points:d.points||(l=[m,b],new p(function(n){var t=n.next.bind(n),e=l.map(function(n){return n.subscribe(t)});return function(){return e.forEach(function(n){return n.unsubscribe()})}})),looks:d.looks||[],timeToDefault:d.timeToDefault||1e3,resetOnCancel:!(!1===d.resetOnCancel),throttle:d.throttle||100,onDebug:d.onDebug||y,onAttach:d.onAttach||y,onDetach:d.onDetach||y}}var d=function(n){var t=n.getBoundingClientRect(),e=t.top+window.pageYOffset+t.height/2,r=t.left+window.pageXOffset+t.width/2;return{y:e,x:r}};var w=function(n,t){return c((o=l([window.scrollX,window.scrollY],t),u=d(n),i=[u.x,u.y],e=o.map(function(n,t){return n-i[t]}),r=90,[e[0]*Math.cos(a(r))-e[1]*Math.sin(a(r)),e[0]*Math.sin(a(r))+e[1]*Math.cos(a(r))]));var e,r,o,i,u},O=function(n){return 180<Math.abs(n)?n-360*((t=n)?t<0?-1:1:0):n;var t},E=function(n,t){return t.slice(0).sort((e=n,function(n,t){return Math.abs(O(n.angle-e))-Math.abs(O(t.angle-e))}))[0];var e},M=function(n,t,e){return t<=n&&n<=e},j=function(n,t){var e,r,o,i,u,a,c,f,l,s=h(t,2),d=s[0],v=s[1];return document.elementFromPoint?document.elementFromPoint(d,v)===n:(e=n.getBoundingClientRect(),r=[d,v],o=e.left,i=e.top,u=e.right,a=e.bottom,c=h(r,2),f=c[0],l=c[1],M(f,o,u)&&M(l,i,a))},r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},x="Expected a function",i=NaN,u="[object Symbol]",T=/^\s+|\s+$/g,D=/^[-+]0x[0-9a-f]+$/i,A=/^0b[01]+$/i,L=/^0o[0-7]+$/i,C=parseInt,I="object"==typeof r&&r&&r.Object===Object&&r,P="object"==typeof self&&self&&self.Object===Object&&self,k=I||P||Function("return this")(),F=Object.prototype.toString,S=Math.max,W=Math.min,R=function(){return k.Date.now()};function N(r,o,n){var i,u,a,c,f,l,s=0,d=!1,v=!1,t=!0;if("function"!=typeof r)throw new TypeError(x);function h(n){var t=i,e=u;return i=u=void 0,s=n,c=r.apply(e,t)}function p(n){var t=n-l;return void 0===l||o<=t||t<0||v&&a<=n-s}function m(){var n,t,e=R();if(p(e))return b(e);f=setTimeout(m,(t=o-((n=e)-l),v?W(t,a-(n-s)):t))}function b(n){return f=void 0,t&&i?h(n):(i=u=void 0,c)}function e(){var n,t=R(),e=p(t);if(i=arguments,u=this,l=t,e){if(void 0===f)return s=n=l,f=setTimeout(m,o),d?h(n):c;if(v)return f=setTimeout(m,o),h(l)}return void 0===f&&(f=setTimeout(m,o)),c}return o=X(o)||0,V(n)&&(d=!!n.leading,a=(v="maxWait"in n)?S(X(n.maxWait)||0,o):a,t="trailing"in n?!!n.trailing:t),e.cancel=function(){void 0!==f&&clearTimeout(f),i=l=u=f=void(s=0)},e.flush=function(){return void 0===f?c:b(R())},e}function V(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function X(n){if("number"==typeof n)return n;if("symbol"==typeof(t=n)||(e=t)&&"object"==typeof e&&F.call(t)==u)return i;var t,e;if(V(n)){var r="function"==typeof n.valueOf?n.valueOf():n;n=V(r)?r+"":r}if("string"!=typeof n)return 0===n?n:+n;n=n.replace(T,"");var o=A.test(n);return o||L.test(n)?C(n.slice(2),o?2:8):D.test(n)?i:+n}var Y=function(n,t,e){var r=!0,o=!0;if("function"!=typeof n)throw new TypeError(x);return V(e)&&(r="leading"in e?!!e.leading:r,o="trailing"in e?!!e.trailing:o),N(n,t,{leading:r,maxWait:t,trailing:o})},$=function(i,u){return new p(function(r){var o=function(t,e,r){var o,i,u,a,c;function f(){var n=Date.now()-a;n<e&&0<=n?o=setTimeout(f,e-n):(o=null,r||(c=t.apply(u,i),u=i=null))}null==e&&(e=100);var n=function(){u=this,i=arguments,a=Date.now();var n=r&&!o;return o||(o=setTimeout(f,e)),n&&(c=t.apply(u,i),u=i=null),c};return n.clear=function(){o&&(clearTimeout(o),o=null)},n.flush=function(){o&&(c=t.apply(u,i),u=i=null,clearTimeout(o),o=null)},n}(function(){return r.next({src:u.src,options:u})},u.timeToDefault),n=u.points.subscribe(Y(function(n){var t=w(i,n),e=function(n,t,e,r){var o=r.looks,i=r.hover,u=r.fieldOfVision,a=r.src;if(i&&j(n,t))a=i;else{var c=E(e,o);Math.abs(O(c.angle-e))<u/2&&(a=c.src)}return a}(i,n,t,u);r.next({point:n,angle:t,src:e,options:u}),o()},u.throttle));return function(){o.clear(),n.unsubscribe()}})},B=function(t,n){var e,r,o,i=s(t,n),u=function(n){t.src=n},a=(e=t,f((r=i,o=r.looks.map(function(n){return n.src}),r.src&&o.push(r.src),r.hover&&o.push(r.hover),o)).then(function(n){return e.creepyfaceReachableImages=n,function(){delete e.creepyfaceReachableImages}})),c=a.then(function(){return i.onAttach(),$(t,i).subscribe(function(n){u(n.src),i.onDebug(n)})});return function(){return c.then(function(n){return n.unsubscribe(),i.resetOnCancel&&u(i.src),i.onDetach(),a.then(function(n){return n()})})}},q=function n(t,e){n.cancel(t);var r=y,o=t,i=function(e,t,r){var o=function(n){return n?t():r()};if(MutationObserver){var i=document.body&&document.body.contains(e);i&&o(!0);var n=new MutationObserver(function(n){var t=document.body&&document.body.contains(e);!t&&i?(o(!1),i=!1):t&&!i&&(o(!0),i=!0)});return n.observe(document,{childList:!0,subtree:!0}),function(){return n.disconnect()}}return document.body&&document.body.contains(e)&&o(!0),e.addEventListener("DOMNodeInserted",function(){return o(!0)},!1),e.addEventListener("DOMNodeRemoved",function(){return o(!1)},!1),y}(t,function(){r=B(o,e)},function(){return n.cancel(t)});return o.creepyfaceCancel=function(){i(),r(),delete o.creepyfaceCancel}};return q.cancel=function(n){var t=n;t.creepyfaceCancel&&t.creepyfaceCancel()},document.addEventListener("DOMContentLoaded",function(){n(document.querySelectorAll("img[data-creepy]")).forEach(function(n){n instanceof HTMLImageElement&&q(n)})}),q});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).creepyface=t()}(this,function(){"use strict";var f=function t(r){if(!r)return Promise.reject();if("string"==typeof r){var e=r;(r=new Image).src=e}else{if(void 0!==r.length){var n=[].map.call(r,function(e){return t(e).catch(function(e){return e})});return Promise.all(n).then(function(e){var t=e.filter(function(e){return e.naturalWidth});return t.length===e.length?t:Promise.reject({loaded:t,errored:e.filter(function(e){return!e.naturalWidth})})})}if("IMG"!==r.tagName)return Promise.reject()}var o=new Promise(function(e,t){function n(){r.naturalWidth?e(r):t(r),r.removeEventListener("load",n),r.removeEventListener("error",n)}r.naturalWidth?e(r):r.complete?t(r):(r.addEventListener("load",n),r.addEventListener("error",n))});return o.image=r,o};var o=function(t){return{subscribe:function(e){return{unsubscribe:t({next:e})}}}},n=[];document.addEventListener("mousemove",function(t){return n.forEach(function(e){return e.next([t.clientX,t.clientY])})},!0);var u=o(function(e){return n.push(e),function(){n.splice(n.indexOf(e),1)}}),i=function(e,n){return e.map(function(e,t){return e+n[t]})},a=function(e){return e*Math.PI/180},s=function(e){return t=Math.atan2(e[1],e[0]),n=2*Math.PI,180*((n+t%n)%n)/Math.PI;var t,n},t=[];document.addEventListener("touchmove",function(o){return t.forEach(function(e){for(var t=[0,0],n=0;n<o.touches.length;n++){var r=o.touches[n];t=i(t,[r.clientX,r.clientY])}e.next(t)})},!0);var c=o(function(e){return t.push(e),function(){t.splice(t.indexOf(e),1)}}),l=function(){},r=function(e){var t=e?parseFloat(e):NaN;return isNaN(t)?void 0:t},d=function(e){return{src:e.getAttribute("src")||void 0,hover:e.getAttribute("data-src-hover")||void 0,looks:function(e){for(var t=/data-src-look-(\d+)/i,n=[],r=0;r<e.attributes.length;r++){var o=e.attributes[r],u=t.exec(o.name);u&&n.push({angle:parseFloat(u[1]),src:o.value})}return n.length?n:void 0}(e),timeToDefault:r(e.getAttribute("data-timetodefault")),throttle:r(e.getAttribute("data-throttle")),fieldOfVision:r(e.getAttribute("data-fieldofvision")),resetOnCancel:"true"===e.getAttribute("data-resetoncancel")}};function v(e){var n,t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=function(o){for(var e=1;e<arguments.length;e++){var u=null!=arguments[e]?arguments[e]:{},t=Object.keys(u);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(u).filter(function(e){return Object.getOwnPropertyDescriptor(u,e).enumerable}))),t.forEach(function(e){var t,n,r;t=o,r=u[n=e],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r})}return o}({},d(e),t);if(!r.src)throw new Error("A default URL must be specified");return{fieldOfVision:r.fieldOfVision||150,src:r.src,hover:r.hover||"",points:r.points||(n=[u,c],o(function(t){var e=n.map(function(e){return e.subscribe(t.next)});return function(){return e.forEach(function(e){return e.unsubscribe()})}})),looks:r.looks||[],timeToDefault:r.timeToDefault||1e3,resetOnCancel:!(!1===r.resetOnCancel),throttle:r.throttle||100,onDebug:r.onDebug||l,onAttach:r.onAttach||l,onDetach:r.onDetach||l}}var h=function(e){var t=e.getBoundingClientRect(),n=t.top+window.pageYOffset+t.height/2,r=t.left+window.pageXOffset+t.width/2;return{y:n,x:r}};var b=function(e,t){return s((o=i([window.scrollX,window.scrollY],t),c=h(e),u=[c.x,c.y],n=o.map(function(e,t){return e-u[t]}),r=90,[n[0]*Math.cos(a(r))-n[1]*Math.sin(a(r)),n[0]*Math.sin(a(r))+n[1]*Math.cos(a(r))]));var n,r,o,u,c},p=function(e){return 180<Math.abs(e)?e-360*((t=e)?t<0?-1:1:0):e;var t},g=function(e,t){return t.slice(0).sort((n=e,function(e,t){return Math.abs(p(e.angle-n))-Math.abs(p(t.angle-n))}))[0];var n},m=function(e,t,n){return t<=e&&e<=n},y=function(e,t){return document.elementFromPoint?document.elementFromPoint(t[0],t[1])===e:(n=e.getBoundingClientRect(),r=[t[0],t[1]],o=n.left,u=n.top,c=n.right,i=n.bottom,m(r[0],o,c)&&m(r[1],u,i));var n,r,o,u,c,i},O=function(h,m){return o(function(r){var e,t,n,o,u,c,i,a,f,s,l,d=(e=function(){return r.next({src:m.src,options:m})},t=m.timeToDefault,(o=function(){n&&clearTimeout(n),n=setTimeout(function(){n=null,e()},t)}).clear=function(){n&&(clearTimeout(n),n=null)},o),v=m.points.subscribe((u=function(e){var t=b(h,e),n=function(e,t,n,r){var o=r.looks,u=r.hover,c=r.fieldOfVision,i=r.src;if(u&&y(e,t))i=u;else{var a=g(n,o);Math.abs(p(a.angle-n))<c/2&&(i=a.src)}return i}(h,e,t,m);r.next({point:e,angle:t,src:n,options:m}),d()},c=m.throttle,f=0,s=function(){f=Date.now(),i=null,u(a)},(l=function(e){var t=Date.now(),n=c-(t-f);a=e,n<=0||c<n?(i&&(clearTimeout(i),i=null),f=t,u(e)):i||(i=setTimeout(s,n))}).clear=function(){i&&clearTimeout(i),f=0,i=null},l));return function(){d.clear(),v.unsubscribe()}})},w=function(t,e){var n,r,o,u=v(t,e),c=function(e){t.src=e},i=(n=t,f((r=u,o=r.looks.map(function(e){return e.src}),r.src&&o.push(r.src),r.hover&&o.push(r.hover),o)).then(function(e){return n.creepyfaceReachableImages=e,function(){delete n.creepyfaceReachableImages}})),a=i.then(function(){return u.onAttach(),O(t,u).subscribe(function(e){c(e.src),u.onDebug(e)})});return function(){return a.then(function(e){return e.unsubscribe(),u.resetOnCancel&&c(u.src),u.onDetach(),i.then(function(e){return e()})})}},M=function e(t,n){e.cancel(t);var r=l,o=t,u=function(n,t,r){var o=function(e){return e?t():r()};if(MutationObserver){var u=document.body&&document.body.contains(n);u&&o(!0);var e=new MutationObserver(function(e){var t=document.body&&document.body.contains(n);!t&&u?(o(!1),u=!1):t&&!u&&(o(!0),u=!0)});return e.observe(document,{childList:!0,subtree:!0}),function(){return e.disconnect()}}return document.body&&document.body.contains(n)&&o(!0),n.addEventListener("DOMNodeInserted",function(){return o(!0)},!1),n.addEventListener("DOMNodeRemoved",function(){return o(!1)},!1),l}(t,function(){r=w(o,n)},function(){return e.cancel(t)});return o.creepyfaceCancel=function(){u(),r(),delete o.creepyfaceCancel}};return M.cancel=function(e){var t=e;t.creepyfaceCancel&&t.creepyfaceCancel()},document.addEventListener("DOMContentLoaded",function(){for(var e=document.querySelectorAll("img[data-creepy]"),t=0;t<e.length;t++){var n=e[t];n instanceof HTMLImageElement&&M(n)}}),M});

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

import Observable from './util/observable';
import { Observable } from './util/observable';
declare const _default: (observables: Observable<number[]>[]) => Observable<number[]>;
export default _default;

@@ -1,6 +0,5 @@

import Observable from './util/observable';
export default (observables) => new Observable(observer => {
const next = observer.next.bind(observer);
const subscriptions = observables.map(o => o.subscribe(next));
import observable from './util/observable';
export default (observables) => observable(observer => {
const subscriptions = observables.map(o => o.subscribe(observer.next));
return () => subscriptions.forEach(s => s.unsubscribe());
});

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

import Observable from './util/observable';
import { Observable } from './util/observable';
import { Options, CreepyData } from '../util/options';

@@ -3,0 +3,0 @@ import { CreepyImage } from '../util/types';

import getAngle from './util/get-angle';
import getSrc from './util/get-src';
import debounce from 'debounce';
import Observable from './util/observable';
import throttle from 'lodash.throttle';
export default (img, options) => new Observable(observer => {
import debounce from './util/debounce';
import observable from './util/observable';
import throttle from './util/throttle';
export default (img, options) => observable(observer => {
const backToDefault = debounce(() => observer.next({ src: options.src, options }), options.timeToDefault);

@@ -8,0 +8,0 @@ const subscription = options.points.subscribe(throttle(point => {

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

import Observable from './util/observable';
declare const _default: Observable<number[]>;
declare const _default: import("./util/observable").Observable<number[]>;
export default _default;

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

import Observable from './util/observable';
import observable from './util/observable';
import { add } from '../util/algebra';

@@ -6,3 +6,4 @@ const observers = [];

let point = [0, 0];
for (const touch of event.touches) {
for (let i = 0; i < event.touches.length; i++) {
const touch = event.touches[i];
point = add(point, [touch.clientX, touch.clientY]);

@@ -12,3 +13,3 @@ }

}), true);
export default new Observable(observer => {
export default observable(observer => {
observers.push(observer);

@@ -15,0 +16,0 @@ return () => {

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

import Observable from './util/observable';
declare const _default: Observable<number[]>;
declare const _default: import("./util/observable").Observable<number[]>;
export default _default;

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

import Observable from './util/observable';
import observable from './util/observable';
const observers = [];
document.addEventListener('mousemove', (event) => observers.forEach(observer => observer.next([event.clientX, event.clientY])), true);
export default new Observable(observer => {
export default observable(observer => {
observers.push(observer);

@@ -6,0 +6,0 @@ return () => {

@@ -6,9 +6,9 @@ import { sign } from '../../util/algebra';

const within = (n, a, b) => n >= a && n <= b;
const rectContains = ({ left, top, right, bottom }, [x, y]) => within(x, left, right) && within(y, top, bottom);
const elementContains = (img, [x, y]) => {
const rectContains = ({ left, top, right, bottom }, point) => within(point[0], left, right) && within(point[1], top, bottom);
const elementContains = (img, point) => {
if (document.elementFromPoint) {
return document.elementFromPoint(x, y) === img;
return document.elementFromPoint(point[0], point[1]) === img;
}
else {
return rectContains(img.getBoundingClientRect(), [x, y]);
return rectContains(img.getBoundingClientRect(), [point[0], point[1]]);
}

@@ -15,0 +15,0 @@ };

@@ -10,7 +10,6 @@ declare type Consumer<T> = (value: T) => void;

declare type Subscriber<T> = (observer: Observer<T>) => Cancel;
export default class Observable<T> {
subscriber: Subscriber<T>;
constructor(subscriber: Subscriber<T>);
export interface Observable<T> {
subscribe(consumer: Consumer<T>): Subscription;
}
export {};
declare const _default: <T>(subscriber: Subscriber<T>) => Observable<T>;
export default _default;

@@ -1,8 +0,5 @@

export default class Observable {
constructor(subscriber) {
this.subscriber = subscriber;
}
export default (subscriber) => ({
subscribe(consumer) {
return { unsubscribe: this.subscriber({ next: consumer }) };
return { unsubscribe: subscriber({ next: consumer }) };
}
}
});

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

import Observable from '../observables/util/observable';
import { Observable } from '../observables/util/observable';
import { Angle, Vector } from './algebra';

@@ -3,0 +3,0 @@ import { CreepyImage } from './types';

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

import parseDataAttributes from 'data-attrs-to-js';
import mousePoints from '../observables/mouse';

@@ -6,33 +5,29 @@ import fingerPoints from '../observables/finger';

import noop from './noop';
const getLooks = (look) => {
const getLooks = (img) => {
const regex = /data-src-look-(\d+)/i;
const looks = [];
for (const key of Object.keys(look)) {
const src = look[key];
if (src) {
looks.push({ angle: parseFloat(key), src });
for (let i = 0; i < img.attributes.length; i++) {
const attr = img.attributes[i];
const match = regex.exec(attr.name);
if (match) {
looks.push({ angle: parseFloat(match[1]), src: attr.value });
}
}
return looks;
return looks.length ? looks : undefined;
};
function fromImage(element) {
const { src = {}, fieldofvision, timetodefault, resetoncancel, throttle } = parseDataAttributes(element);
const options = {
src: element.getAttribute('src') || undefined
};
if (timetodefault)
options.timeToDefault = parseFloat(timetodefault);
if (throttle)
options.throttle = parseFloat(throttle);
if (fieldofvision)
options.fieldOfVision = parseFloat(fieldofvision);
if (resetoncancel)
options.resetOnCancel = resetoncancel === 'true';
if (src.hover)
options.hover = src.hover;
if (src.look)
options.looks = getLooks(src.look);
return options;
}
const getFloat = (s) => {
const float = s ? parseFloat(s) : NaN;
return isNaN(float) ? undefined : float;
};
const fromImage = (img) => ({
src: img.getAttribute('src') || undefined,
hover: img.getAttribute('data-src-hover') || undefined,
looks: getLooks(img),
timeToDefault: getFloat(img.getAttribute('data-timetodefault')),
throttle: getFloat(img.getAttribute('data-throttle')),
fieldOfVision: getFloat(img.getAttribute('data-fieldofvision')),
resetOnCancel: img.getAttribute('data-resetoncancel') === 'true'
});
export default function getOptions(img, options = {}) {
const userOptions = Object.assign({}, fromImage(img), options);
const userOptions = { ...fromImage(img), ...options };
if (!userOptions.src)

@@ -39,0 +34,0 @@ throw new Error('A default URL must be specified');

{
"name": "creepyface",
"version": "4.1.4",
"version": "4.1.5",
"keywords": [

@@ -26,7 +26,4 @@ "face",

"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@types/debounce": "^1.2.0",
"@types/jest": "^23.3.11",
"@types/lodash.throttle": "^4.1.4",
"babel-core": "7.0.0-bridge.0",

@@ -61,7 +58,4 @@ "babel-jest": "^23.6.0",

"dependencies": {
"data-attrs-to-js": "^1.1.1",
"debounce": "^1.0.2",
"get-element-center": "^1.1.0",
"image-promise": "^5.0.1",
"lodash.throttle": "^4.1.1"
"image-promise": "^5.0.1"
},

@@ -68,0 +62,0 @@ "lint-staged": {

# [Creepyface](https://creepyface.io) &middot; [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/4lejandrito/creepyface/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/creepyface.svg?style=flat)](https://www.npmjs.com/package/creepyface) [![Build Status](https://api.travis-ci.org/4lejandrito/creepyface.svg?branch=master)](https://travis-ci.org/4lejandrito/creepyface) [![Coverage Status](https://coveralls.io/repos/github/4lejandrito/creepyface/badge.svg?branch=master)](https://coveralls.io/github/4lejandrito/creepyface?branch=master)
Creepyface is a little JavaScript tool (<4K minified & gzipped) that makes your face look at the mouse (or fingers). It is ideal for resumes, team presentation sites, etc...
Creepyface is a little JavaScript tool that makes your face look at the mouse (or fingers). It is ideal for resumes, team presentation sites, etc...

@@ -5,0 +5,0 @@ [Demo](https://creepyface.io)

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