add scrollPosition method

This commit is contained in:
Cory LaViska
2021-05-29 10:55:56 -04:00
parent 9b21d5a619
commit 0dbb72efe9
2 changed files with 15 additions and 0 deletions

View File

@@ -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

View File

@@ -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,