mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
provide an optional direction when shape switching
This commit is contained in:
parent
66812e5ab3
commit
3272841b23
2 changed files with 9 additions and 2 deletions
|
@ -4112,6 +4112,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
switchShapes(this, {
|
||||
generic,
|
||||
linear,
|
||||
direction: event.shiftKey ? "left" : "right",
|
||||
})
|
||||
) {
|
||||
this.store.shouldCaptureIncrement();
|
||||
|
|
|
@ -408,10 +408,12 @@ export const switchShapes = (
|
|||
generic,
|
||||
linear,
|
||||
nextType,
|
||||
direction = "right",
|
||||
}: {
|
||||
generic?: boolean;
|
||||
linear?: boolean;
|
||||
nextType?: GenericSwitchableToolType | LinearSwitchableToolType;
|
||||
direction?: "left" | "right";
|
||||
} = {},
|
||||
): boolean => {
|
||||
if (!generic && !linear) {
|
||||
|
@ -428,6 +430,8 @@ export const switchShapes = (
|
|||
{},
|
||||
);
|
||||
|
||||
const advancement = direction === "right" ? 1 : -1;
|
||||
|
||||
if (generic) {
|
||||
const selectedGenericSwitchableElements =
|
||||
getGenericSwitchableElements(selectedElements);
|
||||
|
@ -445,7 +449,8 @@ export const switchShapes = (
|
|||
nextType =
|
||||
nextType ??
|
||||
(GENERIC_SWITCHABLE_SHAPES[
|
||||
(index + 1) % GENERIC_SWITCHABLE_SHAPES.length
|
||||
(index + GENERIC_SWITCHABLE_SHAPES.length + advancement) %
|
||||
GENERIC_SWITCHABLE_SHAPES.length
|
||||
] as GenericSwitchableToolType);
|
||||
|
||||
selectedGenericSwitchableElements.forEach((element) => {
|
||||
|
@ -516,7 +521,8 @@ export const switchShapes = (
|
|||
nextType =
|
||||
nextType ??
|
||||
(LINEAR_SWITCHABLE_SHAPES[
|
||||
(index + 1) % LINEAR_SWITCHABLE_SHAPES.length
|
||||
(index + LINEAR_SWITCHABLE_SHAPES.length + advancement) %
|
||||
LINEAR_SWITCHABLE_SHAPES.length
|
||||
] as LinearSwitchableToolType);
|
||||
|
||||
selectedElements.forEach((element) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue