Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Add scrollToElement command and scrollBeforeClick option #167

Merged
merged 4 commits into from
Aug 6, 2017

Conversation

janza
Copy link
Contributor

@janza janza commented Aug 3, 2017

closes #15

@adieuadieu adieuadieu requested a review from schickling August 3, 2017 20:42
Copy link
Collaborator

@adieuadieu adieuadieu left a comment

Choose a reason for hiding this comment

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

Hi @janza thank you for this PR! Looks good other than a small typeo

README.md Outdated
@@ -152,6 +152,7 @@ const chromeless = new Chromeless({
- [`mousedown(selector: string)`](docs/api.md#api-mousedown)
- [`mouseup(selector: string)`](docs/api.md#api-mouseup)
- [`scrollTo(x: number, y: number)`](docs/api.md#api-scrollto)
- [`scrollToElement(selector: string)`](docs/api.md#api-scrollto)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this is linking to the wrong place. Should be docs/api.md#api-scrolltoelement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, fixed!

Copy link
Collaborator

@adieuadieu adieuadieu left a comment

Choose a reason for hiding this comment

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

@janza Hm.. I noticed another thing. In #15 it's mentioned in #15 (comment) that we should scroll past the element until it's completely within the viewport, however I'm not sure if your PR incorporates that since you're scrolling to the top-left of the element.

To address this, it might be as simple as, instead of scrolling to the top-left of the element rect, scroll to the bottom-right? Although this might not cover the case where you are scrolling horizontally. @joelgriffith @timsuchanek?

@janza
Copy link
Contributor Author

janza commented Aug 4, 2017

What it does is it aligns the top left point of the viewport to the top left point of the element to scroll to, so the whole element will be in the viewport (unless it's bigger than viewport).
Other possible solution would be to put the element in the center of the viewport.

@joelgriffith
Copy link
Contributor

I'm digging deep back into the jQuery days (and anchor hrefs), which do scroll that element to the top of the viewport panel. I feel that most folks will be somewhat expecting this just due to the nature of scroll-to's elsewhere.

docs/api.md Outdated

### scrollToElement(selector: string): Chromeless<T>

Scroll to location of element.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might add a note that the expected behavior is the element will be at the top of viewport just to remove that uncertainty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@adieuadieu adieuadieu left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, @janza!

@adieuadieu adieuadieu merged commit d82e42a into schickling:master Aug 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scroll to click position
4 participants