-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
63 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/react-resizable-panels/src/utils/events/getResizeEventCoordinates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ResizeEvent } from "../../types"; | ||
import { isMouseEvent, isTouchEvent } from "."; | ||
|
||
export function getResizeEventCoordinates(event: ResizeEvent) { | ||
if (isMouseEvent(event)) { | ||
return { | ||
x: event.pageX, | ||
y: event.pageY, | ||
}; | ||
} else if (isTouchEvent(event)) { | ||
const touch = event.touches[0]; | ||
if (touch && touch.pageX && touch.pageY) { | ||
return { | ||
x: touch.pageX, | ||
y: touch.pageY, | ||
}; | ||
} | ||
} | ||
|
||
return { | ||
x: Infinity, | ||
y: Infinity, | ||
}; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/react-resizable-panels/src/utils/events/getResizeEventCursorPosition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ResizeEvent } from "../../PanelGroupContext"; | ||
import { Direction } from "../../types"; | ||
import { getResizeEventCoordinates } from "./getResizeEventCoordinates"; | ||
|
||
export function getResizeEventCursorPosition( | ||
direction: Direction, | ||
event: ResizeEvent | ||
): number { | ||
const isHorizontal = direction === "horizontal"; | ||
|
||
const { x, y } = getResizeEventCoordinates(event); | ||
|
||
return isHorizontal ? x : y; | ||
} |
2 changes: 1 addition & 1 deletion
2
...eact-resizable-panels/src/utils/events.ts → ...esizable-panels/src/utils/events/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
packages/react-resizable-panels/src/utils/getResizeEventCursorPosition.ts
This file was deleted.
Oops, something went wrong.