scripting: add scrollIntoView()
This commit is contained in:
parent
22068ab47e
commit
7fc5372ca1
3 changed files with 26 additions and 6 deletions
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
- scripting
|
||||
- add `uploadFile` function for reading client-side files
|
||||
- add `scrollIntoView` function
|
||||
|
||||
## 1.30.2
|
||||
|
||||
|
|
|
|||
|
|
@ -328,10 +328,6 @@ Gives focus to a widget (ie input widget). If `id` is omitted or falsy, currentl
|
|||
|
||||
Returns the scroll position of a container as a `[x, y]` array.
|
||||
|
||||
**Deprecated**
|
||||
|
||||
Scrollable panels expose their scroll position normalized between 0 and 1 with their value.
|
||||
|
||||
----
|
||||
|
||||
#### `setScroll(id, x, y)`
|
||||
|
|
@ -341,9 +337,14 @@ Scrollable panels expose their scroll position normalized between 0 and 1 with t
|
|||
|
||||
Sets the scroll state of a container.
|
||||
|
||||
**Deprecated**
|
||||
----
|
||||
|
||||
#### `scrollIntoView(id, option)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `option`: `alignToTop` or `options` argument as defined in https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
||||
|
||||
Scroll containers to make widget(s) visible.
|
||||
|
||||
Scrollable panels expose their scroll position normalized between 0 and 1 with their value.
|
||||
|
||||
----
|
||||
|
||||
|
|
|
|||
|
|
@ -279,6 +279,24 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
this.globals.scrollIntoView = (id, options)=>{
|
||||
|
||||
this.checkContext('setScroll')
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
if (widgets[i].container && widgets[i].isVisible()) {
|
||||
widgets[i].container.scrollIntoView(options)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.globals.httpGet = (url, callback)=>{
|
||||
|
||||
this.checkContext('httpGet')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue