Socket
Socket
Sign inDemoInstall

@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 3.2.1 to 3.3.0

18

lib/inertial_mouse.d.ts
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",

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