@hscmap/magic-trackpad-detector
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -5,5 +5,5 @@ "use strict"; | ||
function MagicTrackpadDetector() { | ||
this.tolerance = 7; // ms | ||
this.tolerance = 5; // ms | ||
this.interval = 1000 / 60; // events per second | ||
this.minN1 = 7; | ||
this.minN1 = 5; | ||
this.minN2 = 15; | ||
@@ -24,3 +24,3 @@ this.history = new RingBuffer(Math.max(this.minN1, this.minN2)); | ||
var dt = n[0] - o[0]; | ||
if (dt < this.interval - this.tolerance || this.interval + this.tolerance < dt) | ||
if (dt < this.interval - this.tolerance) | ||
return false; | ||
@@ -42,4 +42,3 @@ if (n[1] * o[1] < 0 || n[1] / o[1] > 1) | ||
var dt = n[0] - o[0]; | ||
if (!(this.interval - this.tolerance <= dt && dt <= this.interval + this.tolerance || | ||
2 * this.interval - this.tolerance <= dt && dt <= 2 * this.interval + this.tolerance)) | ||
if (dt < this.interval - this.tolerance) | ||
return false; | ||
@@ -46,0 +45,0 @@ if (n[1] * o[1] < 0 || n[1] / o[1] > 1) |
{ | ||
"name": "@hscmap/magic-trackpad-detector", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
export class MagicTrackpadDetector { | ||
tolerance = 7 // ms | ||
tolerance = 5 // ms | ||
interval = 1000 / 60 // events per second | ||
minN1 = 7 | ||
minN1 = 5 | ||
minN2 = 15 | ||
@@ -22,3 +22,3 @@ private history = new RingBuffer<[number, number]>(Math.max(this.minN1, this.minN2)) | ||
const dt = n[0] - o[0] | ||
if (dt < this.interval - this.tolerance || this.interval + this.tolerance < dt) | ||
if (dt < this.interval - this.tolerance) | ||
return false | ||
@@ -29,3 +29,3 @@ if (n[1] * o[1] < 0 || n[1] / o[1] > 1) | ||
} | ||
else { | ||
else { // |deltaY| == 1 | ||
if (h.length < this.minN2) | ||
@@ -41,8 +41,3 @@ return false | ||
const dt = n[0] - o[0] | ||
if ( | ||
!( | ||
this.interval - this.tolerance <= dt && dt <= this.interval + this.tolerance || | ||
2 * this.interval - this.tolerance <= dt && dt <= 2 * this.interval + this.tolerance | ||
) | ||
) | ||
if (dt < this.interval - this.tolerance) | ||
return false | ||
@@ -49,0 +44,0 @@ if (n[1] * o[1] < 0 || n[1] / o[1] > 1) |
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
146705
266