diff --git a/src/client/widgets/containers/panel.js b/src/client/widgets/containers/panel.js index 550c5ebe..3bb648bf 100644 --- a/src/client/widgets/containers/panel.js +++ b/src/client/widgets/containers/panel.js @@ -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] } } diff --git a/src/client/widgets/scripts/script-vm.js b/src/client/widgets/scripts/script-vm.js index 6ce35d48..2d4b36af 100644 --- a/src/client/widgets/scripts/script-vm.js +++ b/src/client/widgets/scripts/script-vm.js @@ -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]) }