Created
October 24, 2019 16:58
-
-
Save jeovazero/43c7157a5ee9c114de241007fc875849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fake(card) { | |
const el = document.querySelector(card) | |
console.log(el) | |
const bounds = el.getBoundingClientRect() | |
const { x, y } = bounds | |
const down = new MouseEvent('mousedown', { | |
bubbles: true, | |
clientX: x + 10, | |
clientY: y + 10, | |
button: 0 | |
}) | |
const move = new MouseEvent('mousemove', { | |
bubbles: true, | |
clientX: x + 10, | |
clientY: y + 50, | |
button: 0 | |
}) | |
const up = new MouseEvent('mouseup', { | |
bubbles: true, | |
clientX: x + 10, | |
clientY: y + 50, | |
button: 0 | |
}) | |
console.log(el.dispatchEvent(down)) | |
document.querySelector(card).dispatchEvent(move) | |
console.log(document.querySelector(card).getBoundingClientRect()) | |
document.querySelector(card).dispatchEvent(up) | |
} | |
fake('.card') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment