Minor progress on edit mode

This commit is contained in:
Torkel Ödegaard
2018-11-10 07:34:09 -08:00
parent c54ae5d124
commit f74f7b017f
4 changed files with 15 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ import classNames from 'classnames';
import sizeMe from 'react-sizeme';
let lastGridWidth = 1200;
let ignoreNextWidthChange = false;
function GridWrapper({
size,
@@ -24,8 +25,12 @@ function GridWrapper({
isFullscreen,
}) {
const width = size.width > 0 ? size.width : lastGridWidth;
// logic to ignore width changes (optimization)
if (width !== lastGridWidth) {
if (!isFullscreen && Math.abs(width - lastGridWidth) > 8) {
if (ignoreNextWidthChange) {
ignoreNextWidthChange = false;
} else if (!isFullscreen && Math.abs(width - lastGridWidth) > 8) {
onWidthChange();
lastGridWidth = width;
}
@@ -138,6 +143,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
}
onViewModeChanged(payload) {
ignoreNextWidthChange = true;
this.setState({ animated: !payload.fullscreen });
}