Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/relative-mouse
Get mouse position relative to a DOM element.
https://github.com/stagas/relative-mouse
dom element mouse relative
Last synced: 14 days ago
JSON representation
Get mouse position relative to a DOM element.
- Host: GitHub
- URL: https://github.com/stagas/relative-mouse
- Owner: stagas
- License: mit
- Created: 2022-03-17T03:26:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-16T16:20:05.000Z (over 2 years ago)
- Last Synced: 2024-10-08T12:12:30.176Z (about 1 month ago)
- Topics: dom, element, mouse, relative
- Language: TypeScript
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
relative-mouseGet mouse position relative to a DOM element.
npm i relative-mouse
pnpm add relative-mouse
yarn add relative-mouse
## API
#
getRelativeMouse
(el, { x, y }) src/index.ts#L6
# el
HTMLElement
pos
{
number
y
src/index.ts#L6 number
getRelativeMouse(el, { x, y }) =>
#getRelativeMouseFromEvent
(el, event) src/index.ts#L3
## Credits
- [get-element-offset](https://npmjs.org/package/get-element-offset) by [stagas](https://github.com/stagas) – Get accurate DOM element offset.
## Contributing
[Fork](https://github.com/stagas/relative-mouse/fork) or [edit](https://github.dev/stagas/relative-mouse) and submit a PR.
All contributions are welcome!
## License
MIT © 2022 [stagas](https://github.com/stagas)