New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pointerify

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pointerify - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/Events/handlers/handleClick.d.ts

5

config/webpack.config.ts

@@ -1,3 +0,4 @@

import * as path from 'path';
import * as webpack from 'webpack';
// tslint:disable:no-var-requires
const path = require('path');
const webpack = require('webpack');

@@ -4,0 +5,0 @@ module.exports = {

3

dist/Events/EventBinding.d.ts
import IEventBinding from './Interfaces/IEventBinding';
import IEventHandler from './Interfaces/IEventHandler';
declare class EventBinding implements IEventBinding {

@@ -7,3 +6,3 @@ type: string;

debounce: number;
handler: IEventHandler;
handler: EventListener;
passive: boolean;

@@ -10,0 +9,0 @@ constructor(eventBindingRaw: IEventBinding | string);

@@ -6,2 +6,3 @@ import Pointerify from '../Pointerify/Pointerify';

private bindings;
private handlers;
constructor(pointerify: Pointerify);

@@ -11,11 +12,4 @@ readonly root: HTMLElement;

unbindEvents(): void;
protected handleClick(e: MouseEvent): void;
protected handleMousedown(e: MouseEvent): void;
protected handleMousemove(e: MouseEvent): void;
protected handleMouseup(e: MouseEvent): void;
protected handleTouchstart(e: TouchEvent): void;
protected handleTouchmove(e: TouchEvent): void;
protected handleTouchend(e: TouchEvent): void;
protected handleResize(): void;
private bindEvent(eventBindingRaw);
}
export default EventManager;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Pointer_1 = require("../Pointer/Pointer");
var EventType_1 = require("../Shared/Constants/EventType");
var PointerType_1 = require("../Shared/Constants/PointerType");
var closestParent_1 = require("../Shared/Util/closestParent");
var bindEvent_1 = require("./bindEvent");
var debounce_1 = require("../Shared/Util/debounce");
var pascalCase_1 = require("../Shared/Util/pascalCase");
var EventBinding_1 = require("./EventBinding");
var handlers = require("./handlers/");
var EventManager = /** @class */ (function () {

@@ -12,2 +11,3 @@ function EventManager(pointerify) {

this.bindings = [];
this.handlers = handlers;
this.pointerify = pointerify;

@@ -23,3 +23,3 @@ }

EventManager.prototype.bindEvents = function (events) {
this.bindings = events.map(bindEvent_1.default.bind(null, this, this.root));
this.bindings = events.map(this.bindEvent.bind(this));
};

@@ -29,98 +29,19 @@ EventManager.prototype.unbindEvents = function () {

};
EventManager.prototype.handleClick = function (e) {
if (this.pointerify.isClicking)
return;
e.preventDefault();
e.stopPropagation();
};
EventManager.prototype.handleMousedown = function (e) {
var target = e.target;
var handleSelector = this.pointerify.config.selectors.handle;
var didCancel = false;
if (e.button !== 0)
return;
if (this.pointerify.mouse) {
this.pointerify.cancelPointer(this.pointerify.mouse);
didCancel = true;
EventManager.prototype.bindEvent = function (eventBindingRaw) {
var eventBinding = new EventBinding_1.default(eventBindingRaw);
if (!eventBinding.target)
eventBinding.target = this.root;
var handlerName = "handle" + pascalCase_1.default(eventBinding.type);
var handler = this.handlers[handlerName];
if (typeof handler !== 'function') {
throw new TypeError("[Pointerify] No \"" + handlerName + "\" handler method found for event type \"" + eventBinding.type + "\"");
}
if (handleSelector && !closestParent_1.default(target, handleSelector, true))
return;
this.pointerify.setRootGeometry();
this.pointerify.mouse = this.pointerify.createPointer(e, PointerType_1.default.MOUSE, didCancel);
e.preventDefault();
var boundHandler = handler.bind(null, this.pointerify);
eventBinding.handler = (eventBinding.debounce <= 0) ?
boundHandler : debounce_1.default(boundHandler, eventBinding.debounce, true);
eventBinding.target.addEventListener(eventBinding.type, eventBinding.handler, {
passive: eventBinding.passive
});
return eventBinding;
};
EventManager.prototype.handleMousemove = function (e) {
var mouse = this.pointerify.mouse;
if (e.target !== window && mouse && !mouse.isStopping) {
this.pointerify.movePointer(mouse, e, e);
}
else if (e.target === window && !mouse) {
this.pointerify.emitStatic(e, EventType_1.default.POINTER_INSPECT);
}
};
EventManager.prototype.handleMouseup = function (e) {
if (!this.pointerify.mouse)
return;
this.pointerify.releasePointer(this.pointerify.mouse, e);
e.preventDefault();
};
EventManager.prototype.handleTouchstart = function (e) {
var target = e.target;
var handleSelector = this.pointerify.config.selectors.handle;
var touchIds = null;
for (var i = 0, touch = void 0; (touch = e.changedTouches[i]); i++) {
var newId = touch.identifier;
var didCancel = false;
for (var activeId in this.pointerify.touches) {
// If any active touches in this instance are stopping (i.e.
// already released but moving via inertia), cancel them.
var activePointer = null;
if ((activePointer = this.pointerify.touches[activeId]).isStopping) {
this.pointerify.cancelPointer(activePointer);
didCancel = true;
}
}
if (handleSelector && !closestParent_1.default(target, handleSelector, true))
break;
this.pointerify.setRootGeometry();
if (this.pointerify.totalTouches < 2 && !this.pointerify.touches[newId]) {
this.pointerify.touches[newId] = this.pointerify.createPointer(touch, PointerType_1.default.TOUCH, didCancel);
}
}
if (!this.pointerify.config.behavior.pinch)
return;
touchIds = Object.keys(this.pointerify.touches);
if (touchIds.length > 1 && !this.pointerify.virtual) {
// Multiple touches exist, create a "virtual" pointer at the
// midpoint
e.preventDefault();
this.pointerify.virtual = this.pointerify.createVirtualPointer(this.pointerify.touches[touchIds[0]], this.pointerify.touches[touchIds[1]]);
}
};
EventManager.prototype.handleTouchmove = function (e) {
if (this.pointerify.totalTouches < 1)
return;
for (var i = 0, touch = void 0; (touch = e.changedTouches[i]); i++) {
var id = touch.identifier;
var pointer = null;
if (!((pointer = this.pointerify.touches[id]) instanceof Pointer_1.default) || pointer.isStopping)
break;
this.pointerify.movePointer(pointer, touch, e);
}
};
EventManager.prototype.handleTouchend = function (e) {
if (this.pointerify.totalTouches < 1)
return;
for (var i = 0, touch = void 0; (touch = e.changedTouches[i]); i++) {
var id = touch.identifier;
var pointer = null;
if (!((pointer = this.pointerify.touches[id]) instanceof Pointer_1.default))
break;
this.pointerify.releasePointer(pointer, touch);
e.preventDefault();
}
};
EventManager.prototype.handleResize = function () {
this.pointerify.setRootGeometry();
};
return EventManager;

@@ -127,0 +48,0 @@ }());

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

import IEventHandler from './IEventHandler';
interface IEventBinding {

@@ -6,5 +5,5 @@ type: string;

debounce?: number;
handler?: IEventHandler;
handler?: EventListener;
passive?: boolean;
}
export default IEventBinding;

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

declare type IEventHandler = (e: Event) => void;
import Pointerify from '../../Pointerify/Pointerify';
declare type IEventHandler = (pointerify: Pointerify, e: Event) => void;
export default IEventHandler;

@@ -5,3 +5,5 @@ import pointerifyFactory from './Pointerify/pointerifyFactory';

import EventType from './Shared/Constants/EventType';
import PointerifyDynamicEvent from './Shared/Events/PointerifyDynamicEvent';
import PointerifyStaticEvent from './Shared/Events/PointerifyStaticEvent';
declare const create: typeof pointerifyFactory;
export { Axis, create, Direction, EventType, pointerifyFactory as default };
export { Axis, create, Direction, EventType, PointerifyDynamicEvent, PointerifyStaticEvent, pointerifyFactory as default };

@@ -11,4 +11,8 @@ "use strict";

exports.EventType = EventType_1.default;
var PointerifyDynamicEvent_1 = require("./Shared/Events/PointerifyDynamicEvent");
exports.PointerifyDynamicEvent = PointerifyDynamicEvent_1.default;
var PointerifyStaticEvent_1 = require("./Shared/Events/PointerifyStaticEvent");
exports.PointerifyStaticEvent = PointerifyStaticEvent_1.default;
var create = pointerifyFactory_1.default;
exports.create = create;
//# sourceMappingURL=index.js.map
{
"name": "pointerify",
"version": "1.0.0",
"version": "1.0.1",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

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

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