Skip to content

[🚀esl-utils]: replace scrollIntoView() from scroll utils with new implementation #972

@dshovchko

Description

@dshovchko

As an ESL consumer, I want to be able to have promisified versions for scrollIntoView().

Method scrolls the element's parent container such that the element on which scrollIntoView() is called is visible to the user. The promise is resolved when the element became visible to the user and scrolling stops.

Method definition:

export function scrollIntoView(element: Element, options?: boolean | ScrollIntoViewOptions | undefined): Promise<boolean> {
}

Parameters:

element - the element which should become visible

options (Optional)

For boolean value:

  • If true, the top of the element will be aligned to the top of the visible area of the scrollable ancestor. Corresponds to scrollIntoViewOptions: {block: "start", inline: "nearest"}. This is the default value.
  • If false, the bottom of the element will be aligned to the bottom of the visible area of the scrollable ancestor. Corresponds to scrollIntoViewOptions: {block: "end", inline: "nearest"}.

For Object with the following properties:

  • behavior (Optional) - defines the transition animation. One of auto or smooth. Defaults to auto.
  • block (Optional) - defines vertical alignment. One of start, center, end, or nearest. Defaults to start.
  • inline (Optional) - defines horizontal alignment. One of start, center, end, or nearest. Defaults to nearest.
  • offsetTop (Optional) - defines vertical offset in pixels. Defaults is 0.
  • offsetLeft (Optional) - defines horizontal offset in pixels. Defaults is 0.

Proposal of implementation:

The method should realize incremental scroll to a passed element rely on the passed behavior option. Should update target position per each frame.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions