Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scrollBy method to Element #1623

Open
OlaviSau opened this issue Nov 25, 2024 · 1 comment
Open

Add scrollBy method to Element #1623

OlaviSau opened this issue Nov 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@OlaviSau
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Our components us the scrollBy functionality and it would be great if this would be implemented as it is very simple to implement.

Describe the solution you'd like
It should be as simple as adding this to nodes/element/Element.js

	scrollBy(xCoordOrOptions, yCoord) {
		if (typeof xCoordOrOptions !== "object" && arguments.length === 1) {
			throw new TypeError(
				"Failed to execute 'scrollBy' on 'Element': The provided value is not of type 'ScrollToOptions'."
			);
		}
		const options = typeof xCoordOrOptions === "object" ? xCoordOrOptions : { left: xCoordOrOptions, top: yCoord };
		this.scroll({
			left: this.scrollLeft + (options.left ?? 0),
			top: this.scrollTop + (options.top ?? 0),
			behavior: options.behavior
		});
	}

Describe alternatives you've considered
This is part of the browser API.

Will create a PR.

@OlaviSau OlaviSau added the enhancement New feature or request label Nov 25, 2024
@OlaviSau
Copy link
Contributor Author

@capricorn86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant