Socket
Socket
Sign inDemoInstall

@visx/event

Package Overview
Dependencies
2
Maintainers
4
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visx/event


Version published
Weekly downloads
412K
increased by7.75%
Maintainers
4
Created
Weekly downloads
 

Changelog

Source

v1.0.0

:house: Internal

  • project renamed from vx => visx, migrated from hshoff/vx => airbnb/visx #802, #803

:memo: Documentation

  • Demo site migrated from https://vx-demo.now.sh/ => https://airbnb.io/visx #804
  • Demo site re-brand

:boom: Breaking Changes

  • [all packages] vx-... classNames are renamed to visx-... #803
  • [demo] existing codesandbox links which reference vx-demo directory structure will break #803
  • [tooltip] className="vx-tooltip-portal" => visx-tooltip (so as not to be confused with the new TooltipInPortal) #803
:bug: Bug Fix
  • [demo] fix /axis codesandbox dependency #799
:trophy: Contributors
@vx/*@0.0.199 => @visx/*@1.0.0

Readme

Source

@visx/event

Installation

npm install --save @visx/event

Usage

@visx/event exports a utility localPoint that takes an SVG MouseEvent or TouchEvent as input and returns a { x: number; y: number; } point coordinate (or null in the case the event has no ownerSVGElement) within the coordinate system of the SVG. This makes placement of tooltips, finding nearby datum, etc. easier.

Example:

import { localPoint } from '@visx/event';

<svg>
  <SomeElement
    {...}
    onMouseMove={(event: MouseEvent) => {
      const point = localPoint(event) || { x: 0, y: 0 };
      // use coordinates ...
    }}
  />
  {...}
</svg>

You may optionally pass a reference to the SVG node

import { useRef } from 'react';
import { localPoint } from '@visx/event';

const svgRef = useRef<SVGSVGElement>(null);

<svg ref={svgRef}>
  <SomeElement
    {...}
    onMouseMove={(event: MouseEvent) => {
      const point = localPoint(svgRef.current, event) || { x: 0, y: 0 };
      // use coordinates ...
    }}
  />
  {...}
</svg>

Keywords

FAQs

Last updated on 22 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc