creepyface
Advanced tools
Comparing version 7.1.1 to 7.1.2
@@ -1,9 +0,55 @@ | ||
import { UserOptions } from './util/options'; | ||
import { Cancel } from './types'; | ||
declare const creepyface: { | ||
(img: HTMLImageElement, userOptions?: UserOptions | undefined): Cancel; | ||
cancel(img: HTMLImageElement): void; | ||
registerPointProvider: (name: string, provider: import("./types").PointProvider) => void; | ||
}; | ||
export default creepyface; | ||
export { PointProvider, Consumer, Point } from './types'; | ||
export type Point = [number, number] | ||
export type Cancel = () => void | ||
export type Consumer<T> = (t: T) => void | ||
export type PointProvider = ( | ||
consumer: Consumer<Point | null>, | ||
img: HTMLImageElement | ||
) => Cancel | ||
export type Millis = number | ||
export type ImageURL = string | ||
export type Look = { | ||
src: ImageURL | ||
angle: number | ||
} | ||
export type CreepyData = { | ||
point?: Point | ||
angle?: number | ||
src: string | ||
options: Options | ||
} | ||
export type Options = { | ||
src: ImageURL | ||
hover?: ImageURL | ||
looks: Array<Look> | ||
pointProvider: PointProvider | ||
timeToDefault: Millis | ||
throttle: Millis | ||
onDebug: Consumer<CreepyData> | ||
onAttach: Consumer<void> | ||
onDetach: Consumer<void> | ||
} | ||
export type UserOptions = { | ||
hover?: ImageURL | ||
looks?: Array<Look> | ||
points?: PointProvider | string | ||
timeToDefault?: Millis | ||
throttle?: Millis | ||
onDebug?: Consumer<CreepyData> | ||
onAttach?: Consumer<void> | ||
onDetach?: Consumer<void> | ||
} | ||
export type Creepyface = { | ||
(img: HTMLImageElement, userOptions?: UserOptions | undefined): Cancel | ||
cancel(img: HTMLImageElement): void | ||
registerPointProvider: (name: string, provider: PointProvider) => void | ||
} | ||
declare const creepyface: Creepyface | ||
export default creepyface |
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).creepyface=e()}(this,function(){"use strict";var i=function(o){return 1===o.length?o[0]:function(e,n){var t=o.map(function(t){return t(e,n)});return function(){return t.forEach(function(t){return t()})}}},t=function(n){var o,r=[];return function(t,e){return r.push(t),1===r.length&&(o=n(function(e){return r.forEach(function(t){return t(e)})},e)),function(){r.splice(r.indexOf(t),1),0===r.length&&o&&o()}}},e=t(function(e){var t=function(t){return e([t.clientX,t.clientY])};return window.addEventListener("mousemove",t,!0),function(){return window.removeEventListener("mousemove",t,!0)}}),s=function(t,e){return[t[0]+e[0],t[1]+e[1]]},d=function(t){return t*Math.PI/180},h=function(t){return e=Math.atan2(t[1],t[0]),n=2*Math.PI,180*((n+e%n)%n)/Math.PI;var e,n},n=t(function(r){var t=function(t){for(var e=[0,0],n=0;n<t.touches.length;n++){var o=t.touches[n];e=s(e,[o.clientX,o.clientY])}r(e)};return window.addEventListener("touchmove",t,!0),function(){return window.removeEventListener("touchmove",t,!0)}}),o={mouse:e,finger:n,pointer:i([e,n])},c=function(t){return o[t]?o[t]:(console.error("No point provider registered as '".concat(t,"', defaulting to pointer.")),o.pointer)},r=function(t){var e=t?parseFloat(t):NaN;return isNaN(e)?void 0:e},u=function(t){return{hover:t.getAttribute("data-src-hover")||void 0,looks:function(t){for(var e=/data-src-look-(\d+)/i,n=[],o=0;o<t.attributes.length;o++){var r=t.attributes[o],i=e.exec(r.name);i&&n.push({angle:parseFloat(i[1]),src:r.value})}return n.length?n:void 0}(t),points:t.getAttribute("data-points")||void 0,timeToDefault:r(t.getAttribute("data-timetodefault")),throttle:r(t.getAttribute("data-throttle"))}},a=function(){};function f(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=function(r){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{},e=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(i).filter(function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable}))),e.forEach(function(t){var e,n,o;e=r,o=i[n=t],n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o})}return r}({},u(t),n),r=t.getAttribute("src");if(!r)throw new Error("A default URL must be specified");return{src:r,hover:o.hover||"",pointProvider:(e=o,"function"==typeof e.points?e.points:i((e.points||"pointer").split(",").map(c))),looks:o.looks||[],timeToDefault:o.timeToDefault||1e3,throttle:o.throttle||100,onDebug:o.onDebug||a,onAttach:o.onAttach||a,onDetach:o.onDetach||a}}var l=function(r,i){var c=[];r.forEach(function(t){var e,n,o;e=t,n=function(t){c.push(t),c.length===r.length&&i(c)},(o=new Image).src=e,o.onload=o.onerror=function(){o.naturalWidth||console.error("Creepyface was unable to load ".concat(e)),delete o.onload,delete o.onerror,n(o)}})};function v(r,i,c,u){var a,f=!1,l=0;function s(){a&&clearTimeout(a)}function t(){var t=this,e=Date.now()-l,n=arguments;function o(){l=Date.now(),c.apply(t,n)}f||(u&&!a&&o(),s(),void 0===u&&r<e?o():!0!==i&&(a=setTimeout(u?function(){a=void 0}:o,void 0===u?r-e:r)))}return"boolean"!=typeof i&&(u=c,c=i,i=void 0),t.cancel=function(){s(),f=!0},t}var p=function(t,e){return h((r=s([window.scrollX,window.scrollY],e),c=t.getBoundingClientRect(),u=c.left,a=c.top,f=c.width,l=c.height,i=[u+window.pageXOffset+f/2,a+window.pageYOffset+l/2],n=[r[0]-i[0],r[1]-i[1]],o=90,[n[0]*Math.cos(d(o))-n[1]*Math.sin(d(o)),n[0]*Math.sin(d(o))+n[1]*Math.cos(d(o))]));var n,o,r,i,c,u,a,f,l},g=function(t){return 180<Math.abs(t)?t-360*(t<0?-1:1):t},m=function(t,e){return e.slice(0).sort((n=t,function(t,e){return Math.abs(g(t.angle-n))-Math.abs(g(e.angle-n))}))[0];var n},b=function(t,e,n){return e<=t&&t<=n},w=function(t,e){return document.elementFromPoint?document.elementFromPoint(e[0],e[1])===t:(n=t.getBoundingClientRect(),o=[e[0],e[1]],r=n.left,i=n.top,c=n.right,u=n.bottom,b(o[0],r,c)&&b(o[1],i,u));var n,o,r,i,c,u},y=function(s,t){var n,o,e,r,i,c,d=f(s,t);return s.__creepyfaceCancel=(n=s,i=!(o=function(){var t,e,n,f=function(t,e,n){s.src=t,d.onDebug({src:t,point:e,angle:n,options:d})},l=(t=d.timeToDefault,e=function(){return f(d.src)},void 0===n?v(t,e,!1):v(t,n,!1!==e)),o=v(d.throttle,function(t){if(!t)return f(d.src);var e,n,o,r,i,c,u=p(s,t),a=(e=s,n=t,o=u,i=(r=d).looks,(c=r.hover)&&w(e,n)?c:0===i.length?r.src:m(o,i).src);f(a,t,u),l()}),r=d.pointProvider(o,s);return d.onAttach(),function(){l.cancel(),o.cancel(),r(),s.src=d.src,delete s.__creepyfaceCancel,d.onDetach()}}),c=function(){i=!0},l(((r=(e=d).looks.map(function(t){return t.src})).push(e.src),e.hover&&r.push(e.hover),r),function(t){n.__creepyfaceReachableImages=t;var e=o();c=function(){e(),delete n.__creepyfaceReachableImages},(i||t.some(function(t){return!t.naturalWidth}))&&c()}),function(){return c()})};return y.cancel=function(t){var e=t.__creepyfaceCancel;e&&e()},y.registerPointProvider=function(t,e){o[t]=e},document.addEventListener("DOMContentLoaded",function(){for(var t=document.querySelectorAll("img[data-creepy],img[data-creepyface]"),e=0;e<t.length;e++)y(t[e])}),y}); | ||
//# sourceMappingURL=creepyface.umd.js.map |
{ | ||
"name": "creepyface", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"keywords": [ | ||
@@ -31,3 +31,3 @@ "face", | ||
"babel-jest": "^24.9.0", | ||
"coveralls": "^3.0.2", | ||
"chromedriver": "^79.0.0", | ||
"eslint": "^5.11.1", | ||
@@ -46,4 +46,5 @@ "geckodriver": "^1.19.1", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"selenium-webdriver": "^4.0.0-alpha.1", | ||
"selenium-webdriver": "^4.0.0-alpha.5", | ||
"simulate-event": "^1.4.0", | ||
@@ -66,12 +67,9 @@ "standard": "^12.0.1", | ||
"all": "run-s clean lint build test", | ||
"travis": "run-s clean lint build test:coverage", | ||
"prepublishOnly": "npm run all", | ||
"start": "npm run build:ts && run-p \"build:* -- -w\"", | ||
"start": "rollup -c -w", | ||
"lint": "tslint --project tsconfig.json", | ||
"build:ts": "tsc", | ||
"build:umd": "rollup -c", | ||
"build": "NODE_ENV=production run-s build:*", | ||
"build": "NODE_ENV=production rollup -c && cp src/types.d.ts dist/creepyface.d.ts", | ||
"clean": "rimraf dist", | ||
"test": "jest", | ||
"test:coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls" | ||
"test:coverage": "jest --coverage" | ||
}, | ||
@@ -78,0 +76,0 @@ "prettier": { |
@@ -1,2 +0,2 @@ | ||
# [Creepyface](https://creepyface.io) · [![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](https://creepyface.io) · [![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](https://github.com/4lejandrito/creepyface/workflows/Build/badge.svg)](https://github.com/4lejandrito/creepyface/actions?query=workflow%3ABuild+branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/4lejandrito/creepyface/badge.svg?branch=master)](https://coveralls.io/github/4lejandrito/creepyface?branch=master) | ||
@@ -3,0 +3,0 @@ Creepyface is a little JavaScript tool that makes your face look at the pointer (or a [firefly](https://github.com/4lejandrito/creepyface-firefly)). It is ideal for resumes, team presentation sites, etc... |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
41343
31
6
68
1