Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.13] Fix precision loss (int vs float mixup) #655

Open
wants to merge 2 commits into
base: 1.13
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Input/Mouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Mouse
*/
protected $page;

protected $x = 0;
protected $y = 0;
protected $x = 0.0;
protected $y = 0.0;

protected $button = self::BUTTON_NONE;

Expand All @@ -45,16 +45,16 @@ public function __construct(Page $page)
}

/**
* @param int $x
* @param int $y
* @param float $x
* @param float $y
* @param array|null $options
*
* @throws \HeadlessChromium\Exception\CommunicationException
* @throws \HeadlessChromium\Exception\NoResponseAvailable
*
* @return $this
*/
public function move(int $x, int $y, array $options = null)
public function move(float $x, float $y, array $options = null)
{
$this->page->assertNotClosed();

Expand Down Expand Up @@ -329,13 +329,13 @@ public function findElement(Selector $selector, int $position = 1): self
/**
* Get the maximum distance to scroll a page.
*
* @param int $distance Distance to scroll, positive or negative
* @param int $current Current position
* @param int $maximum Maximum possible distance
* @param float $distance Distance to scroll, positive or negative
* @param float $current Current position
* @param float $maximum Maximum possible distance
*
* @return int allowed distance to scroll
* @return float allowed distance to scroll
*/
private function getMaximumDistance(int $distance, int $current, int $maximum): int
private function getMaximumDistance(float $distance, float $current, float $maximum): float
{
$result = $current + $distance;

Expand Down
Loading