From 9aeee0515f83dd884e71b8e26320bb58a81441e6 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 16 May 2020 17:22:06 +0200 Subject: [PATCH] editor: make dragresize rectangle resize with viewport --- src/client/ui/ui-dragresize.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/client/ui/ui-dragresize.js b/src/client/ui/ui-dragresize.js index 6f9bacba..4df72d5c 100644 --- a/src/client/ui/ui-dragresize.js +++ b/src/client/ui/ui-dragresize.js @@ -32,6 +32,7 @@ class UiDragResize extends UiWidget { this.width = 0 this.height = 0 + this.widgets = [] this.mounted = false this.handles = DOM.get(this.container, '.handle') @@ -94,6 +95,10 @@ class UiDragResize extends UiWidget { }, {element: this.container}) + window.addEventListener('resize', ()=>{ + if (this.mounted) this.updateRectangle() + }) + // this.handles[0]._ignore_css_transforms = true } @@ -104,6 +109,7 @@ class UiDragResize extends UiWidget { this.container.parentNode.removeChild(this.container) this.mounted = false + this.widgets = [] } @@ -112,11 +118,22 @@ class UiDragResize extends UiWidget { this.clear() - widgets = widgets.slice().filter(w=>w.getProp('visible') && !(w instanceof Tab) && !(w instanceof Root)) + this.widgets = widgets.slice().filter(w=>w.getProp('visible') && !(w instanceof Tab) && !(w instanceof Root)) - if (!widgets.length) return + if (!this.widgets.length) return - var widget = widgets[0] + this.updateRectangle() + + this.widgets[0].parentNode.appendChild(this.container) + this.mounted = true + + + } + + updateRectangle() { + + var widgets = this.widgets, + widget = widgets[0] var handlesVisibility = [ widget.parent.getProp('layout') === 'default', // nw @@ -145,9 +162,6 @@ class UiDragResize extends UiWidget { this.updateCss() - parent.appendChild(this.container) - this.mounted = true - } updateCss(grid) {