shake-detector
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,2 +0,2 @@ | ||
'use strict';function isAcceleration(a){if(null===a)return!0;let {x:b,y:d,z:c}=a;return isNumber(b)&&isNumber(d)&&isNumber(c)}function isNumber(a){return"number"===typeof a}function getDelta(a,b){return Math.abs(a-b)}function isFunc(a){return"function"===typeof a}function isDeviceMotionSupported(){return"DeviceMotionEvent"in window}function isPermissionRequired(){return isFunc(DeviceMotionEvent.requestPermission)} | ||
'use strict';function isAcceleration(a){if(null===a)return!1;let {x:b,y:d,z:c}=a;return isNumber(b)&&isNumber(d)&&isNumber(c)}function isNumber(a){return"number"===typeof a}function getDelta(a,b){return Math.abs(a-b)}function isFunc(a){return"function"===typeof a}function isDeviceMotionSupported(){return"DeviceMotionEvent"in window}function isPermissionRequired(){return isFunc(DeviceMotionEvent.requestPermission)} | ||
class MotionMonitor{constructor(){this.listeners=[];this.onMotion=a=>{this.listeners.forEach(b=>b(a))};this.isSupported=isDeviceMotionSupported();this.isPermissionGranted=!isPermissionRequired()}subscribe(a){isFunc(a)&&this.listeners.push(a);return this}unsubscribe(a){isFunc(a)&&(this.listeners=this.listeners.filter(b=>b!==a));return this}confirmPermissionGranted(){this.isPermissionGranted=!0;return this}requestPermission(a=document.documentElement){return this.isSupported?this.isPermissionGranted? | ||
@@ -3,0 +3,0 @@ Promise.resolve(!0):new Promise(b=>{let d=()=>{DeviceMotionEvent.requestPermission().then(c=>{(this.isPermissionGranted="granted"===c)||console.warn("The permission to listen to DeviceMotionEvent was not granted");a.removeEventListener("click",d);b(this.isPermissionGranted)})};a.addEventListener("click",d)}):Promise.resolve(!1)}start(){this.isSupported&&this.isPermissionGranted&&window.removeEventListener("devicemotion",this.onMotion,!1);return this}stop(){this.isSupported&&this.isPermissionGranted&& |
@@ -1,2 +0,2 @@ | ||
function f(a){if(null===a)return!0;let {x:b,y:c,z:d}=a;return"number"===typeof b&&"number"===typeof c&&"number"===typeof d}function g(a){return"function"===typeof a} | ||
function f(a){if(null===a)return!1;let {x:b,y:c,z:d}=a;return"number"===typeof b&&"number"===typeof c&&"number"===typeof d}function g(a){return"function"===typeof a} | ||
class l{constructor(){this.listeners=[];this.onMotion=a=>{this.listeners.forEach(b=>b(a))};this.isSupported="DeviceMotionEvent"in window;this.isPermissionGranted=!g(DeviceMotionEvent.requestPermission)}subscribe(a){g(a)&&this.listeners.push(a);return this}unsubscribe(a){g(a)&&(this.listeners=this.listeners.filter(b=>b!==a));return this}confirmPermissionGranted(){this.isPermissionGranted=!0;return this}requestPermission(a=document.documentElement){return this.isSupported?this.isPermissionGranted?Promise.resolve(!0): | ||
@@ -3,0 +3,0 @@ new Promise(b=>{let c=()=>{DeviceMotionEvent.requestPermission().then(d=>{(this.isPermissionGranted="granted"===d)||console.warn("The permission to listen to DeviceMotionEvent was not granted");a.removeEventListener("click",c);b(this.isPermissionGranted)})};a.addEventListener("click",c)}):Promise.resolve(!1)}start(){this.isSupported&&this.isPermissionGranted&&window.removeEventListener("devicemotion",this.onMotion,!1);return this}stop(){this.isSupported&&this.isPermissionGranted&&window.removeEventListener("devicemotion", |
@@ -1,2 +0,2 @@ | ||
'use strict';(function(c,b){"object"===typeof exports&&"undefined"!==typeof module?module.exports=b():"function"===typeof define&&define.amd?define(b):(c="undefined"!==typeof globalThis?globalThis:c||self,c.ShakeMonitor=b())})(this,function(){function c(a){if(null===a)return!0;let {x:d,y:b,z:c}=a;return"number"===typeof d&&"number"===typeof b&&"number"===typeof c}function b(a){return"function"===typeof a}class l{constructor(){this.listeners=[];this.onMotion=a=>{this.listeners.forEach(d=>d(a))};this.isSupported= | ||
'use strict';(function(c,b){"object"===typeof exports&&"undefined"!==typeof module?module.exports=b():"function"===typeof define&&define.amd?define(b):(c="undefined"!==typeof globalThis?globalThis:c||self,c.ShakeMonitor=b())})(this,function(){function c(a){if(null===a)return!1;let {x:d,y:b,z:c}=a;return"number"===typeof d&&"number"===typeof b&&"number"===typeof c}function b(a){return"function"===typeof a}class l{constructor(){this.listeners=[];this.onMotion=a=>{this.listeners.forEach(d=>d(a))};this.isSupported= | ||
"DeviceMotionEvent"in window;this.isPermissionGranted=!b(DeviceMotionEvent.requestPermission)}subscribe(a){b(a)&&this.listeners.push(a);return this}unsubscribe(a){b(a)&&(this.listeners=this.listeners.filter(d=>d!==a));return this}confirmPermissionGranted(){this.isPermissionGranted=!0;return this}requestPermission(a=document.documentElement){return this.isSupported?this.isPermissionGranted?Promise.resolve(!0):new Promise(d=>{let b=()=>{DeviceMotionEvent.requestPermission().then(c=>{(this.isPermissionGranted= | ||
@@ -3,0 +3,0 @@ "granted"===c)||console.warn("The permission to listen to DeviceMotionEvent was not granted");a.removeEventListener("click",b);d(this.isPermissionGranted)})};a.addEventListener("click",b)}):Promise.resolve(!1)}start(){this.isSupported&&this.isPermissionGranted&&window.removeEventListener("devicemotion",this.onMotion,!1);return this}stop(){this.isSupported&&this.isPermissionGranted&&window.removeEventListener("devicemotion",this.onMotion,!1);return this}}let m={threshold:15,frequency:1E3};class n{constructor(a){this.listeners= |
{ | ||
"name": "shake-detector", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Mobile device shakes detection", | ||
@@ -34,3 +34,6 @@ "keywords": [ | ||
"build": "rollup -c rollup/prod.config.js", | ||
"dev": "rollup -c rollup/dev.config.js -w" | ||
"dev-build": "rollup -c rollup/dev.config.js -w", | ||
"dev": "rollup -c rollup/dev.config.js", | ||
"declarations": "tsc --emitDeclarationOnly", | ||
"postversion": "npm run build && npm publish && git push && git push --tags" | ||
}, | ||
@@ -37,0 +40,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49098