creepyface
Advanced tools
Comparing version 7.4.5 to 7.4.6
@@ -1,2 +0,2 @@ | ||
!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";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(o){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?e(Object(i),!0).forEach(function(t){var e,n,r;e=o,r=i[n=t],n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(i,t))})}return o}function u(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 t(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()}}}function s(t,e){return[t[0]+e[0],t[1]+e[1]]}function d(t){return t*Math.PI/180}function h(t){return e=Math.atan2(t[1],t[0]),180*(((n=2*Math.PI)+e%n)%n)/Math.PI;var e,n}function a(t){return i[t]?i[t]:(console.error("No point provider registered as '".concat(t,"', defaulting to pointer.")),i.pointer)}function n(t){var e=t?parseFloat(t):NaN;return isNaN(e)?void 0:e}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:n(t.getAttribute("data-timetodefault")),throttle:n(t.getAttribute("data-throttle")),fieldOfVision:n(t.getAttribute("data-fieldofvision"))}}function l(){}var r=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)}}),o=t(function(o){function t(t){for(var e=[0,0],n=0;n<t.touches.length;n++){var r=t.touches[n];e=s(e,[r.clientX,r.clientY])}o(e)}return window.addEventListener("touchmove",t,!0),function(){return window.removeEventListener("touchmove",t,!0)}}),i={mouse:r,finger:o,pointer:u([r,o])};function p(t,e){var n,r=1<arguments.length&&void 0!==e?e:{},o=c(c({},f(t)),r),i=t.getAttribute("src");if(!i)throw new Error("A default URL must be specified");return{src:i,hover:o.hover||"",pointProvider:"function"==typeof(n=o).points?n.points:u((n.points||"pointer").split(",").map(a)),looks:o.looks||[],timeToDefault:void 0!==o.timeToDefault?o.timeToDefault:1e3,throttle:o.throttle||100,fieldOfVision:o.fieldOfVision||150,onDebug:o.onDebug||l,onAttach:o.onAttach||l,onDetach:o.onDetach||l}}function v(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)),delete r.onload,delete r.onerror,n(r)}})}function g(o,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 r(){l=Date.now(),c.apply(t,n)}f||(u&&!a&&r(),s(),void 0===u&&o<e?r():!0!==i&&(a=setTimeout(u?function(){a=void 0}:r,void 0===u?o-e:o)))}return"boolean"!=typeof i&&(u=c,c=i,i=void 0),t.cancel=function(){s(),f=!0},t}function m(t,e){return h((o=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=[o[0]-i[0],o[1]-i[1]],r=90,[n[0]*Math.cos(d(r))-n[1]*Math.sin(d(r)),n[0]*Math.sin(d(r))+n[1]*Math.cos(d(r))]));var n,r,o,i,c,u,a,f,l}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){return document.elementFromPoint?document.elementFromPoint(e[0],e[1])===t:(n=t.getBoundingClientRect(),r=[e[0],e[1]],o=n.left,i=n.top,c=n.right,u=n.bottom,y(r[0],o,c)&&y(r[1],i,u));var n,r,o,i,c,u}function D(u,t){var n,r,e,o,i,c,a=p(u,t);return u.__creepyfaceCancel=(n=u,i=!(r=function(){function r(t,e,n){u.src=t,a.onDebug({src:t,point:e,angle:n,options:a})}var t,e,n,o=(t=a.timeToDefault,e=function(){return r(a.src)},void 0===n?g(t,e,!1):g(t,n,!1!==e)),i=g(a.throttle,function(t){if(!t)return r(a.src);var e=m(u,t),n=function(t,e,n,r){var o=r.looks,i=r.hover,c=r.fieldOfVision;if(i&&O(t,e))return i;if(0<o.length){var u=w(n,o);if(Math.abs(b(u.angle-n))<=c/2)return u.src}return r.src}(u,t,e,a);r(n,t,e),0<a.timeToDefault&&o()}),c=a.pointProvider(i,u);return a.onAttach(),function(){o.cancel(),i.cancel(),c(),u.src=a.src,delete u.__creepyfaceCancel,a.onDetach()}}),c=function(){i=!0},v(((o=(e=a).looks.map(function(t){return t.src})).push(e.src),e.hover&&o.push(e.hover),o),function(t){n.__creepyfaceReachableImages=t;var e=r();c=function(){e(),delete n.__creepyfaceReachableImages},(i||t.some(function(t){return!t.naturalWidth}))&&c()}),function(){return c()})}return D.cancel=function(t){var e=t.__creepyfaceCancel;e&&e()},D.registerPointProvider=function(t,e){i[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++)D(t[e])}),D}); | ||
!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,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function n(o){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?e(Object(r),!0).forEach(function(t){var e,n;e=o,t=r[n=t],n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function o(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()})}}}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 r(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=[],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:a(t.getAttribute("data-timetodefault")),throttle:a(t.getAttribute("data-throttle")),fieldOfVision:a(t.getAttribute("data-fieldofvision"))}}function l(){}var 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()}}},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(r){function t(t){for(var e=[0,0],n=0;n<t.touches.length;n++)var o=t.touches[n],e=i(e,[o.clientX,o.clientY]);r(e)}return window.addEventListener("touchmove",t,!0),function(){return window.removeEventListener("touchmove",t,!0)}}),d={mouse:s,finger:t,pointer:o([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:o((t.points||"pointer").split(",").map(r)),looks:e.looks||[],timeToDefault:void 0!==e.timeToDefault?e.timeToDefault:1e3,throttle:e.throttle||100,fieldOfVision:e.fieldOfVision||150,onDebug:e.onDebug||l,onAttach:e.onAttach||l,onDetach:e.onDetach||l}}function p(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)),o.onload=null,o.onerror=null,n(o)}})}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 o=this,r=Date.now()-d;function i(){d=Date.now(),a.apply(o,e)}s||(f&&!l&&i(),h(),void 0===f&&c<r?i():!0!==u&&(l=setTimeout(f?function(){l=void 0}:i,void 0===f?c-r:c)))}return"boolean"!=typeof u&&(f=a,a=u,u=void 0),t.cancel=function(){h(),s=!0},t}function g(t,e){return u((n=i([window.scrollX,window.scrollY],e),r=(o=t).getBoundingClientRect(),e=r.left,t=r.top,o=r.width,r=r.height,r=[e+window.pageXOffset+o/2,t+window.pageYOffset+r/2],n=[n[0]-r[0],n[1]-r[1]],r=90,[n[0]*Math.cos(c(r))-n[1]*Math.sin(c(r)),n[0]*Math.sin(c(r))+n[1]*Math.cos(c(r))]));var n,o,r}function m(t){return 180<Math.abs(t)?t-360*(t<0?-1:1):t}function b(t,e){return e.slice(0).sort((n=t,function(t,e){return Math.abs(m(t.angle-n))-Math.abs(m(e.angle-n))}))[0];var n}function w(t,e,n){return e<=t&&t<=n}function y(t,e){return document.elementFromPoint?document.elementFromPoint(e[0],e[1])===t:(n=t.getBoundingClientRect(),o=[e[0],e[1]],r=n.left,t=n.top,e=n.right,n=n.bottom,w(o[0],r,e)&&w(o[1],t,n));var n,o,r}function O(u,t){var n,e,o,r,i,a=h(u,t);return u.__creepyfaceCancel=(n=u,r=!(o=function(){function o(t,e,n){u.src=t,a.onDebug({src:t,point:e,angle:n,options:a})}var t,e,n,r=(t=a.timeToDefault,e=function(){return o(a.src)},void 0===n?v(t,e,!1):v(t,n,!1!==e)),i=v(a.throttle,function(t){if(!t)return o(a.src);var e=g(u,t),n=function(t,e,n,o){var r=o.looks,i=o.hover,c=o.fieldOfVision;if(i&&y(t,e))return i;if(0<r.length){r=b(n,r);if(Math.abs(m(r.angle-n))<=c/2)return r.src}return o.src}(u,t,e,a);o(n,t,e),0<a.timeToDefault&&r()}),c=a.pointProvider(i,u);return a.onAttach(),function(){r.cancel(),i.cancel(),c(),u.src=a.src,delete u.__creepyfaceCancel,a.onDetach()}}),i=function(){r=!0},p(((e=(t=e=a).looks.map(function(t){return t.src})).push(t.src),t.hover&&e.push(t.hover),e),function(t){n.__creepyfaceReachableImages=t;var e=o();i=function(){e(),delete n.__creepyfaceReachableImages},(r||t.some(function(t){return!t.naturalWidth}))&&i()}),function(){return i()})}return O.cancel=function(t){t=t.__creepyfaceCancel;t&&t()},O.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++)O(t[e])}),O}); | ||
//# sourceMappingURL=creepyface.umd.js.map |
{ | ||
"name": "creepyface", | ||
"version": "7.4.5", | ||
"version": "7.4.6", | ||
"main": "dist/creepyface.umd.js", | ||
@@ -24,35 +24,35 @@ "types": "dist/creepyface.d.ts", | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/preset-env": "^7.9.6", | ||
"@types/jest": "^23.3.11", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@types/jest": "^26.0.20", | ||
"@types/throttle-debounce": "^2.1.0", | ||
"babel-core": "7.0.0-bridge.0", | ||
"babel-jest": "^24.9.0", | ||
"chromedriver": "^81.0.0", | ||
"eslint": "^5.11.1", | ||
"geckodriver": "^1.19.1", | ||
"jest": "^24.9.0", | ||
"babel-jest": "^26.6.3", | ||
"chromedriver": "^88.0.0", | ||
"eslint": "^7.19.0", | ||
"geckodriver": "^1.22.1", | ||
"jest": "^26.6.3", | ||
"npm-run-all": "^4.1.5", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.0.0", | ||
"rollup-plugin-babel": "^4.2.0", | ||
"rollup-plugin-browsersync": "^1.1.0", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"rollup-plugin-typescript2": "^0.25.3", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.38.2", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-browsersync": "^1.3.1", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"rollup-plugin-uglify": "^6.0.0", | ||
"selenium-webdriver": "^4.0.0-alpha.5", | ||
"selenium-webdriver": "^4.0.0-alpha.8", | ||
"simulate-event": "^1.4.0", | ||
"standard": "^12.0.1", | ||
"throttle-debounce": "^2.1.0", | ||
"ts-jest": "^24.2.0", | ||
"tslint": "^5.12.0", | ||
"standard": "^16.0.3", | ||
"throttle-debounce": "^3.0.1", | ||
"ts-jest": "^26.5.0", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.17.0", | ||
"tslint-config-standard": "^8.0.1", | ||
"typescript": "^3.7.3" | ||
"tslint-config-standard": "^9.0.0", | ||
"typescript": "^4.1.3" | ||
}, | ||
"scripts": { | ||
"all": "run-s clean lint build", | ||
"all": "run-s clean lint build test", | ||
"prepublishOnly": "yarn all", | ||
"start": "rollup -c -w", | ||
"dev": "rollup -c -w", | ||
"lint": "tslint --project tsconfig.json", | ||
@@ -63,3 +63,4 @@ "build": "NODE_ENV=production rollup -c && cp src/types.d.ts dist/creepyface.d.ts", | ||
"test:coverage": "jest --coverage" | ||
} | ||
}, | ||
"gitHead": "84b06a1152c3373eaa34eef256ab28262b9db41b" | ||
} |
@@ -33,3 +33,3 @@ # [Creepyface](https://creepyface.io) · [![npm version](https://img.shields.io/npm/v/creepyface.svg?style=flat)](https://www.npmjs.com/package/creepyface) | ||
- `yarn start` will spin up a test page. | ||
- `yarn dev` will spin up a test page. | ||
- `yarn build` will generate the production scripts under the `dist` folder. |
Sorry, the diff of this file is not supported yet
35520
6