mouse-event

WebJar for mouse-event

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

mouse-event
Последняя версия

Последняя версия

1.0.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

mouse-event
WebJar for mouse-event
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/mikolalysenko/mouse-event

Скачать mouse-event

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/mouse-event/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>mouse-event</artifactId>
    <version>1.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/mouse-event/
implementation 'org.webjars.npm:mouse-event:1.0.5'
// https://jarcasting.com/artifacts/org.webjars.npm/mouse-event/
implementation ("org.webjars.npm:mouse-event:1.0.5")
'org.webjars.npm:mouse-event:jar:1.0.5'
<dependency org="org.webjars.npm" name="mouse-event" rev="1.0.5">
  <artifact name="mouse-event" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='mouse-event', version='1.0.5')
)
libraryDependencies += "org.webjars.npm" % "mouse-event" % "1.0.5"
[org.webjars.npm/mouse-event "1.0.5"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

mouse-event

Provides a normalized, cross-browser, garbage-collection-free API for reading out the state of a mouse event.

Why is this needed?

Because it is 2015 and somehow every major browser still disagrees on even the most basic details of MouseEvents. Seriously guys.

Example

var mouse = require('mouse-event')

window.addEventListener('mousemove', function(ev) {
  document.body.innerHTML =
    '<p>Buttons: ' + mouse.buttons(ev) + 
    ' x:' + mouse.x(ev) + 
    ' y:' + mouse.y(ev) + '</p>'
})

Try this in your browser

Install

npm i mouse-event

API

var mouse = require('mouse-event')

mouse.buttons(event)

Returns a bit vector, similar to event.which in WebKit encoding the state of the mouse buttons.

  • event is a mouse event

Returns A bit vector with the following interpretation for the flags:

  • 1 - left mouse
  • 2 - right mouse
  • 4 - middle mouse
  • 8 - button 4
  • 16 - button 5
  • ...
  • 1<<k - button k+1

mouse.x(event)

Returns the relative x-coordinate of the mouse event

  • event is a mouse event

Returns The relative x-coordinate of event, similar to event.x in WebKit

mouse.y(event)

Returns the relative y-coordinate of the mouse event

  • event is a mouse event

Returns The relative y-coordinate of event, similar to event.y in WebKit

mouse.element(event)

Get the element which triggered the event.

  • event is a mouse event

Returns The target or srcElement or whatever it was that triggered the event

License

(c) 2015 Mikola Lysenko. MIT License

Версии библиотеки

Версия
1.0.5