MCPcopy
hub / github.com/basecamp/trix / mouseDownOnElementAndMove

Function mouseDownOnElementAndMove

src/test/test_helpers/input_helpers.js:219–244  ·  view source on GitHub ↗
(element, distance)

Source from the content-addressed store, hash-verified

217}
218
219export const mouseDownOnElementAndMove = async (element, distance) => {
220 const coordinates = getElementCoordinates(element)
221 triggerEvent(element, "mousedown", coordinates)
222
223 const destination = (offset) => ({
224 clientX: coordinates.clientX + offset,
225 clientY: coordinates.clientY + offset,
226 })
227
228 const dragSpeed = 20
229 await delay(dragSpeed)
230
231 let offset = 0
232 const drag = async () => {
233 if (++offset <= distance) {
234 triggerEvent(element, "mousemove", destination(offset))
235 await delay(dragSpeed)
236 drag()
237 } else {
238 triggerEvent(element, "mouseup", destination(distance))
239 await delay(dragSpeed)
240 }
241 }
242
243 drag()
244}
245
246const typeCharacterInElement = async (character, element) => {
247 const charCode = character.charCodeAt(0)

Callers

nothing calls this directly

Calls 4

triggerEventFunction · 0.90
delayFunction · 0.90
getElementCoordinatesFunction · 0.85
dragFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…