From 39ab3d86bd5c547b5b7bdc2f44851d27163c6d7a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 18 Oct 2018 15:51:22 +0200 Subject: [PATCH] create sizer that sets item size with flex-basis works with the flex-grow we set initially for the sub lists --- src/components/views/rooms/RoomList.js | 2 +- src/resizer/index.js | 3 ++- src/resizer/sizer.js | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index b6585c4e1f..bca274dd82 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -35,7 +35,7 @@ import RoomListStore from '../../../stores/RoomListStore'; import GroupStore from '../../../stores/GroupStore'; import ResizeHandle from '../elements/ResizeHandle'; -import {Resizer, CollapseDistributor} from '../../../resizer' +import {Resizer, FixedDistributor, FlexSizer} from '../../../resizer' const HIDE_CONFERENCE_CHANS = true; const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/; diff --git a/src/resizer/index.js b/src/resizer/index.js index f0c5878a1d..df7a839b9b 100644 --- a/src/resizer/index.js +++ b/src/resizer/index.js @@ -14,13 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -import {Sizer} from "./sizer"; +import {Sizer, FlexSizer} from "./sizer"; import {FixedDistributor, CollapseDistributor, PercentageDistributor} from "./distributors"; import {Resizer} from "./resizer"; module.exports = { Resizer, Sizer, + FlexSizer, FixedDistributor, CollapseDistributor, PercentageDistributor, diff --git a/src/resizer/sizer.js b/src/resizer/sizer.js index b8d1c55dd0..fb4e860d4e 100644 --- a/src/resizer/sizer.js +++ b/src/resizer/sizer.js @@ -97,4 +97,11 @@ class Sizer { } } -module.exports = {Sizer}; +class FlexSizer extends Sizer { + setItemSize(item, size) { + item.style.flexGrow = '0'; + item.style.flexBasis = `${Math.round(size)}px`; + } +} + +module.exports = {Sizer, FlexSizer};