pick-dom-element
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

pick-dom-element

npm version

A JavaScript library (written in TypeScript) for interactively picking DOM elements.

Usage

Create an instance of the ElementPicker class, and call its start() method to start picking. Provide an onHover or onClick callback to get the picked element(s). Call stop() to stop picking and remove the overlay from the DOM.

import { ElementPicker } from "pick-dom-element";

const style = { borderColor: "#0000ff" };
const picker = new ElementPicker({ style });
picker.start({
  onHover: (el) => console.log(`Hover: ${el}`),
  onClick: (el) => {
    picker.stop();
    console.log(`Picked: ${el}`);
  },
});

See the example directory for a more complete example of how to use the library.

Readme

Keywords

none

Package Sidebar

Install

npm i pick-dom-element

Weekly Downloads

1,611

Version

0.2.3

License

MIT

Unpacked Size

10.9 kB

Total Files

11

Last publish

Collaborators

  • hmarr