Skip to content

Commit

Permalink
fix(types): Accept false as valid scrollBehavior value (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored Apr 18, 2021
1 parent 4462edb commit 3f7c7d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ Options:
- `Optional` **pointer**: \"mouse\" \| \"pen\"
- `Optional` x coordinate to click **x**: number
- `Optional` y coordinate to click **y**: number
- `Optional` **position**: "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
- `Optional` **position**: "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
- `Optional` **scrollBehavior**: "center" | "top" | "bottom" | "nearest" | false

> Make sure that `x` and `y` has a bigger priority than `position`.
Expand All @@ -120,6 +121,7 @@ Options:

- `Optional` **pointer**: \"mouse\" \| \"pen\"
- `Optional` **position**: "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
- `Optional` **scrollBehavior**: "center" | "top" | "bottom" | "nearest" | false

## cy.realPress

Expand Down
5 changes: 3 additions & 2 deletions src/getCypressElementCoordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type Position =
| "bottomRight"
| { x: number; y: number };

export type ScrollBehaviorOptions = "center" | "top" | "bottom" | "nearest";
type ScrollBehaviorPosition = "center" | "top" | "bottom" | "nearest";
export type ScrollBehaviorOptions = ScrollBehaviorPosition | false;

function getPositionedCoordinates(
x0: number,
Expand Down Expand Up @@ -52,7 +53,7 @@ function getPositionedCoordinates(
*/
function scrollIntoView(
htmlElement: HTMLElement,
scrollBehavior: ScrollBehaviorOptions = "center"
scrollBehavior: ScrollBehaviorPosition = "center"
) {
let block: ScrollLogicalPosition;

Expand Down

0 comments on commit 3f7c7d7

Please sign in to comment.