-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathmouse.js
720 lines (582 loc) · 21.3 KB
/
mouse.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
const $ = require('jquery')
const _ = require('lodash')
const $dom = require('../dom')
const $elements = require('../dom/elements')
const $Keyboard = require('./keyboard')
const $selection = require('../dom/selection')
const debug = require('debug')('cypress:driver:mouse')
/**
* @typedef Coords
* @property {number} x
* @property {number} y
* @property {Document} doc
*/
const getLastHoveredEl = (state) => {
let lastHoveredEl = state('mouseLastHoveredEl')
const lastHoveredElAttached = lastHoveredEl && $elements.isAttachedEl(lastHoveredEl)
if (!lastHoveredElAttached) {
lastHoveredEl = null
state('mouseLastHoveredEl', lastHoveredEl)
}
return lastHoveredEl
}
const defaultPointerDownUpOptions = {
pointerType: 'mouse',
pointerId: 1,
isPrimary: true,
detail: 0,
// pressure 0.5 is default for mouse that doesn't support pressure
// https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure
pressure: 0.5,
}
const getMouseCoords = (state) => {
return state('mouseCoords')
}
const shouldFireMouseMoveEvents = (targetEl, lastHoveredEl, fromElViewport, coords) => {
// not the same element, fire mouse move events
if (lastHoveredEl !== targetEl) {
return true
}
const xy = (obj) => {
return _.pick(obj, 'x', 'y')
}
// if we have the same element, but the xy coords are different
// then fire mouse move events...
return !_.isEqual(xy(fromElViewport), xy(coords))
}
const shouldMoveCursorToEndAfterMousedown = (el) => {
if (!$elements.isElement(el)) {
return false
}
if (!($elements.isInput(el) || $elements.isTextarea(el) || $elements.isContentEditable(el))) {
return false
}
if (!$elements.isFocused(el)) {
return false
}
if ($elements.isNeedSingleValueChangeInputElement(el)) {
return false
}
return true
}
const create = (state, keyboard, focused) => {
const mouse = {
_getDefaultMouseOptions (x, y, win) {
const _activeModifiers = keyboard.getActiveModifiers(state)
const modifiersEventOptions = $Keyboard.toModifiersEventOptions(_activeModifiers)
const coordsEventOptions = toCoordsEventOptions(x, y, win)
return _.extend({
view: win,
// allow propagation out of root of shadow-dom
// https://developer.mozilla.org/en-US/docs/Web/API/Event/composed
composed: true,
// only for events involving moving cursor
relatedTarget: null,
}, modifiersEventOptions, coordsEventOptions)
},
/**
* @param {Coords} coords
* @param {HTMLElement} forceEl
*/
move (fromElViewport, forceEl) {
debug('mouse.move', fromElViewport)
const lastHoveredEl = getLastHoveredEl(state)
const targetEl = forceEl || mouse.getElAtCoords(fromElViewport)
// if the element is already hovered and our coords for firing the events
// already match our existing state coords, then bail early and don't fire
// any mouse move events
if (!shouldFireMouseMoveEvents(targetEl, lastHoveredEl, fromElViewport, getMouseCoords(state))) {
return { el: targetEl }
}
const events = mouse._moveEvents(targetEl, fromElViewport)
const resultEl = forceEl || mouse.getElAtCoords(fromElViewport)
return { el: resultEl, fromEl: lastHoveredEl, events }
},
/**
* @param {HTMLElement} el
* @param {Coords} coords
* Steps to perform mouse move:
* - send out events to elLastHovered (bubbles)
* - send leave events to all Elements until commonAncestor
* - send over events to elToHover (bubbles)
* - send enter events to all elements from commonAncestor
* - send move events to elToHover (bubbles)
* - elLastHovered = elToHover
*/
_moveEvents (el, coords) {
// events are not fired on disabled elements, so we don't have to take that into account
const win = $dom.getWindowByElement(el)
const { x, y } = coords
const defaultOptions = mouse._getDefaultMouseOptions(x, y, win)
const defaultMouseOptions = _.extend({}, defaultOptions, {
button: 0,
which: 0,
buttons: 0,
})
const defaultPointerOptions = _.extend({}, defaultOptions, {
button: -1,
which: 0,
buttons: 0,
pointerId: 1,
pointerType: 'mouse',
isPrimary: true,
})
const notFired = () => {
return {
skipped: formatReasonNotFired('Already on Coordinates'),
}
}
let pointerout = _.noop
let pointerleave = _.noop
let pointerover = notFired
let pointerenter = _.noop
let mouseout = _.noop
let mouseleave = _.noop
let mouseover = notFired
let mouseenter = _.noop
let pointermove = notFired
let mousemove = notFired
const lastHoveredEl = getLastHoveredEl(state)
const hoveredElChanged = el !== lastHoveredEl
let commonAncestor = null
if (hoveredElChanged && lastHoveredEl) {
commonAncestor = $elements.getFirstCommonAncestor(el, lastHoveredEl)
pointerout = () => {
sendPointerout(lastHoveredEl, _.extend({}, defaultPointerOptions, { relatedTarget: el }))
}
mouseout = () => {
sendMouseout(lastHoveredEl, _.extend({}, defaultMouseOptions, { relatedTarget: el }))
}
let curParent = lastHoveredEl
const elsToSendMouseleave = []
while (curParent && curParent.ownerDocument && curParent !== commonAncestor) {
elsToSendMouseleave.push(curParent)
curParent = curParent.parentNode
}
pointerleave = () => {
elsToSendMouseleave.forEach((elToSend) => {
sendPointerleave(elToSend, _.extend({}, defaultPointerOptions, { relatedTarget: el }))
})
}
mouseleave = () => {
elsToSendMouseleave.forEach((elToSend) => {
sendMouseleave(elToSend, _.extend({}, defaultMouseOptions, { relatedTarget: el }))
})
}
}
if (hoveredElChanged) {
if (el && $elements.isAttachedEl(el)) {
mouseover = () => {
return sendMouseover(el, _.extend({}, defaultMouseOptions, { relatedTarget: lastHoveredEl }))
}
pointerover = () => {
return sendPointerover(el, _.extend({}, defaultPointerOptions, { relatedTarget: lastHoveredEl }))
}
let curParent = el
const elsToSendMouseenter = []
while (curParent && curParent.ownerDocument && curParent !== commonAncestor) {
elsToSendMouseenter.push(curParent)
curParent = curParent.parentNode
}
elsToSendMouseenter.reverse()
pointerenter = () => {
return elsToSendMouseenter.forEach((elToSend) => {
sendPointerenter(elToSend, _.extend({}, defaultPointerOptions, { relatedTarget: lastHoveredEl }))
})
}
mouseenter = () => {
return elsToSendMouseenter.forEach((elToSend) => {
sendMouseenter(elToSend, _.extend({}, defaultMouseOptions, { relatedTarget: lastHoveredEl }))
})
}
}
}
pointermove = () => {
return sendPointermove(el, defaultPointerOptions)
}
mousemove = () => {
return sendMousemove(el, defaultMouseOptions)
}
const events = []
pointerout()
pointerleave()
events.push({ type: 'pointerover', ...pointerover() })
pointerenter()
mouseout()
mouseleave()
events.push({ type: 'mouseover', ...mouseover() })
mouseenter()
state('mouseLastHoveredEl', $elements.isAttachedEl(el) ? el : null)
state('mouseCoords', { x, y })
events.push({ type: 'pointermove', ...pointermove() })
events.push({ type: 'mousemove', ...mousemove() })
return events
},
/**
*
* @param {Coords} coords
* @returns {HTMLElement}
*/
getElAtCoords ({ x, y, doc }) {
const el = doc.elementFromPoint(x, y)
return el
},
/**
*
* @param {Coords} coords
*/
moveToCoords (coords) {
const { el } = mouse.move(coords)
return el
},
/**
* @param {Coords} coords
* @param {HTMLElement} forceEl
*/
_downEvents (coords, forceEl, pointerEvtOptionsExtend = {}, mouseEvtOptionsExtend = {}) {
const { x, y } = coords
const el = forceEl || mouse.moveToCoords(coords)
const win = $dom.getWindowByElement(el)
const defaultOptions = mouse._getDefaultMouseOptions(x, y, win)
const pointerEvtOptions = _.extend({}, defaultOptions, {
...defaultPointerDownUpOptions,
button: 0,
which: 1,
buttons: 1,
relatedTarget: null,
}, pointerEvtOptionsExtend)
const mouseEvtOptions = _.extend({}, defaultOptions, {
button: 0,
which: 1,
buttons: 1,
detail: 1,
}, mouseEvtOptionsExtend)
// TODO: pointer events should have fractional coordinates, not rounded
let pointerdown = sendPointerdown(
el,
pointerEvtOptions
)
const pointerdownPrevented = pointerdown.preventedDefault
const elIsDetached = $elements.isDetachedEl(el)
if (pointerdownPrevented || elIsDetached) {
let reason = 'pointerdown was cancelled'
if (elIsDetached) {
reason = 'Element was detached'
}
return {
targetEl: el,
events: {
pointerdown,
mousedown: {
skipped: formatReasonNotFired(reason),
},
},
}
}
let mousedown = sendMousedown(el, mouseEvtOptions)
return {
targetEl: el,
events: {
pointerdown,
mousedown,
},
}
},
down (fromElViewport, forceEl, pointerEvtOptionsExtend = {}, mouseEvtOptionsExtend = {}) {
const $previouslyFocused = focused.getFocused()
const mouseDownPhase = mouse._downEvents(fromElViewport, forceEl, pointerEvtOptionsExtend, mouseEvtOptionsExtend)
// el we just send pointerdown
const el = mouseDownPhase.targetEl
if (mouseDownPhase.events.pointerdown.preventedDefault || mouseDownPhase.events.mousedown.preventedDefault || !$elements.isAttachedEl(el)) {
return mouseDownPhase
}
//# retrieve the first focusable $el in our parent chain
const $elToFocus = $elements.getFirstFocusableEl($(el))
if (focused.needsFocus($elToFocus, $previouslyFocused)) {
if ($dom.isWindow($elToFocus)) {
// if the first focusable element from the click
// is the window, then we can skip the focus event
// since the user has clicked a non-focusable element
const $focused = focused.getFocused()
if ($focused) {
focused.fireBlur($focused.get(0))
}
} else {
// the user clicked inside a focusable element
focused.fireFocus($elToFocus.get(0))
}
}
if (shouldMoveCursorToEndAfterMousedown($elToFocus[0])) {
debug('moveSelectionToEnd due to click')
$selection.moveSelectionToEnd($dom.getDocumentFromElement($elToFocus[0]), { onlyIfEmptySelection: true })
}
return mouseDownPhase
},
/**
* @param {HTMLElement} el
* @param {Window} win
* @param {Coords} fromElViewport
* @param {HTMLElement} forceEl
*/
up (fromElViewport, forceEl, skipMouseEvent, pointerEvtOptionsExtend = {}, mouseEvtOptionsExtend = {}) {
debug('mouse.up', { fromElViewport, forceEl, skipMouseEvent })
return mouse._upEvents(fromElViewport, forceEl, skipMouseEvent, pointerEvtOptionsExtend, mouseEvtOptionsExtend)
},
/**
*
* Steps to perform a click:
*
* moveToCoordsOrNoop = (coords) => {
* elAtPoint = getElementFromPoint(coords)
* if (elAtPoint !== elLastHovered)
* sendMouseMoveEvents({to: elAtPoint, from: elLastHovered})
* elLastHovered = elAtPoint
* return getElementFromPoint(coords)
* }
*
* coords = getCoords(elSubject)
* el1 = moveToCoordsOrNoop(coords)
* sendMousedown(el1)
* el2 = moveToCoordsOrNoop(coords)
* sendMouseup(el2)
* el3 = moveToCoordsOrNoop(coords)
* if (notDetached(el1))
* sendClick(ancestorOf(el1, el2))
*/
click (fromElViewport, forceEl, pointerEvtOptionsExtend = {}, mouseEvtOptionsExtend = {}) {
debug('mouse.click', { fromElViewport, forceEl })
const mouseDownPhase = mouse.down(fromElViewport, forceEl, pointerEvtOptionsExtend, mouseEvtOptionsExtend)
const skipMouseupEvent = mouseDownPhase.events.pointerdown.skipped || mouseDownPhase.events.pointerdown.preventedDefault
const mouseUpPhase = mouse.up(fromElViewport, forceEl, skipMouseupEvent, pointerEvtOptionsExtend, mouseEvtOptionsExtend)
const getElementToClick = () => {
// Never skip the click event when force:true
if (forceEl) {
return { elToClick: forceEl }
}
// Only send click event if mousedown element is not detached.
if ($elements.isDetachedEl(mouseDownPhase.targetEl)) {
return { skipClickEventReason: 'element was detached' }
}
const commonAncestor = mouseUpPhase.targetEl &&
mouseDownPhase.targetEl &&
$elements.getFirstCommonAncestor(mouseUpPhase.targetEl, mouseDownPhase.targetEl)
return { elToClick: commonAncestor }
}
const { skipClickEventReason, elToClick } = getElementToClick()
const mouseClickEvents = mouse._mouseClickEvents(fromElViewport, elToClick, forceEl, skipClickEventReason, mouseEvtOptionsExtend)
return _.extend({}, mouseDownPhase.events, mouseUpPhase.events, mouseClickEvents)
},
/**
* @param {Coords} fromElViewport
* @param {HTMLElement} el
* @param {HTMLElement} forceEl
* @param {Window} win
*/
_upEvents (fromElViewport, forceEl, skipMouseEvent, pointerEvtOptionsExtend = {}, mouseEvtOptionsExtend = {}) {
const win = state('window')
let defaultOptions = mouse._getDefaultMouseOptions(fromElViewport.x, fromElViewport.y, win)
const pointerEvtOptions = _.extend({}, defaultOptions, {
...defaultPointerDownUpOptions,
buttons: 0,
}, pointerEvtOptionsExtend)
let mouseEvtOptions = _.extend({}, defaultOptions, {
buttons: 0,
detail: 1,
}, mouseEvtOptionsExtend)
const el = forceEl || mouse.moveToCoords(fromElViewport)
let pointerup = sendPointerup(el, pointerEvtOptions)
if (skipMouseEvent || $elements.isDetachedEl($(el))) {
return {
targetEl: el,
events: {
pointerup,
mouseup: {
skipped: formatReasonNotFired('Previous event cancelled'),
},
},
}
}
let mouseup = sendMouseup(el, mouseEvtOptions)
return {
targetEl: el,
events: {
pointerup,
mouseup,
},
}
},
_mouseClickEvents (fromElViewport, el, forceEl, skipClickEvent, mouseEvtOptionsExtend = {}) {
if (skipClickEvent) {
return {
click: {
skipped: formatReasonNotFired(skipClickEvent),
},
}
}
if (!forceEl) {
mouse.moveToCoords(fromElViewport)
}
const win = $dom.getWindowByElement(el)
const defaultOptions = mouse._getDefaultMouseOptions(fromElViewport.x, fromElViewport.y, win)
const clickEventOptions = _.extend({}, defaultOptions, {
buttons: 0,
detail: 1,
}, mouseEvtOptionsExtend)
let click = sendClick(el, clickEventOptions)
return { click }
},
_contextmenuEvent (fromElViewport, forceEl, mouseEvtOptionsExtend) {
const el = forceEl || mouse.moveToCoords(fromElViewport)
const win = $dom.getWindowByElement(el)
const defaultOptions = mouse._getDefaultMouseOptions(fromElViewport.x, fromElViewport.y, win)
const mouseEvtOptions = _.extend({}, defaultOptions, {
button: 2,
buttons: 2,
detail: 0,
which: 3,
}, mouseEvtOptionsExtend)
let contextmenu = sendContextmenu(el, mouseEvtOptions)
return { contextmenu }
},
dblclick (fromElViewport, forceEl, mouseEvtOptionsExtend = {}) {
const click = (clickNum) => {
const clickEvents = mouse.click(fromElViewport, forceEl, {}, { detail: clickNum })
return clickEvents
}
const clickEvents1 = click(1)
const clickEvents2 = click(2)
const el = forceEl || mouse.moveToCoords(fromElViewport)
const win = $dom.getWindowByElement(el)
const dblclickEvtProps = _.extend(mouse._getDefaultMouseOptions(fromElViewport.x, fromElViewport.y, win), {
buttons: 0,
detail: 2,
}, mouseEvtOptionsExtend)
let dblclick = sendDblclick(el, dblclickEvtProps)
return { clickEvents1, clickEvents2, dblclick }
},
rightclick (fromElViewport, forceEl) {
const pointerEvtOptionsExtend = {
button: 2,
buttons: 2,
which: 3,
}
const mouseEvtOptionsExtend = {
button: 2,
buttons: 2,
which: 3,
}
const mouseDownPhase = mouse.down(fromElViewport, forceEl, pointerEvtOptionsExtend, mouseEvtOptionsExtend)
const contextmenuEvent = mouse._contextmenuEvent(fromElViewport, forceEl)
const skipMouseupEvent = mouseDownPhase.events.pointerdown.skipped || mouseDownPhase.events.pointerdown.preventedDefault
const mouseUpPhase = mouse.up(fromElViewport, forceEl, skipMouseupEvent, pointerEvtOptionsExtend, mouseEvtOptionsExtend)
const clickEvents = _.extend({}, mouseDownPhase.events, mouseUpPhase.events)
return _.extend({}, { clickEvents, contextmenuEvent })
},
}
return mouse
}
const { stopPropagation } = window.MouseEvent.prototype
const sendEvent = (evtName, el, evtOptions, bubbles = false, cancelable = false, Constructor) => {
evtOptions = _.extend({}, evtOptions, { bubbles, cancelable })
const _eventModifiers = $Keyboard.fromModifierEventOptions(evtOptions)
const modifiers = $Keyboard.modifiersToString(_eventModifiers)
const evt = new Constructor(evtName, _.extend({}, evtOptions, { bubbles, cancelable }))
if (bubbles) {
evt.stopPropagation = function (...args) {
evt._hasStoppedPropagation = true
return stopPropagation.apply(this, ...args)
}
}
debug('event:', evtName, el)
const preventedDefault = !el.dispatchEvent(evt)
return {
stoppedPropagation: !!evt._hasStoppedPropagation,
preventedDefault,
el,
modifiers,
}
}
const sendPointerEvent = (el, evtOptions, evtName, bubbles = false, cancelable = false) => {
const Constructor = el.ownerDocument.defaultView.PointerEvent
return sendEvent(evtName, el, evtOptions, bubbles, cancelable, Constructor)
}
const sendMouseEvent = (el, evtOptions, evtName, bubbles = false, cancelable = false) => {
// TODO: IE doesn't have event constructors, so you should use document.createEvent('mouseevent')
// https://dom.spec.whatwg.org/#dom-document-createevent
const Constructor = el.ownerDocument.defaultView.MouseEvent
return sendEvent(evtName, el, evtOptions, bubbles, cancelable, Constructor)
}
const sendPointerup = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointerup', true, true)
}
const sendPointerdown = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointerdown', true, true)
}
const sendPointermove = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointermove', true, true)
}
const sendPointerover = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointerover', true, true)
}
const sendPointerenter = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointerenter', false, false)
}
const sendPointerleave = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointerleave', false, false)
}
const sendPointerout = (el, evtOptions) => {
return sendPointerEvent(el, evtOptions, 'pointerout', true, true)
}
const sendMouseup = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mouseup', true, true)
}
const sendMousedown = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mousedown', true, true)
}
const sendMousemove = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mousemove', true, true)
}
const sendMouseover = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mouseover', true, true)
}
const sendMouseenter = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mouseenter', false, false)
}
const sendMouseleave = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mouseleave', false, false)
}
const sendMouseout = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'mouseout', true, true)
}
const sendClick = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'click', true, true)
}
const sendDblclick = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'dblclick', true, true)
}
const sendContextmenu = (el, evtOptions) => {
return sendMouseEvent(el, evtOptions, 'contextmenu', true, true)
}
const formatReasonNotFired = (reason) => {
return `⚠️ not fired (${reason})`
}
const toCoordsEventOptions = (x, y, win) => {
// these are the coords from the element's window,
// ignoring scroll position
const { scrollX, scrollY } = win
return {
x,
y,
clientX: x,
clientY: y,
screenX: x,
screenY: y,
pageX: x + scrollX,
pageY: x + scrollY,
layerX: x + scrollX,
layerY: x + scrollY,
}
}
module.exports = {
create,
}