Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ import * as DomEventType from '../DomEventType/DomEventType.ts'
import * as GetEventClass from '../GetEventClass/GetEventClass.ts'

export const mouseEvent = (element, eventType, options) => {
const event = new MouseEvent(eventType, options)
// Get the element's bounding rect and calculate center position
const rect = element.getBoundingClientRect()
const centerX = rect.left + rect.width / 2
const centerY = rect.top + rect.height / 2

// Ensure clientX and clientY are set if not provided
const eventOptions = {
...options,
clientX: options?.clientX ?? centerX,
clientY: options?.clientY ?? centerY,
}

const event = new MouseEvent(eventType, eventOptions)
element.dispatchEvent(event)
}

Expand Down
Loading