fixed mouse movent, now takes scroll position into account

develop
Sascha Nitsch 2024-09-04 18:58:35 +02:00
parent 7a8895df33
commit 4ea99cd4f8
2 changed files with 13 additions and 0 deletions

View File

@ -57,6 +57,9 @@ function mousemove($main, $control, $options) : bool
$targetPos = $control->getElementRect($element);
$targetX = $targetPos['x'] + $targetPos['width'] / 2;
$targetY = $targetPos['y'] + $targetPos['height'] / 2;
$scroll = $control->getScrollPosition();
$targetX -= $scroll[0];
$targetY -= $scroll[1];
// echo "move $element - $tokens[1] $targetX $targetY\n";
$mouseX = $main->getMouseX();
$mouseY = $main->getMouseY();

View File

@ -174,6 +174,16 @@ class Control
return (!is_array($url)) ? $url : '';
}
/**
* get scroll position
*
* @return [int,int] current scroll position
*/
public function getScrollPosition()
{
return $this->executeScript('return [window.pageXOffset, window.pageYOffset];');
}
/**
* move mouse to absolute position
*