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",
|
vertical: "mx_ResizeHandle_vertical",
|
||||||
reverse: "mx_ResizeHandle_reverse"
|
reverse: "mx_ResizeHandle_reverse"
|
||||||
};
|
};
|
||||||
makeResizeable(this.resizeContainer, classNames, CollapseDistributor);
|
const collapseToggleSize = 260 - 50;
|
||||||
|
makeResizeable(
|
||||||
|
this.resizeContainer,
|
||||||
|
classNames,
|
||||||
|
CollapseDistributor,
|
||||||
|
collapseToggleSize);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
@ -17,29 +17,20 @@ class FixedDistributor {
|
|||||||
|
|
||||||
|
|
||||||
class CollapseDistributor extends FixedDistributor {
|
class CollapseDistributor extends FixedDistributor {
|
||||||
constructor(container, items, handleIndex, direction, sizer) {
|
constructor(container, items, handleIndex, direction, sizer, toggleSize) {
|
||||||
super(container, items, handleIndex, direction, sizer);
|
super(container, items, handleIndex, direction, sizer);
|
||||||
const style = getComputedStyle(this.item);
|
this.toggleSize = toggleSize;
|
||||||
this.minWidth = parseInt(style.minWidth, 10); //auto becomes NaN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resize(offset) {
|
resize(offset) {
|
||||||
let newWidth = offset - this.sizer.getItemOffset(this.item);
|
let newSize = offset - this.sizer.getItemOffset(this.item);
|
||||||
if (this.minWidth > 0) {
|
if (newSize < this.toggleSize) {
|
||||||
// -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)) {
|
|
||||||
this.item.classList.add("collapsed");
|
this.item.classList.add("collapsed");
|
||||||
newWidth = this.minWidth;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.item.classList.remove("collapsed");
|
this.item.classList.remove("collapsed");
|
||||||
}
|
}
|
||||||
}
|
super.resize(newSize);
|
||||||
super.resize(newWidth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ classNames:
|
|||||||
resizing: string
|
resizing: string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function makeResizeable(container, classNames, distributorCtor, sizerCtor = Sizer) {
|
function makeResizeable(container, classNames, distributorCtor, distributorCfg = undefined, sizerCtor = Sizer) {
|
||||||
|
|
||||||
function isResizeHandle(el) {
|
function isResizeHandle(el) {
|
||||||
return el && el.classList.contains(classNames.handle);
|
return el && el.classList.contains(classNames.handle);
|
||||||
@ -44,7 +44,9 @@ function makeResizeable(container, classNames, distributorCtor, sizerCtor = Size
|
|||||||
});
|
});
|
||||||
const prevItem = resizeHandle.previousElementSibling;
|
const prevItem = resizeHandle.previousElementSibling;
|
||||||
const handleIndex = items.indexOf(prevItem) + 1;
|
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 onMouseMove = (event) => {
|
||||||
const offset = sizer.offsetFromEvent(event);
|
const offset = sizer.offsetFromEvent(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user