Skip to content

Commit 777be68

Browse files
committed
Added top right drag handle
1 parent b6c956e commit 777be68

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

src/components/Positioned.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ interface IPositionedProps extends IReactSpaceCommonProps {
1919
export const Positioned: React.FC<IPositionedProps> = ({ left, top, right, bottom, width, height, resizable, ...props }) => {
2020
const resizeTypes = resizable || [];
2121

22+
console.log(resizeTypes);
23+
2224
return (
2325
<Space
2426
{...props}

src/components/stories/02-components/Positioned.Resizable.TopRightBottomLeft.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Absolutely positioned space within it's parent with top / left / right / bottom
2929
<Story name="Resize handles (all sides)">
3030
{() => {
3131
return <ViewPort>
32-
<Positioned style={green} left={200} top={200} right={200} bottom={200} trackSize={true} resizable={[ ResizeType.Left, ResizeType.Top, ResizeType.Bottom, ResizeType.Right ]} onResizeStart={action('onResizeStart')} onResizeEnd={action('onResizeEnd')}>
32+
<Positioned style={green} left={200} top={200} right={200} bottom={200} trackSize={true} resizable={[ ResizeType.Left, ResizeType.Top, ResizeType.Bottom, ResizeType.Right, ResizeType.TopLeft, ResizeType.TopRight, ResizeType.BottomLeft, ResizeType.BottomRight ]} onResizeStart={action('onResizeStart')} onResizeEnd={action('onResizeEnd')}>
3333
{description("Positioned")}
3434
</Positioned>
3535
</ViewPort>

src/core-react.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,16 @@ export function useSpaceResizeHandles(store: ISpaceStore, space: ISpaceDefinitio
251251
});
252252
}
253253

254+
if (space.canResizeTopRight) {
255+
mouseHandles.push({
256+
id: `${space.id}-mtr`,
257+
key: "top-right",
258+
className: `spaces-resize-handle resize-top-right`,
259+
onMouseDown: (event) => store.startMouseResize(ResizeType.Right, space, event),
260+
onTouchStart: (event) => store.startTouchResize(ResizeType.Right, space, event),
261+
});
262+
}
263+
254264
return {
255265
mouseHandles,
256266
};

src/core-utils.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ export function styleDefinition(space: ISpaceDefinition) {
182182
}
183183

184184
if (space.canResizeRight) {
185-
cssElements.push(`#${space.id}-mr:after { left: -${touchHandleSize}px; right: -${touchHandleSize}px; top: 0; bottom: 0; }`);
186185
if (space.width.size) {
187186
cssElements.push(
188187
`#${space.id}-mr { left: calc(${css(space.left, true)} + ${css(space.width, true)} - ${
@@ -227,6 +226,22 @@ export function styleDefinition(space: ISpaceDefinition) {
227226
}px; height: ${space.handleSize}px; }`,
228227
);
229228
}
229+
230+
if (space.canResizeTopRight) {
231+
if (space.width.size) {
232+
cssElements.push(
233+
`#${space.id}-mtr { left: calc(${css(space.left, true)} + ${css(space.width, true)} - ${
234+
space.handleSize
235+
}px + ${handleOffset}px); width: ${space.handleSize}px; top: ${css(space.top)}; height: ${space.handleSize}px; }`,
236+
);
237+
} else {
238+
cssElements.push(
239+
`#${space.id}-mtr { right: calc(${css(space.right, true)} - ${handleOffset}px); width: ${space.handleSize}px; top: ${css(
240+
space.top,
241+
)}; height: ${space.handleSize}px; }`,
242+
);
243+
}
244+
}
230245
} else {
231246
if (space.canResizeLeft) {
232247
cssElements.push(

src/styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@
8888
bottom: 0;
8989
}
9090

91+
.spaces-resize-handle.resize-top-right {
92+
top: 0;
93+
bottom: 0;
94+
}
95+
96+
.spaces-resize-handle.resize-top-right:before {
97+
cursor: ne-resize;
98+
}
99+
100+
.spaces-touch-handle.resize-top-right {
101+
top: 0;
102+
bottom: 0;
103+
}
104+
91105
.spaces-resize-handle.resize-top {
92106
left: 0;
93107
right: 0;

0 commit comments

Comments
 (0)