Co-authored-by: Alireza <ar.sedghi@gmail.com> Co-authored-by: Dan Rukas <dan.rukas@gmail.com> Co-authored-by: Tang Cheng <45505657+tctco@users.noreply.github.com>
This commit is contained in:
44 files changed
+516
-258
No files matched your search
@@ -5,21 +5,21 @@ interface WindowWithMousePosition extends Window {
|
||||
mouseY: number;
|
||||
}
|
||||
|
||||
export const initilizeMousePositionTracker = async (page: Page) => {
|
||||
const window = await page.evaluateHandle("window") as any;
|
||||
export const initializeMousePositionTracker = async (page: Page) => {
|
||||
const window = (await page.evaluateHandle('window')) as any;
|
||||
await page.evaluate((window: WindowWithMousePosition) => {
|
||||
window.mouseX = 0;
|
||||
window.mouseY = 0;
|
||||
window.addEventListener("mousemove", (event) => {
|
||||
window.addEventListener('mousemove', event => {
|
||||
window.mouseX = event.clientX;
|
||||
window.mouseY = event.clientY;
|
||||
});
|
||||
}, window);
|
||||
}
|
||||
};
|
||||
|
||||
export const getMousePosition = async (page: Page) => {
|
||||
const window = await page.evaluateHandle("window") as any;
|
||||
const window = (await page.evaluateHandle('window')) as any;
|
||||
return await page.evaluate((window: WindowWithMousePosition) => {
|
||||
return { x: window.mouseX, y: window.mouseY };
|
||||
}, window);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user