script: add getScroll and setScroll
This commit is contained in:
parent
330649e4d0
commit
c40a6157a2
2 changed files with 29 additions and 3 deletions
|
|
@ -223,8 +223,8 @@ class Panel extends Container() {
|
|||
if (!s) {
|
||||
return [this.widget.scrollLeft, this.widget.scrollTop]
|
||||
} else {
|
||||
this.widget.scrollLeft = s[0]
|
||||
this.widget.scrollTop = s[1]
|
||||
if (s[0] !== undefined) this.widget.scrollLeft = s[0]
|
||||
if (s[1] !== undefined) this.widget.scrollTop = s[1]
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,32 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.getScroll = (id)=>{
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
if (widgets[i].scroll) return widgets[i].scroll()
|
||||
|
||||
}
|
||||
|
||||
return []
|
||||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.setScroll = (id, x, y)=>{
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
if (widgets[i].scroll) widgets[i].scroll([x, y])
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.httpGet = (url, callback)=>{
|
||||
|
||||
var parser = urlParser(url),
|
||||
|
|
@ -286,7 +312,7 @@ class ScriptVm extends Vm {
|
|||
}
|
||||
|
||||
for (var imports of ['set', 'get', 'getProp', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'unfocus']) {
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'unfocus', 'setScroll', 'getScroll']) {
|
||||
this.sanitize(this.sandbox.contentWindow[imports])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue