mirror of
https://github.com/xodio/xod.git
synced 2026-03-12 19:56:49 +01:00
17 lines
601 B
JavaScript
17 lines
601 B
JavaScript
import getBoundingClientRect from './getBoundingClientRect';
|
|
import getCenterPositon from './getCenterPositon';
|
|
|
|
export default async function drag(page, elementHandle, delta) {
|
|
// can't use hover with SVGs, see https://github.com/GoogleChrome/puppeteer/issues/1247
|
|
const rect = await getBoundingClientRect(page, elementHandle);
|
|
const startingPosition = getCenterPositon(rect);
|
|
|
|
await page.mouse.move(startingPosition.x, startingPosition.y);
|
|
await page.mouse.down();
|
|
await page.mouse.move(
|
|
startingPosition.x + delta.x,
|
|
startingPosition.y + delta.y
|
|
);
|
|
await page.mouse.up();
|
|
}
|