-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathevents.js
47 lines (42 loc) · 1.08 KB
/
events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const getEvent = (evType) => `
const node = arguments[0]
const mouseoverEv = document.createEvent("MouseEvents")
mouseoverEv.initMouseEvent(
"${evType}", true,
false, window,
1, // detail : Event's mouse click count
50, // screenX
50, // screenY
50, // clientX
50, // clientY
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
0, // button : 0 = click, 1 = middle button, 2 = right button
null // relatedTarget : Only used with some event types (e.g. mouseover and mouseout). In other cases, pass null.
)
node.dispatchEvent(mouseoverEv)
`
const mouseOver = getEvent('mouseover')
const mouseLeave = getEvent('mouseleave')
const mouseEnter = getEvent('mouseenter')
const mouseOut = getEvent('mouseout')
const doubleClick = getEvent('dblclick')
const eventsScripts = {
mouseEnter,
mouseLeave,
mouseOver,
mouseOut,
doubleClick
}
const eventsList = {
mouseEnter: 'mouseEnter',
mouseOver: 'mouseOver',
mouseLeave: 'mouseLeave',
mouseOut: 'mouseOut'
}
module.exports = {
eventsList,
eventsScripts
}