Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hscmap/inertial-mouse

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hscmap/inertial-mouse - npm Package Compare versions

Comparing version 0.0.0 to 1.0.0

16

lib/index.d.ts

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

export declare class V2 {
export declare class Coord {
x: number;

@@ -37,15 +37,15 @@ y: number;

export declare class DownEvent {
readonly r: V2;
constructor(r: V2, originalEvent: MouseEvent);
readonly r: Coord;
constructor(r: Coord, originalEvent: MouseEvent);
}
export declare class UpEvent {
readonly r: V2;
constructor(r: V2, originalEvent: MouseEvent);
readonly r: Coord;
constructor(r: Coord, originalEvent: MouseEvent);
}
export declare class MoveEvent {
readonly r: V2;
readonly d: V2;
constructor(r: V2, d: V2);
readonly r: Coord;
readonly d: Coord;
constructor(r: Coord, d: Coord);
}
export declare class StopEvent {
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var V2 = (function () {
function V2(x, y) {
var Coord = (function () {
function Coord(x, y) {
this.x = x;
this.y = y;
}
return V2;
return Coord;
}());
exports.V2 = V2;
exports.Coord = Coord;
var InertialMouse = (function () {

@@ -53,3 +53,3 @@ function InertialMouse(target, cb) {

this.lastT = performance.now();
this.v = new V2(0, 0);
this.v = new Coord(0, 0);
};

@@ -69,5 +69,5 @@ InertialMouse.prototype.tick = function () {

var dt = Math.max(t, 0);
var delta = new V2(this.anchor.x - this.r.x, this.anchor.y - this.r.y);
var a = this.hold || !this.slick ? new V2(// acceleration of critical damping
delta.x - 2 * this.v.x, delta.y - 2 * this.v.y) : new V2(// friction
var delta = new Coord(this.anchor.x - this.r.x, this.anchor.y - this.r.y);
var a = this.hold || !this.slick ? new Coord(// acceleration of critical damping
delta.x - 2 * this.v.x, delta.y - 2 * this.v.y) : new Coord(// friction
-this.friction * this.v.x, -this.friction * this.v.y);

@@ -82,3 +82,3 @@ this.v.x += dt * a.x;

}
this.cb.move && this.cb.move(new MoveEvent(this.r, new V2(this.r.x - this.lastR.x, this.r.y - this.lastR.y)));
this.cb.move && this.cb.move(new MoveEvent(this.r, new Coord(this.r.x - this.lastR.x, this.r.y - this.lastR.y)));
this.lastT = now;

@@ -89,3 +89,3 @@ this.lastR = this.r;

var rect = this.target.getBoundingClientRect();
return new V2(e.clientX - rect.left, e.clientY - rect.top);
return new Coord(e.clientX - rect.left, e.clientY - rect.top);
};

@@ -92,0 +92,0 @@ InertialMouse.prototype.moving = function () {

{
"name": "@hscmap/inertial-mouse",
"version": "0.0.0",
"version": "1.0.0",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts",

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

export class V2 {
export class Coord {
constructor(public x: number, public y: number) { }

@@ -19,6 +19,6 @@ }

private anchor: V2
private r: V2
private v: V2
private lastR: V2
private anchor: Coord
private r: Coord
private v: Coord
private lastR: Coord
private hold = false

@@ -62,7 +62,7 @@ private lastT = 0

private initPhysics(r: V2) {
private initPhysics(r: Coord) {
this.hold = true
this.anchor = this.r = this.lastR = r
this.lastT = performance.now()
this.v = new V2(0, 0)
this.v = new Coord(0, 0)
}

@@ -84,7 +84,7 @@

const dt = Math.max(t, 0)
const delta = new V2(this.anchor.x - this.r.x, this.anchor.y - this.r.y)
const a = this.hold || !this.slick ? new V2( // acceleration of critical damping
const delta = new Coord(this.anchor.x - this.r.x, this.anchor.y - this.r.y)
const a = this.hold || !this.slick ? new Coord( // acceleration of critical damping
delta.x - 2 * this.v.x,
delta.y - 2 * this.v.y,
) : new V2( // friction
) : new Coord( // friction
- this.friction * this.v.x,

@@ -102,3 +102,3 @@ - this.friction * this.v.y,

this.cb.move && this.cb.move(new MoveEvent(this.r, new V2(this.r.x - this.lastR.x, this.r.y - this.lastR.y)))
this.cb.move && this.cb.move(new MoveEvent(this.r, new Coord(this.r.x - this.lastR.x, this.r.y - this.lastR.y)))
this.lastT = now

@@ -110,3 +110,3 @@ this.lastR = this.r

const rect = this.target.getBoundingClientRect()
return new V2(e.clientX - rect.left, e.clientY - rect.top)
return new Coord(e.clientX - rect.left, e.clientY - rect.top)
}

@@ -122,11 +122,11 @@

export class DownEvent {
constructor(readonly r: V2, originalEvent: MouseEvent) { }
constructor(readonly r: Coord, originalEvent: MouseEvent) { }
}
export class UpEvent {
constructor(readonly r: V2, originalEvent: MouseEvent) { }
constructor(readonly r: Coord, originalEvent: MouseEvent) { }
}
export class MoveEvent {
constructor(readonly r: V2, readonly d: V2) { }
constructor(readonly r: Coord, readonly d: Coord) { }
}

@@ -133,0 +133,0 @@

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