add scrollPosition method

pull/463/head
Cory LaViska 2021-05-29 10:55:56 -04:00
rodzic 9b21d5a619
commit 0dbb72efe9
2 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

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