@hscmap/inertial-mouse
Advanced tools
Comparing version 3.2.1 to 3.3.0
import { V2 } from "./v2"; | ||
import { Physics } from "./physics"; | ||
export interface Callbacks { | ||
down?(e: DownEvent): void; | ||
move?(e: MoveEvent): void; | ||
up?(e: UpEvent): void; | ||
movestart?(e: MoveStartEvent): void; | ||
moveend?(e: MoveEndEvent): void; | ||
setNextTick?(tick: () => void): void; | ||
down(e: DownEvent): void; | ||
move(e: MoveEvent): void; | ||
up(e: UpEvent): void; | ||
movestart(e: MoveStartEvent): void; | ||
moveend(e: MoveEndEvent): void; | ||
setNextTick(tick: () => void): void; | ||
} | ||
export declare type EventFitler = (e: MouseEvent) => boolean; | ||
export declare class InertialMouse { | ||
readonly target: HTMLElement; | ||
readonly cb: Callbacks; | ||
readonly cb: Partial<Callbacks>; | ||
readonly eventFilter: EventFitler | undefined; | ||
readonly physics: Physics; | ||
constructor(target: HTMLElement, cb?: Callbacks); | ||
constructor(target: HTMLElement, cb: Partial<Callbacks>, eventFilter?: EventFitler | undefined); | ||
teardown(): void; | ||
@@ -17,0 +19,0 @@ stop(): void; |
@@ -6,14 +6,16 @@ "use strict"; | ||
var InertialMouse = /** @class */ (function () { | ||
function InertialMouse(target, cb) { | ||
if (cb === void 0) { cb = {}; } | ||
function InertialMouse(target, cb, eventFilter) { | ||
var _this = this; | ||
this.target = target; | ||
this.cb = cb; | ||
this.eventFilter = eventFilter; | ||
this.physics = new physics_1.Physics(); | ||
this.mousedown = function (e) { | ||
var r = _this.coord(e); | ||
_this.physics.put(r); | ||
document.addEventListener('mousemove', _this.mousemove); | ||
document.addEventListener('mouseup', _this.mouseup); | ||
_this.cb.down && _this.cb.down(new DownEvent(r, e)); | ||
if (_this.eventFilter && _this.eventFilter(e) || _this.eventFilter == undefined) { | ||
var r = _this.coord(e); | ||
_this.physics.put(r); | ||
document.addEventListener('mousemove', _this.mousemove); | ||
document.addEventListener('mouseup', _this.mouseup); | ||
_this.cb.down && _this.cb.down(new DownEvent(r, e)); | ||
} | ||
}; | ||
@@ -20,0 +22,0 @@ this.mousemove = function (e) { |
{ | ||
"name": "@hscmap/inertial-mouse", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
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
15088
368