@@ -8,17 +8,22 @@ import debugFn from 'debug'
88import type { StateFunc } from '../cypress/state'
99import type { IFocused } from './focused'
1010import type { ICypress } from '../cypress'
11+ import type { ElViewportPostion } from '../dom/coordinates'
1112
1213const debug = debugFn ( 'cypress:driver:mouse' )
1314
15+ export type ForceEl = false | HTMLElement
16+
17+ export type MouseCoords = { x ?: number , y ?: number }
18+
1419/**
1520 * @typedef Coords
1621 * @property {number } x
1722 * @property {number } y
1823 * @property {Document } doc
1924 */
2025
21- const getLastHoveredEl = ( state ) : HTMLElement | null => {
26+ const getLastHoveredEl = ( state : StateFunc ) : HTMLElement | null => {
2227 let lastHoveredEl = state ( 'mouseLastHoveredEl' )
2328 const lastHoveredElAttached = lastHoveredEl && $elements . isAttachedEl ( lastHoveredEl )
2429
@@ -40,7 +45,7 @@ const defaultPointerDownUpOptions = {
4045 pressure : 0.5 ,
4146}
4247
43- const getMouseCoords = ( state ) => {
48+ const getMouseCoords = ( state : StateFunc ) => {
4449 return state ( 'mouseCoords' )
4550}
4651
@@ -205,11 +210,7 @@ export const create = (state: StateFunc, keyboard: Keyboard, focused: IFocused,
205210 } , modifiersEventOptions , coordsEventOptions )
206211 } ,
207212
208- /**
209- * @param {Coords } coords
210- * @param {HTMLElement } forceEl
211- */
212- move ( fromElViewport , forceEl ?) {
213+ move ( fromElViewport : ElViewportPostion , forceEl ?: ForceEl ) {
213214 debug ( 'mouse.move' , fromElViewport )
214215
215216 const lastHoveredEl = getLastHoveredEl ( state )
@@ -241,7 +242,7 @@ export const create = (state: StateFunc, keyboard: Keyboard, focused: IFocused,
241242 * - send move events to elToHover (bubbles)
242243 * - elLastHovered = elToHover
243244 */
244- _moveEvents ( el , coords ) {
245+ _moveEvents ( el : HTMLElement , coords : ElViewportPostion ) {
245246 // events are not fired on disabled elements, so we don't have to take that into account
246247 const win = $dom . getWindowByElement ( el )
247248 const { x, y } = coords
@@ -386,7 +387,7 @@ export const create = (state: StateFunc, keyboard: Keyboard, focused: IFocused,
386387 * @param {Coords } coords
387388 * @returns {HTMLElement }
388389 */
389- getElAtCoords ( { x, y, doc } ) {
390+ getElAtCoords ( { x, y, doc } : ElViewportPostion ) {
390391 const el = $dom . elementFromPoint ( doc , x , y )
391392
392393 return el
0 commit comments