Skip to content

Commit 6bc7fcc

Browse files
committed
Merge pull request #44 from ara4n/master
Fixes a nasty bug where all Panes could end up sharing the same static style
2 parents 3498db2 + 465a583 commit 6bc7fcc

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/index.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ class SortablePane extends Component {
363363
y: !this.isHorizontal() ? mouse : 0,
364364
}
365365
: {
366-
scale: spring(1, springConfig),
367-
shadow: spring(0, springConfig),
366+
scale: disableEffect ? 1 : spring(1, springConfig),
367+
shadow: disableEffect ? 0 : spring(0, springConfig),
368368
x: this.isHorizontal() ? springPosition : 0,
369369
y: !this.isHorizontal() ? springPosition : 0,
370370
};
@@ -376,6 +376,21 @@ class SortablePane extends Component {
376376
const onTouchStart = this.handleTouchStart.bind(this, i, x, y);
377377
const onResizeStart = this.handleResizeStart.bind(this, i);
378378
const onResizeStop = this.handleResizeStop.bind(this, i);
379+
380+
// take a copy rather than direct-manipulating the child's prop, which violates React
381+
// and causes problems if the child's prop is a static default {}, which then will be
382+
// shared across all children!
383+
const customStyle = Object.assign({}, child.props.style);
384+
Object.assign(customStyle, {
385+
boxShadow: `rgba(0, 0, 0, 0.2) 0px ${shadow}px ${2 * shadow}px 0px`,
386+
transform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
387+
WebkitTransform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
388+
MozTransform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
389+
MsTransform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
390+
zIndex: i === lastPressed ? 99 : i, // TODO: Add this.props.zIndex
391+
position: 'absolute',
392+
});
393+
379394
return (
380395
<Resizable
381396
customClass={child.props.className}
@@ -396,15 +411,7 @@ class SortablePane extends Component {
396411
minHeight={child.props.minHeight}
397412
maxWidth={child.props.maxWidth}
398413
maxHeight={child.props.maxHeight}
399-
customStyle={Object.assign(child.props.style, {
400-
boxShadow: `rgba(0, 0, 0, 0.2) 0px ${shadow}px ${2 * shadow}px 0px`,
401-
transform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
402-
WebkitTransform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
403-
MozTransform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
404-
MsTransform: `translate3d(${x}px, ${y}px, 0px) scale(${scale})`,
405-
zIndex: i === lastPressed ? 99 : i, // TODO: Add this.props.zIndex
406-
position: 'absolute',
407-
})}
414+
customStyle={customStyle}
408415
onMouseDown={onMouseDown}
409416
onTouchStart={onTouchStart}
410417
onResizeStart={onResizeStart}

0 commit comments

Comments
 (0)