Skip to content

feat: scrollTo allows ElementHandle arg - #207

Open
bvandrc wants to merge 3 commits into
Xetera:masterfrom
bvandrc:feat/scrollTo-elementHandle
Open

feat: scrollTo allows ElementHandle arg#207
bvandrc wants to merge 3 commits into
Xetera:masterfrom
bvandrc:feat/scrollTo-elementHandle

Conversation

@bvandrc

@bvandrc bvandrc commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends GhostCursor.scrollTo to accept a Puppeteer ElementHandle as the destination, allowing callers to scroll directly to an element rather than only to coordinates or edge keywords.

Changes:

  • Updated scrollTo to accept ElementHandle and resolve it to a scroll target via boundingBox().
  • Adjusted internal resolution logic to handle the new destination type asynchronously.
  • Updated README documentation to include ElementHandle in the scrollTo signature and parameter description.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/spoof.ts Expands scrollTo destination handling to support ElementHandle and updates the destination resolution logic.
README.md Documents the expanded scrollTo destination types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/spoof.ts
Comment on lines 161 to 162

export type ScrollToDestination = Partial<Vector> | 'top' | 'bottom' | 'left' | 'right'

export type MouseButtonOptions = Pick<ClickOptions, 'button' | 'clickCount'>
Comment thread src/spoof.ts
Comment on lines +949 to +962
default: {
const isElementHandle =
typeof destination === 'object' && 'evaluate' in destination

if (isElementHandle) {
const box = await destination.boundingBox()
if (box == null) {
throw new Error('no boundingBox')
}
return box
}

return destination
}
Comment thread README.md
- **destination:** Can be any of:
- An object with `x` and `y` coordinates representing the target position. For example, `{ x: 500, y: 300 }`.
- `'top'` or `'bottom'` or `'left'` or `'right'`.
- An ElementHandle.
@Niek

Niek commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

@bvandrc can you please check review comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants