From d859c0f253a0bb83c5c6493cbcd049e06d78497a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Aug 2020 23:37:42 +0300 Subject: [PATCH] [SSE] Resize cell editor in multiples of line height --- apps/common/main/lib/component/Layout.js | 24 +++++++++++++++---- .../main/app/view/Viewport.js | 3 ++- .../main/resources/less/celleditor.less | 2 ++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/apps/common/main/lib/component/Layout.js b/apps/common/main/lib/component/Layout.js index 8251aceab..50428d26c 100644 --- a/apps/common/main/lib/component/Layout.js +++ b/apps/common/main/lib/component/Layout.js @@ -167,7 +167,8 @@ define([ fmax : panel.resize.fmax, behaviour : panel.behaviour, index : this.splitters.length, - offset : panel.resize.offset || 0 + offset : panel.resize.offset || 0, + multiply : panel.resize.multiply }; if (!stretch) { @@ -264,6 +265,7 @@ define([ this.resize.fmin = panel.fmin; this.resize.fmax = panel.fmax; this.resize.behaviour = panel.behaviour; + this.resize.multiply = panel.multiply; this.resize.$el.addClass('move'); @@ -274,9 +276,11 @@ define([ } else if (e.data.type == 'horizontal') { this.resize.width = parseInt(this.resize.$el.css('width')); - this.resize.max = (panel.maxpos > 0 ? panel.maxpos : this.resize.$el.parent().height() + panel.maxpos) - this.resize.width; + this.resize.max = (panel.maxpos > 0 ? panel.maxpos : this.resize.$el.parent().width() + panel.maxpos) - this.resize.width; this.resize.initx = e.pageX*Common.Utils.zoom() - parseInt(e.currentTarget.style.left); } + if (this.resize.multiply && this.resize.multiply.koeff) + this.resize.max = Math.floor(this.resize.max/this.resize.multiply.koeff) * this.resize.multiply.koeff + (this.resize.multiply.offset || 0); Common.NotificationCenter.trigger('layout:resizestart'); }, @@ -290,7 +294,13 @@ define([ prop = 'left'; value = e.pageX*zoom - this.resize.initx; } - + if (this.resize.multiply && this.resize.multiply.koeff) { + var m = this.resize.multiply.koeff, + val = value/m, + vfloor = Math.floor(val) * m + (this.resize.multiply.offset || 0), + vceil = Math.ceil(val) * m + (this.resize.multiply.offset || 0); + value = (value>vfloor+m/2) ? vceil : vfloor; + } if (this.resize.fmin && this.resize.fmax) { if (!(value < this.resize.fmin()) && !(value > this.resize.fmax())) { this.resize.$el[0].style[prop] = value + 'px'; @@ -332,7 +342,13 @@ define([ prop = 'width'; value = e.pageX*zoom - this.resize.initx; } - + if (this.resize.multiply && this.resize.multiply.koeff) { + var m = this.resize.multiply.koeff, + val = value/m, + vfloor = Math.floor(val) * m + (this.resize.multiply.offset || 0), + vceil = Math.ceil(val) * m + (this.resize.multiply.offset || 0); + value = (value>vfloor+m/2) ? vceil : vfloor; + } if (this.resize.fmin && this.resize.fmax) { value < this.resize.fmin() && (value = this.resize.fmin()); value > this.resize.fmax() && (value = this.resize.fmax()); diff --git a/apps/spreadsheeteditor/main/app/view/Viewport.js b/apps/spreadsheeteditor/main/app/view/Viewport.js index ea2116bac..d866e501a 100644 --- a/apps/spreadsheeteditor/main/app/view/Viewport.js +++ b/apps/spreadsheeteditor/main/app/view/Viewport.js @@ -135,7 +135,8 @@ define([ rely: true, resize: { min: 19, - max: -100 + max: -100, + multiply: { koeff: 18, offset: 2} } }, { el: items[1], diff --git a/apps/spreadsheeteditor/main/resources/less/celleditor.less b/apps/spreadsheeteditor/main/resources/less/celleditor.less index 3250734d3..3cbb6c018 100644 --- a/apps/spreadsheeteditor/main/resources/less/celleditor.less +++ b/apps/spreadsheeteditor/main/resources/less/celleditor.less @@ -83,6 +83,8 @@ min-height: 19px; border: 0 none; font-size: 12px; + line-height: 18px; + padding-bottom: 0; &[disabled] { color: @gray-darker;