mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 11:09:13 +00:00
add scrollPosition method
This commit is contained in:
@@ -9,6 +9,7 @@ _During the beta period, these restrictions may be relaxed in the event of a mis
|
||||
## Next
|
||||
|
||||
- Added `?` to optional arguments in methods tables
|
||||
- Added the `scrollPosition()` method to `sl-textarea` to get/set scroll position
|
||||
|
||||
## 2.0.0-beta.42
|
||||
|
||||
|
||||
@@ -162,6 +162,20 @@ export default class SlTextarea extends LitElement {
|
||||
return this.input.select();
|
||||
}
|
||||
|
||||
/** Gets or sets the textarea's scroll position. */
|
||||
scrollPosition(position?: { top?: number; left?: number }) {
|
||||
if (position) {
|
||||
if (typeof position.top === 'number') this.input.scrollTop = position.top;
|
||||
if (typeof position.left === 'number') this.input.scrollLeft = position.left;
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
top: this.input.scrollTop,
|
||||
left: this.input.scrollTop
|
||||
};
|
||||
}
|
||||
|
||||
/** Sets the start and end positions of the text selection (0-based). */
|
||||
setSelectionRange(
|
||||
selectionStart: number,
|
||||
|
||||
Reference in New Issue
Block a user