Relax flexboxes in resizer on window resize
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
ba21c6ed36
commit
447ea9eb23
|
@ -124,10 +124,6 @@ $MiniAppTileHeight: 200px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
& + .mx_AppTile {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_AppTileFullWidth {
|
.mx_AppTileFullWidth {
|
||||||
|
|
|
@ -27,6 +27,8 @@ classNames:
|
||||||
resizing: string
|
resizing: string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import {throttle} from "lodash";
|
||||||
|
|
||||||
import FixedDistributor from "./distributors/fixed";
|
import FixedDistributor from "./distributors/fixed";
|
||||||
import Sizer from "./sizer";
|
import Sizer from "./sizer";
|
||||||
import ResizeItem from "./item";
|
import ResizeItem from "./item";
|
||||||
|
@ -76,10 +78,12 @@ export default class Resizer<C extends IConfig = IConfig> {
|
||||||
|
|
||||||
public attach() {
|
public attach() {
|
||||||
this.container.addEventListener("mousedown", this.onMouseDown, false);
|
this.container.addEventListener("mousedown", this.onMouseDown, false);
|
||||||
|
window.addEventListener("resize", this.onResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public detach() {
|
public detach() {
|
||||||
this.container.removeEventListener("mousedown", this.onMouseDown, false);
|
this.container.removeEventListener("mousedown", this.onMouseDown, false);
|
||||||
|
window.removeEventListener("resize", this.onResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,6 +162,17 @@ export default class Resizer<C extends IConfig = IConfig> {
|
||||||
body.addEventListener("mousemove", onMouseMove, false);
|
body.addEventListener("mousemove", onMouseMove, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onResize = throttle(() => {
|
||||||
|
const distributors = this.getResizeHandles().map(handle => {
|
||||||
|
const {distributor} = this.createSizerAndDistributor(<HTMLDivElement>handle);
|
||||||
|
return distributor;
|
||||||
|
});
|
||||||
|
|
||||||
|
// relax all items if they had any overconstrained flexboxes
|
||||||
|
distributors.forEach(d => d.start());
|
||||||
|
distributors.forEach(d => d.finish());
|
||||||
|
}, 100, {trailing: true, leading: true});
|
||||||
|
|
||||||
private createSizerAndDistributor(
|
private createSizerAndDistributor(
|
||||||
resizeHandle: HTMLDivElement,
|
resizeHandle: HTMLDivElement,
|
||||||
): {sizer: Sizer, distributor: FixedDistributor<any>} {
|
): {sizer: Sizer, distributor: FixedDistributor<any>} {
|
||||||
|
|
Loading…
Reference in New Issue