Files
xod/packages/xod-client-browser/test-func/utils/drag.js
Evgeny Kochetkov e6ab08e297 chore(infra): format code with prettier
Just `yarn lint  --fix`
2018-03-05 17:59:03 +03:00

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();
}