mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
dont base collapse toggle size on min-width, as it's not available in collapsed state
This commit is contained in:
parent
01471abdc5
commit
c56975d93d
@ -98,7 +98,12 @@ const LoggedInView = React.createClass({
|
||||
vertical: "mx_ResizeHandle_vertical",
|
||||
reverse: "mx_ResizeHandle_reverse"
|
||||
};
|
||||
makeResizeable(this.resizeContainer, classNames, CollapseDistributor);
|
||||
const collapseToggleSize = 260 - 50;
|
||||
makeResizeable(
|
||||
this.resizeContainer,
|
||||
classNames,
|
||||
CollapseDistributor,
|
||||
collapseToggleSize);
|
||||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
|
@ -17,29 +17,20 @@ class FixedDistributor {
|
||||
|
||||
|
||||
class CollapseDistributor extends FixedDistributor {
|
||||
constructor(container, items, handleIndex, direction, sizer) {
|
||||
constructor(container, items, handleIndex, direction, sizer, toggleSize) {
|
||||
super(container, items, handleIndex, direction, sizer);
|
||||
const style = getComputedStyle(this.item);
|
||||
this.minWidth = parseInt(style.minWidth, 10); //auto becomes NaN
|
||||
this.toggleSize = toggleSize;
|
||||
}
|
||||
|
||||
resize(offset) {
|
||||
let newWidth = offset - this.sizer.getItemOffset(this.item);
|
||||
if (this.minWidth > 0) {
|
||||
// -50 this is to not collapse immediately
|
||||
// when moving the cursor past the minWidth
|
||||
// to give some visual feedback you are about
|
||||
// to collapse
|
||||
// TODO: should 50 be configurable? minWidth/2 maybe?
|
||||
if (offset < (this.minWidth - 50)) {
|
||||
let newSize = offset - this.sizer.getItemOffset(this.item);
|
||||
if (newSize < this.toggleSize) {
|
||||
this.item.classList.add("collapsed");
|
||||
newWidth = this.minWidth;
|
||||
}
|
||||
else {
|
||||
this.item.classList.remove("collapsed");
|
||||
}
|
||||
}
|
||||
super.resize(newWidth);
|
||||
super.resize(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ classNames:
|
||||
resizing: string
|
||||
*/
|
||||
|
||||
function makeResizeable(container, classNames, distributorCtor, sizerCtor = Sizer) {
|
||||
function makeResizeable(container, classNames, distributorCtor, distributorCfg = undefined, sizerCtor = Sizer) {
|
||||
|
||||
function isResizeHandle(el) {
|
||||
return el && el.classList.contains(classNames.handle);
|
||||
@ -44,7 +44,9 @@ function makeResizeable(container, classNames, distributorCtor, sizerCtor = Size
|
||||
});
|
||||
const prevItem = resizeHandle.previousElementSibling;
|
||||
const handleIndex = items.indexOf(prevItem) + 1;
|
||||
const distributor = new distributorCtor(container, items, handleIndex, direction, sizer);
|
||||
const distributor = new distributorCtor(
|
||||
container, items, handleIndex,
|
||||
direction, sizer, distributorCfg);
|
||||
|
||||
const onMouseMove = (event) => {
|
||||
const offset = sizer.offsetFromEvent(event);
|
||||
|
Loading…
Reference in New Issue
Block a user