Skip to content

Commit

Permalink
Minimize initial shunting on mount. Part of a fix for react-grid-layo…
Browse files Browse the repository at this point in the history
  • Loading branch information
STRML committed Apr 14, 2016
1 parent 09314aa commit cccee20
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/ReactGridLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import GridItem from './GridItem';
import type {ResizeEvent, DragEvent, Layout, LayoutItem} from './utils';
type State = {
activeDrag: ?LayoutItem,
isMounted: boolean,
layout: Layout,
oldDragItem: ?LayoutItem,
oldResizeItem: ?LayoutItem
Expand Down Expand Up @@ -145,7 +144,6 @@ export default class ReactGridLayout extends React.Component {

state: State = {
activeDrag: null,
isMounted: false,
layout: synchronizeLayoutWithChildren(this.props.layout, this.props.children,
this.props.cols, this.props.verticalCompact),
oldDragItem: null,
Expand All @@ -161,7 +159,6 @@ export default class ReactGridLayout extends React.Component {
// Call back with layout on mount. This should be done after correcting the layout width
// to ensure we don't rerender with the wrong width.
this.props.onLayoutChange(this.state.layout);
this.setState({isMounted: true});
}

componentWillReceiveProps(nextProps: Object) {
Expand Down Expand Up @@ -365,6 +362,8 @@ export default class ReactGridLayout extends React.Component {
// Parse 'static'. Any properties defined directly on the grid item will take precedence.
const draggable = Boolean(!l.static && isDraggable && (l.isDraggable || l.isDraggable == null));
const resizable = Boolean(!l.static && isResizable && (l.isResizable || l.isResizable == null));
// $FlowIgnore
const isBrowser = process.browser;

return (
<GridItem
Expand All @@ -383,8 +382,8 @@ export default class ReactGridLayout extends React.Component {
onResizeStop={this.onResizeStop}
isDraggable={draggable}
isResizable={resizable}
useCSSTransforms={useCSSTransforms && this.state.isMounted}
usePercentages={!this.state.isMounted}
useCSSTransforms={useCSSTransforms && isBrowser}
usePercentages={!isBrowser}

w={l.w}
h={l.h}
Expand Down

0 comments on commit cccee20

Please sign in to comment.