Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Improve room sublist resizing #2440

Merged
merged 27 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d558ea1
WIP
bwindels Dec 19, 2018
5eba821
Merge branch 'experimental' into bwindels/smarterresizer
bwindels Jan 8, 2019
4bd6ce8
WIP2 for making smart resizer work, sort of works now but shows big s…
bwindels Jan 8, 2019
b419705
change min size to exactly one room tile + header
bwindels Jan 8, 2019
0c36451
trying to make the left panel not grow taller than available space
bwindels Jan 8, 2019
8352d8c
not sure we need this, but adding the padding in _offset container
bwindels Jan 8, 2019
0803ea9
support collapsed items
bwindels Jan 8, 2019
b82e19b
size header explicitly for content size
bwindels Jan 9, 2019
51376c5
draft room sub list item api
bwindels Jan 9, 2019
68afadd
try flex-basis for resizing
bwindels Jan 10, 2019
1a2727f
sized items cannot grow, unsized items start with their content size …
bwindels Jan 10, 2019
a130c44
try clear next item size when resizing so there is always one unsized…
bwindels Jan 10, 2019
92b9a8c
persist cleared size sublists
bwindels Jan 10, 2019
9456fc0
fix typo
bwindels Jan 11, 2019
a413f35
normalize sizes when starting drag operation
bwindels Jan 11, 2019
136dd4a
stop resize operation when cursor leaves viewport
bwindels Jan 11, 2019
961e0d2
flex-basis to 0 so sublists shrink/grow not-relative to their content
bwindels Jan 14, 2019
9ecb23c
cleanup
bwindels Jan 14, 2019
7e395f0
cleanup - part II
bwindels Jan 14, 2019
1bbf150
Merge branch 'experimental' into bwindels/smarterresizer
bwindels Jan 15, 2019
aa90e95
fix min & max size for empty sublists
bwindels Jan 15, 2019
3c7bed9
size all items to rendered height when starting drag operation
bwindels Jan 15, 2019
a5424f3
Update src/resizer/item.js
turt2live Jan 16, 2019
2bd65e1
Update src/resizer/distributors/fixed.js
turt2live Jan 16, 2019
98aa657
Update src/resizer/distributors/collapse.js
turt2live Jan 16, 2019
fed256c
Update src/resizer/distributors/roomsublist.js
turt2live Jan 16, 2019
313bbaa
remove obsolete comments
bwindels Jan 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions res/css/structures/_RoomSubList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,25 @@ limitations under the License.

.mx_RoomSubList {
min-height: 31px;
flex: 0 100000000 auto;
flex: 0 10000 auto;
display: flex;
flex-direction: column;
}

.mx_RoomSubList.resized-sized {
/*
flex-basis to 0 so sublists
are not shrinking/growing relative
to their content (as would be the case with auto),
as this intervenes with sizing an item exactly
when not available space is available
in the flex container
*/
flex: 1 1 0;
}

.mx_RoomSubList_nonEmpty {
min-height: 70px;
min-height: 74px;

.mx_AutoHideScrollbar_offset {
padding-bottom: 4px;
Expand All @@ -50,17 +62,6 @@ limitations under the License.
flex: none !important;
}

.mx_RoomSubList.resized-all {
flex: 0 1 auto;
}

.mx_RoomSubList.resized-sized {
/* resizer set max-height on resized-sized,
so that limits the height and hence
needs a very small flex-shrink */
flex: 0 10000 auto;
}

.mx_RoomSubList_labelContainer {
display: flex;
flex-direction: row;
Expand Down
12 changes: 8 additions & 4 deletions src/components/views/rooms/RoomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import GroupStore from '../../../stores/GroupStore';
import RoomSubList from '../../structures/RoomSubList';
import ResizeHandle from '../elements/ResizeHandle';

import {Resizer, RoomDistributor, RoomSizer} from '../../../resizer'
import {Resizer, RoomSubListDistributor} from '../../../resizer'
const HIDE_CONFERENCE_CHANS = true;
const STANDARD_TAGS_REGEX = /^(m\.(favourite|lowpriority|server_notice)|im\.vector\.fake\.(invite|recent|direct|archived))$/;

Expand Down Expand Up @@ -153,7 +153,11 @@ module.exports = React.createClass({
if (typeof newSize === "string") {
newSize = Number.MAX_SAFE_INTEGER;
}
this.subListSizes[id] = newSize;
if (newSize === null) {
delete this.subListSizes[id];
} else {
this.subListSizes[id] = newSize;
}
window.localStorage.setItem("mx_roomlist_sizes", JSON.stringify(this.subListSizes));
// update overflow indicators
this._checkSubListsOverflow();
Expand All @@ -164,7 +168,7 @@ module.exports = React.createClass({
const cfg = {
onResized: this._onSubListResize,
};
this.resizer = new Resizer(this.resizeContainer, RoomDistributor, cfg, RoomSizer);
this.resizer = new Resizer(this.resizeContainer, RoomSubListDistributor, cfg);
this.resizer.setClassNames({
handle: "mx_ResizeHandle",
vertical: "mx_ResizeHandle_vertical",
Expand Down Expand Up @@ -724,4 +728,4 @@ module.exports = React.createClass({
</div>
);
},
});
});
82 changes: 0 additions & 82 deletions src/resizer/distributors.js

This file was deleted.

53 changes: 53 additions & 0 deletions src/resizer/distributors/collapse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2018 New Vector Ltd
bwindels marked this conversation as resolved.
Show resolved Hide resolved

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import FixedDistributor from "./fixed";
import ResizeItem from "../item";

class CollapseItem extends ResizeItem {
notifyCollapsed(collapsed) {
const callback = this.resizer.config.onCollapsed;
if (callback) {
callback(collapsed, this.id, this.domNode);
}
}
}

export default class CollapseDistributor extends FixedDistributor {
static createItem(resizeHandle, resizer, sizer) {
return new CollapseItem(resizeHandle, resizer, sizer);
}

constructor(item, config) {
super(item);
this.toggleSize = config && config.toggleSize;
this.isCollapsed = false;
}

resize(newSize) {
const isCollapsedSize = newSize < this.toggleSize;
if (isCollapsedSize && !this.isCollapsed) {
this.isCollapsed = true;
this.item.notifyCollapsed(true);
} else if (!isCollapsedSize && this.isCollapsed) {
this.item.notifyCollapsed(false);
this.isCollapsed = false;
}
if (!isCollapsedSize) {
super.resize(newSize);
}
}
}
57 changes: 57 additions & 0 deletions src/resizer/distributors/fixed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2018 New Vector Ltd
bwindels marked this conversation as resolved.
Show resolved Hide resolved

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import ResizeItem from "../item";
import Sizer from "../sizer";

/**
distributors translate a moving cursor into
CSS/DOM changes by calling the sizer

they have two methods:
`resize` receives then new item size
`resizeFromContainerOffset` receives resize handle location
within the container bounding box. For internal use.
This method usually ends up calling `resize` once the start offset is subtracted.
the offset from the container edge of where
the mouse cursor is.
bwindels marked this conversation as resolved.
Show resolved Hide resolved
*/
export default class FixedDistributor {
static createItem(resizeHandle, resizer, sizer) {
return new ResizeItem(resizeHandle, resizer, sizer);
}

static createSizer(containerElement, vertical, reverse) {
return new Sizer(containerElement, vertical, reverse);
}

constructor(item) {
this.item = item;
this.beforeOffset = item.offset();
}

resize(size) {
this.item.setSize(size);
}

resizeFromContainerOffset(offset) {
this.resize(offset - this.beforeOffset);
}

start() {}

finish() {}
}
Loading