Socket
Socket
Sign inDemoInstall

@visx/event

Package Overview
Dependencies
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visx/event - npm Package Compare versions

Comparing version 1.0.0 to 1.3.0-alpha.0

17

esm/getXAndYFromEvent.js
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import { isTouchEvent } from './typeGuards';
import { isMouseEvent, isTouchEvent } from './typeGuards';
var DEFAULT_POINT = {

@@ -18,6 +18,17 @@ x: 0,

if (isMouseEvent(event)) {
return {
x: event.clientX,
y: event.clientY
};
} // for focus events try to extract the center position of the target element
var target = event == null ? void 0 : event.target;
var boundingClientRect = target && 'getBoundingClientRect' in target ? target.getBoundingClientRect() : null;
if (!boundingClientRect) return _extends({}, DEFAULT_POINT);
return {
x: event.clientX,
y: event.clientY
x: boundingClientRect.x + boundingClientRect.width / 2,
y: boundingClientRect.y + boundingClientRect.height / 2
};
}

@@ -18,2 +18,6 @@ export function isElement(elem) {

return !!event && 'changedTouches' in event;
} // functional definition of MouseEvent
export function isMouseEvent(event) {
return !!event && 'clientX' in event;
} // functional definition of event

@@ -20,0 +24,0 @@

@@ -25,6 +25,17 @@ "use strict";

if ((0, _typeGuards.isMouseEvent)(event)) {
return {
x: event.clientX,
y: event.clientY
};
} // for focus events try to extract the center position of the target element
var target = event == null ? void 0 : event.target;
var boundingClientRect = target && 'getBoundingClientRect' in target ? target.getBoundingClientRect() : null;
if (!boundingClientRect) return _extends({}, DEFAULT_POINT);
return {
x: event.clientX,
y: event.clientY
x: boundingClientRect.x + boundingClientRect.width / 2,
y: boundingClientRect.y + boundingClientRect.height / 2
};
}

@@ -8,3 +8,4 @@ /// <reference types="react" />

export declare function isTouchEvent(event?: EventType): event is TouchEvent | React.TouchEvent;
export declare function isMouseEvent(event?: EventType): event is MouseEvent | React.MouseEvent;
export declare function isEvent(event?: EventType | Element): event is EventType;
//# sourceMappingURL=typeGuards.d.ts.map

@@ -9,2 +9,3 @@ "use strict";

exports.isTouchEvent = isTouchEvent;
exports.isMouseEvent = isMouseEvent;
exports.isEvent = isEvent;

@@ -33,2 +34,7 @@

return !!event && 'changedTouches' in event;
} // functional definition of MouseEvent
function isMouseEvent(event) {
return !!event && 'clientX' in event;
} // functional definition of event

@@ -35,0 +41,0 @@

2

lib/types.d.ts
/// <reference types="react" />
export declare type EventType = MouseEvent | TouchEvent | React.MouseEvent | React.TouchEvent;
export declare type EventType = MouseEvent | TouchEvent | FocusEvent | React.MouseEvent | React.TouchEvent | React.FocusEvent;
//# sourceMappingURL=types.d.ts.map
{
"name": "@visx/event",
"version": "1.0.0",
"version": "1.3.0-alpha.0",
"description": "visx event",

@@ -37,3 +37,3 @@ "sideEffects": false,

},
"gitHead": "598445514c93f22b1b7c399efa894b0778fd6ca6"
"gitHead": "d11b08238456bf5031df5da238d2bafa0d062316"
}

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