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 7.5.0 to 8.0.0-alpha.0

27

dist/creepyface.d.ts

@@ -6,6 +6,7 @@ export type Degrees = number

export type PointProvider = (
consumer: Consumer<Point | null>,
export type PointProvider = (consumer: Consumer<Point | null>) => Cancel
export type PointMapper = (
point: Point | null,
img: HTMLImageElement
) => Cancel
) => Point | null

@@ -27,2 +28,6 @@ export type Millis = number

export type AttachData = {
setPointProvider: (points: string | undefined) => void
}
export type Options = {

@@ -32,9 +37,8 @@ src: ImageURL

looks: Array<Look>
pointProvider: PointProvider
points?: string
timeToDefault: Millis
throttle: Millis | 'raf'
fieldOfVision: Degrees
optimizePerformance?: boolean
onDebug: Consumer<CreepyData>
onAttach: Consumer<void>
onAttach: Consumer<AttachData>
onDetach: Consumer<void>

@@ -46,9 +50,8 @@ }

looks?: Array<Look>
points?: PointProvider | string
points?: string
timeToDefault?: Millis
throttle?: Millis | 'raf'
fieldOfVision?: Degrees
optimizePerformance?: boolean
onDebug?: Consumer<CreepyData>
onAttach?: Consumer<void>
onAttach?: Consumer<AttachData>
onDetach?: Consumer<void>

@@ -60,3 +63,7 @@ }

cancel(img: HTMLImageElement): void
registerPointProvider: (name: string, provider: PointProvider) => void
registerPointProvider: (
name: string,
provider: PointProvider,
mapper?: PointMapper
) => void
}

@@ -63,0 +70,0 @@

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).creepyface=e()}(this,function(){"use strict";function e(e,t){var n,r=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)),r}function n(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?e(Object(o),!0).forEach(function(t){var e,n;e=r,t=o[n=t],n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(o,t))})}return r}function r(r){return 1===r.length?r[0]:function(e,n){var t=r.map(function(t){return t(e,n)});return function(){return t.forEach(function(t){return t()})}}}function i(t,e){return[t[0]+e[0],t[1]+e[1]]}function c(t){return t*Math.PI/180}function u(t){return e=Math.atan2(t[1],t[0]),180*(((t=2*Math.PI)+e%t)%t)/Math.PI;var e}function o(t){return d[t]||(console.error("No point provider registered as '".concat(t,"', defaulting to pointer.")),d.pointer)}function a(t){return t=t?parseFloat(t):NaN,isNaN(t)?void 0:t}function f(t){return{hover:t.getAttribute("data-src-hover")||void 0,looks:function(t){for(var e=/data-src-look-(\d+)/i,n=[],r=0;r<t.attributes.length;r++){var o=t.attributes[r],i=e.exec(o.name);i&&n.push({angle:parseFloat(i[1]),src:o.value})}return n.length?n:void 0}(t),points:t.getAttribute("data-points")||void 0,timeToDefault:a(t.getAttribute("data-timetodefault")),throttle:"raf"===(e=t.getAttribute("data-throttle"))?"raf":a(e),fieldOfVision:a(t.getAttribute("data-fieldofvision"))};var e}function l(){}var t=function(n){var r,o=[];return function(t,e){return o.push(t),1===o.length&&(r=n(function(e){return o.forEach(function(t){return t(e)})},e)),function(){o.splice(o.indexOf(t),1),0===o.length&&r&&r()}}},s=t(function(e){function t(t){return e([t.clientX,t.clientY])}return window.addEventListener("mousemove",t,!0),function(){return window.removeEventListener("mousemove",t,!0)}}),t=t(function(o){function t(t){for(var e=[0,0],n=0;n<t.touches.length;n++)var r=t.touches[n],e=i(e,[r.clientX,r.clientY]);o(e)}return window.addEventListener("touchmove",t,!0),function(){return window.removeEventListener("touchmove",t,!0)}}),d={mouse:s,finger:t,pointer:r([s,t])};function h(t,e){e=1<arguments.length&&void 0!==e?e:{},e=n(n({},f(t)),e),t=t.getAttribute("src");if(!t)throw new Error("A default URL must be specified");return{src:t,hover:e.hover||"",pointProvider:"function"==typeof(t=e).points?t.points:r((t.points||"pointer").split(",").map(o)),looks:e.looks||[],timeToDefault:void 0!==e.timeToDefault?e.timeToDefault:1e3,throttle:e.throttle||100,fieldOfVision:e.fieldOfVision||150,optimizePerformance:e.optimizePerformance,onDebug:e.onDebug||l,onAttach:e.onAttach||l,onDetach:e.onDetach||l}}function p(o,i){var c=[];o.forEach(function(t){var e,n,r;e=t,n=function(t){c.push(t),c.length===o.length&&i(c)},(r=new Image).src=e,r.onload=r.onerror=function(){r.naturalWidth||console.error("Creepyface was unable to load ".concat(e)),r.onload=null,r.onerror=null,n(r)}})}function v(c,u,a,f){var l,s=!1,d=0;function h(){l&&clearTimeout(l)}function t(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=this,o=Date.now()-d;function i(){d=Date.now(),a.apply(r,e)}s||(f&&!l&&i(),h(),void 0===f&&c<o?i():!0!==u&&(l=setTimeout(f?function(){l=void 0}:i,void 0===f?c-o:c)))}return"boolean"!=typeof u&&(f=a,a=u,u=void 0),t.cancel=function(){h(),s=!0},t}var m=function(o){function t(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];i=n,null===c&&(c=requestAnimationFrame((t=this,function(){c=null,o.apply(t,i)})))}var i,c=null;return t.cancel=function(){cancelAnimationFrame(c),c=null},t};function g(t,e){return u((n=i([window.scrollX,window.scrollY],e),o=(r=t).getBoundingClientRect(),e=o.left,t=o.top,r=o.width,o=o.height,o=[e+window.pageXOffset+r/2,t+window.pageYOffset+o/2],n=[n[0]-o[0],n[1]-o[1]],o=90,[n[0]*Math.cos(c(o))-n[1]*Math.sin(c(o)),n[0]*Math.sin(c(o))+n[1]*Math.cos(c(o))]));var n,r,o}function b(t){return 180<Math.abs(t)?t-360*(t<0?-1:1):t}function w(t,e){return e.slice(0).sort((n=t,function(t,e){return Math.abs(b(t.angle-n))-Math.abs(b(e.angle-n))}))[0];var n}function y(t,e,n){return e<=t&&t<=n}function O(t,e,n){return!n.optimizePerformance&&document.elementFromPoint?document.elementFromPoint(e[0],e[1])===t:(r=t.getBoundingClientRect(),o=[e[0],e[1]],n=r.left,t=r.top,e=r.right,r=r.bottom,y(o[0],n,e)&&y(o[1],t,r));var r,o}function P(u,t){function e(){return delete u.__creepyfaceCancel}var n,r,o,i,c,a,f=h(u,t),l=(n=u,i=e,c=!(o=function(){function r(t,e,n){u.src=t,f.onDebug({src:t,point:e,angle:n,options:f})}var t,e,n,o=(t=f.timeToDefault,n=function(){return r(f.src)},void 0===e?v(t,n,!1):v(t,e,!1!==n)),i=(e=f.throttle,n=function(t){if(!t)return r(f.src);var e=g(u,t),n=function(t,e,n,r){var o=r.looks,i=r.hover,c=r.fieldOfVision;if(i&&O(t,e,r))return i;if(0<o.length){o=w(n,o);if(Math.abs(b(o.angle-n))<=c/2)return o.src}return r.src}(u,t,e,f);r(n,t,e),0<f.timeToDefault&&o()},"raf"===e?m(n):v(e,n)),c=f.pointProvider(i,u);return f.onAttach(),function(){o.cancel(),i.cancel(),c(),u.src=f.src,f.onDetach()}}),a=function(){c=!0},p(((r=(t=r=f).looks.map(function(t){return t.src})).push(t.src),t.hover&&r.push(t.hover),r),function(t){if(!c){if(t.some(function(t){return!t.naturalWidth}))return i();n.__creepyfaceReachableImages=t;var e=o();a=function(){e(),delete n.__creepyfaceReachableImages}}}),function(){return a()});return u.__creepyfaceCancel=function(){l(),e()}}return P.cancel=function(t){t=t.__creepyfaceCancel;t&&t()},P.registerPointProvider=function(t,e){d[t]=e},"undefined"!=typeof window&&document.addEventListener("DOMContentLoaded",function(){for(var t=document.querySelectorAll("img[data-creepy],img[data-creepyface]"),e=0;e<t.length;e++)P(t[e])}),P});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).creepyface=n()}(this,function(){"use strict";function n(n,e){var t,r=Object.keys(n);return Object.getOwnPropertySymbols&&(t=Object.getOwnPropertySymbols(n),e&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})),r.push.apply(r,t)),r}function s(r){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?n(Object(o),!0).forEach(function(e){var n,t;n=r,e=o[t=e],t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))})}return r}function t(e){return e=e?parseFloat(e):NaN,isNaN(e)?void 0:e}function d(e){return{hover:e.getAttribute("data-src-hover")||void 0,looks:function(e){for(var n=/data-src-look-(\d+)/i,t=[],r=0;r<e.attributes.length;r++){var o=e.attributes[r],i=n.exec(o.name);i&&t.push({angle:parseFloat(i[1]),src:o.value})}return t.length?t:void 0}(e),points:e.getAttribute("data-points")||void 0,timeToDefault:t(e.getAttribute("data-timetodefault")),fieldOfVision:t(e.getAttribute("data-fieldofvision"))}}function p(){}function i(e,n){return[e[0]+n[0],e[1]+n[1]]}function c(e){return e*Math.PI/180}function u(e){return n=Math.atan2(e[1],e[0]),180*(((e=2*Math.PI)+n%e)%e)/Math.PI;var n}function v(c,u,a,f){var l,s=!1,d=0;function p(){l&&clearTimeout(l)}function e(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=this,o=Date.now()-d;function i(){d=Date.now(),a.apply(r,n)}s||(f&&!l&&i(),p(),void 0===f&&c<o?i():!0!==u&&(l=setTimeout(f?function(){l=void 0}:i,void 0===f?c-o:c)))}return"boolean"!=typeof u&&(f=a,a=u,u=void 0),e.cancel=function(){p(),s=!0},e}function r(e){return{provider:e,mapper:1<arguments.length&&void 0!==arguments[1]?arguments[1]:function(e){return e},registrations:[]}}function a(e){var n=o[e];return n||(console.error("No point provider registered as '".concat(e,"'.")),null)}var o={mouse:r(function(n){function e(e){return n([e.clientX,e.clientY])}return window.addEventListener("mousemove",e,!0),function(){return window.removeEventListener("mousemove",e,!0)}}),finger:r(function(o){function e(e){for(var n=[0,0],t=0;t<e.touches.length;t++)var r=e.touches[t],n=i(n,[r.clientX,r.clientY]);o(n)}return window.addEventListener("touchmove",e,!0),function(){return window.removeEventListener("touchmove",e,!0)}})},f=[o.mouse,o.finger],l=v(50,function(t,e){var n=e.registrations,r=e.mapper;return n.forEach(function(e){var n=e.consumer,e=e.img;return n(r(t,e))})});function h(o,i,e){var n=function(e){if(!e||"pointer"===e)return f;var n=[];return e.split(",").map(a).forEach(function(e){e&&n.push(e)}),0===n.length?f:n}(e).map(function(n){var t=n.registrations,e=n.provider,r={consumer:i,img:o};return t.push(r),1===t.length&&(n.cancel=e(function(e){return l(e,n)})),function(){var e;t.splice(t.indexOf(r),1),0===t.length&&(null!==(e=n.cancel)&&void 0!==e&&e.call(n),delete n.cancel)}});return function(){return n.forEach(function(e){return e()})}}function g(o,i){var c=[];o.forEach(function(e){var n,t,r;n=e,t=function(e){c.push(e),c.length===o.length&&i(c)},(r=new Image).src=n,r.onload=r.onerror=function(){r.naturalWidth||console.error("Creepyface was unable to load ".concat(n)),r.onload=null,r.onerror=null,t(r)}})}function m(e,n){return u((t=i([window.scrollX,window.scrollY],n),o=(r=e).getBoundingClientRect(),n=o.left,e=o.top,r=o.width,o=o.height,o=[n+window.pageXOffset+r/2,e+window.pageYOffset+o/2],t=[t[0]-o[0],t[1]-o[1]],o=90,[t[0]*Math.cos(c(o))-t[1]*Math.sin(c(o)),t[0]*Math.sin(c(o))+t[1]*Math.cos(c(o))]));var t,r,o}function b(e){return 180<Math.abs(e)?e-360*(e<0?-1:1):e}function w(e,n){return n.slice(0).sort((t=e,function(e,n){return Math.abs(b(e.angle-t))-Math.abs(b(n.angle-t))}))[0];var t}function y(e,n,t){return n<=e&&e<=t}function O(e,n,t){return!t.optimizePerformance&&document.elementFromPoint?document.elementFromPoint(n[0],n[1])===e:(r=e.getBoundingClientRect(),o=[n[0],n[1]],t=r.left,e=r.top,n=r.right,r=r.bottom,y(o[0],t,n)&&y(o[1],e,r));var r,o}function P(u,e){function n(){return delete u.__creepyfaceCancel}var t,r,o,i,c,a,f=function(e,n){if(n=1<arguments.length&&void 0!==n?n:{},n=s(s({},d(e)),n),!(e=e.getAttribute("src")))throw new Error("A default URL must be specified");return{src:e,hover:n.hover||"",points:n.points,looks:n.looks||[],timeToDefault:void 0!==n.timeToDefault?n.timeToDefault:1e3,fieldOfVision:n.fieldOfVision||150,optimizePerformance:n.optimizePerformance,onDebug:n.onDebug||p,onAttach:n.onAttach||p,onDetach:n.onDetach||p}}(u,e),l=(t=u,i=n,c=!(o=function(){function r(e,n,t){u.src=e,f.onDebug({src:e,point:n,angle:t,options:f})}function n(e){if(!e)return r(f.src);var n=m(u,e),t=function(e,n,t,r){var o=r.looks,i=r.hover,c=r.fieldOfVision;if(i&&O(e,n,r))return i;if(0<o.length){o=w(t,o);if(Math.abs(b(o.angle-t))<=c/2)return o.src}return r.src}(u,e,n,f);r(t,e,n),0<f.timeToDefault&&i()}var e,t,o,i=(e=f.timeToDefault,t=function(){return r(f.src)},void 0===o?v(e,t,!1):v(e,o,!1!==t)),c=h(u,n,f.points);return f.onAttach({setPointProvider:function(e){c(),c=h(u,n,e)}}),function(){i.cancel(),c(),u.src=f.src,f.onDetach()}}),a=function(){c=!0},g(((r=(e=r=f).looks.map(function(e){return e.src})).push(e.src),e.hover&&r.push(e.hover),r),function(e){if(!c){if(e.some(function(e){return!e.naturalWidth}))return i();t.__creepyfaceReachableImages=e;var n=o();a=function(){n(),delete t.__creepyfaceReachableImages}}}),function(){return a()});return u.__creepyfaceCancel=function(){l(),n()}}return P.cancel=function(e){e=e.__creepyfaceCancel;e&&e()},P.registerPointProvider=function(e,n,t){return o[e]=r(n,t)},"undefined"!=typeof window&&document.addEventListener("DOMContentLoaded",function(){for(var e=document.querySelectorAll("img[data-creepy],img[data-creepyface]"),n=0;n<e.length;n++)P(e[n])}),P});
//# sourceMappingURL=creepyface.umd.js.map
{
"name": "creepyface",
"version": "7.5.0",
"version": "8.0.0-alpha.0",
"main": "dist/creepyface.umd.js",

@@ -38,3 +38,2 @@ "types": "dist/creepyface.d.ts",

"npm-run-all": "^4.1.5",
"raf-throttle": "^2.0.5",
"rimraf": "^3.0.2",

@@ -41,0 +40,0 @@ "rollup": "^2.38.4",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc