Socket
Socket
Sign inDemoInstall

mouse-event-offset

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mouse-event-offset

get relative position from an event


Version published
Weekly downloads
207K
increased by2.14%
Maintainers
1
Install size
4.60 kB
Created
Weekly downloads
 

Readme

Source

mouse-event-offset

experimental

Gets the offsetX/offsetY from a mouse event, relative to the top left of the target (i.e. clicked) element.

var offset = require('mouse-event-offset')
var events = require('dom-events')

events.on(element, 'click', function(e) {
	var pos = offset(e)
	console.log(pos.x, pos.y)
})

Usage

NPM

offset(event[, options])

Pass an event object to the function, and a position with { x, y } is returned. The options:

  • clientRect is a pre-computed bounding client rect (e.g. to avoid reflows), defaults to use the target's getBoundingClientRect()
  • clientX is the client x position, defaults to event.clientX
  • clientY is the client y position, defaults to event.clientY

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Last updated on 22 Sep 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc