feat: scrollTo allows ElementHandle arg - #207
Open
bvandrc wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
scrollToto acceptElementHandleand resolve it to a scroll target viaboundingBox(). - Adjusted internal resolution logic to handle the new destination type asynchronously.
- Updated README documentation to include
ElementHandlein thescrollTosignature 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 on lines
161
to
162
|
|
||
| export type ScrollToDestination = Partial<Vector> | 'top' | 'bottom' | 'left' | 'right' | ||
|
|
||
| export type MouseButtonOptions = Pick<ClickOptions, 'button' | 'clickCount'> |
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 | ||
| } |
| - **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. |
Collaborator
|
@bvandrc can you please check review comments? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.