Skip to content

Commit b6c956e

Browse files
committed
Initial element/css wire up for corner drag handle
1 parent 00906ce commit b6c956e

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

src/components/Positioned.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ export const Positioned: React.FC<IPositionedProps> = ({ left, top, right, botto
2525
type={Type.Positioned}
2626
position={{
2727
left: left,
28-
leftResizable: resizeTypes.includes(ResizeType.Left),
2928
top: top,
30-
topResizable: resizeTypes.includes(ResizeType.Top),
3129
right: right,
32-
rightResizable: resizeTypes.includes(ResizeType.Right),
3330
bottom: bottom,
31+
leftResizable: resizeTypes.includes(ResizeType.Left),
32+
topResizable: resizeTypes.includes(ResizeType.Top),
33+
rightResizable: resizeTypes.includes(ResizeType.Right),
3434
bottomResizable: resizeTypes.includes(ResizeType.Bottom),
35+
topLeftResizable: resizeTypes.includes(ResizeType.TopLeft),
36+
topRightResizable: resizeTypes.includes(ResizeType.TopRight),
37+
bottomLeftResizable: resizeTypes.includes(ResizeType.BottomLeft),
38+
bottomRightResizable: resizeTypes.includes(ResizeType.BottomRight),
3539
width: width,
3640
height: height,
3741
}}>

src/core-react.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ export function useSpaceResizeHandles(store: ISpaceStore, space: ISpaceDefinitio
241241
});
242242
}
243243

244+
if (space.canResizeTopLeft) {
245+
mouseHandles.push({
246+
id: `${space.id}-mtl`,
247+
key: "top-left",
248+
className: `spaces-resize-handle resize-top-left`,
249+
onMouseDown: (event) => store.startMouseResize(ResizeType.Left, space, event),
250+
onTouchStart: (event) => store.startTouchResize(ResizeType.Left, space, event),
251+
});
252+
}
253+
244254
return {
245255
mouseHandles,
246256
};

src/core-utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ export function styleDefinition(space: ISpaceDefinition) {
219219
}
220220
cssElements.push(`#${space.id}-mb:after { top: -${touchHandleSize}px; bottom: -${touchHandleSize}px; left: 0; right: 0; }`);
221221
}
222+
223+
if (space.canResizeTopLeft) {
224+
cssElements.push(
225+
`#${space.id}-mtl { left: calc(${css(space.left, true)} - ${handleOffset}px); top: ${css(space.top)}; width: ${
226+
space.handleSize
227+
}px; height: ${space.handleSize}px; }`,
228+
);
229+
}
222230
} else {
223231
if (space.canResizeLeft) {
224232
cssElements.push(

src/core.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ export function createStore(): ISpaceStore {
425425
const canResizeRight = (position && position.leftResizable) || false;
426426
const canResizeTop = (position && position.bottomResizable) || false;
427427
const canResizeBottom = (position && position.topResizable) || false;
428+
const canResizeTopLeft = (position && position.topLeftResizable) || false;
429+
const canResizeTopRight = (position && position.topRightResizable) || false;
430+
const canResizeBottomLeft = (position && position.bottomLeftResizable) || false;
431+
const canResizeBottomRight = (position && position.bottomRightResizable) || false;
428432

429433
const newSpace: ISpaceDefinition = {
430434
...spaceDefaults,
@@ -456,11 +460,15 @@ export function createStore(): ISpaceStore {
456460
canResizeRight: canResizeRight,
457461
canResizeTop: canResizeTop,
458462
canResizeBottom: canResizeBottom,
463+
canResizeTopLeft: canResizeTopLeft,
464+
canResizeTopRight: canResizeTopRight,
465+
canResizeBottomLeft: canResizeBottomLeft,
466+
canResizeBottomRight: canResizeBottomRight,
459467
},
460468
} as ISpaceDefinition;
461469

462-
newSpace.anchoredChildren = (children, anchor, zIndex) => {
463-
return children.filter((s) => s.type === Type.Anchored && s.anchor === anchor && s.zIndex === zIndex);
470+
newSpace.anchoredChildren = (children, chanchor, zIndex) => {
471+
return children.filter((s) => s.type === Type.Anchored && s.anchor === chanchor && s.zIndex === zIndex);
464472
};
465473

466474
newSpace.adjustLeft = (adjusted) => {

src/styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@
6060
bottom: 0;
6161
}
6262

63+
.spaces-resize-handle.resize-top-left {
64+
top: 0;
65+
bottom: 0;
66+
}
67+
68+
.spaces-resize-handle.resize-top-left:before {
69+
cursor: nw-resize;
70+
}
71+
72+
.spaces-touch-handle.resize-top-left {
73+
top: 0;
74+
bottom: 0;
75+
}
76+
6377
.spaces-resize-handle.resize-right {
6478
top: 0;
6579
bottom: 0;

0 commit comments

Comments
 (0)