Skip to content

Commit 0243d95

Browse files
authored
Merge pull request #14 from aeagle/patch/_6-resize-handle-fix-in-scrollable
Patch/ 6 resize handle fix in scrollable
2 parents 9d6e69e + 7cd5b8f commit 0243d95

File tree

4 files changed

+45
-29
lines changed

4 files changed

+45
-29
lines changed

demo/src/docs/VersionHistory.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ export const VersionHistory = () => {
55
<>
66
<h2 id="changes">Version history</h2>
77

8+
<div>
9+
<h3>0.1.7</h3>
10+
<ul>
11+
<li>Fixed positioning of resize handles within scrollable divs</li>
12+
</ul>
13+
</div>
814
<div>
915
<h3>0.1.6</h3>
1016
<ul>

react-spaces/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-spaces",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"main": "dist/index.js",
55
"author": {
66
"name": "Allan Eagle"

react-spaces/src/components/Space.scss

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
overflow: hidden;
44
z-index: 1;
55

6-
&:after {
7-
content: "";
8-
display: table;
9-
clear: both;
6+
.spaces-space-inner {
7+
z-index: 2;
8+
position: absolute;
9+
left: 0;
10+
top: 0;
11+
right: 0;
12+
bottom: 0;
13+
14+
&:after {
15+
content: "";
16+
display: table;
17+
clear: both;
18+
}
1019
}
1120

1221
&.scrollable {
13-
overflow: auto;
22+
.spaces-space-inner {
23+
overflow: auto;
24+
}
1425
}
1526
}

react-spaces/src/components/Space.tsx

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class Space extends React.Component<AllProps, IState> {
226226
const currentContext = this.getContext(parentContext);
227227

228228
let spaceRender = this.props.children;
229+
let resizeRender = null;
229230

230231
if (parentContext && this.props.anchor && this.props.resizable) {
231232
let resizeType : ResizeType = ResizeType.Left;
@@ -245,36 +246,34 @@ class Space extends React.Component<AllProps, IState> {
245246
break;
246247
}
247248

248-
spaceRender =
249-
<>
250-
<Resizable
251-
type={resizeType}
252-
minimumAdjust={ -(this.state.parsedSize || 0) + (this.props.minimumSize || 20) }
253-
maximumAdjust={ this.props.maximumSize ? (this.props.maximumSize - (this.state.parsedSize || 0)) : undefined}
254-
onResize={(adjustedSize) => {
255-
this.setState(
256-
{ adjustedSize: adjustedSize },
257-
() => {
258-
parentContext.updateSpaceTakerAdjustedSize(this.state.id, adjustedSize);
259-
});
260-
}} />
261-
{spaceRender}
262-
</>;
249+
resizeRender =
250+
<Resizable
251+
type={resizeType}
252+
minimumAdjust={ -(this.state.parsedSize || 0) + (this.props.minimumSize || 20) }
253+
maximumAdjust={ this.props.maximumSize ? (this.props.maximumSize - (this.state.parsedSize || 0)) : undefined}
254+
onResize={(adjustedSize) => {
255+
this.setState(
256+
{ adjustedSize: adjustedSize },
257+
() => {
258+
parentContext.updateSpaceTakerAdjustedSize(this.state.id, adjustedSize);
259+
});
260+
}} />;
263261
}
264262

265263
return (
266264
<div
267265
id={id}
268266
ref={this.divElementRef}
269267
className={`spaces-space${this.props.anchor || ''}${this.props.scrollable ? ' scrollable' : ''}${className ? ` ${className}` : ``}`}
270-
style={{ ...style, ...this.props.style }}>
271-
272-
<SpaceContext.Provider value={currentContext}>
273-
<SpaceInfoContext.Provider value={{ width: Math.floor(this.state.currentWidth), height: Math.floor(this.state.currentHeight) }}>
274-
{ spaceRender }
275-
</SpaceInfoContext.Provider>
276-
</SpaceContext.Provider>
277-
268+
style={style}>
269+
{ resizeRender }
270+
<div className="spaces-space-inner" style={this.props.style}>
271+
<SpaceContext.Provider value={currentContext}>
272+
<SpaceInfoContext.Provider value={{ width: Math.floor(this.state.currentWidth), height: Math.floor(this.state.currentHeight) }}>
273+
{ spaceRender }
274+
</SpaceInfoContext.Provider>
275+
</SpaceContext.Provider>
276+
</div>
278277
</div>
279278
)
280279
}

0 commit comments

Comments
 (0)