1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export const Position = {
|
18 | BOTTOM: "bottom" as "bottom",
|
19 | BOTTOM_LEFT: "bottom-left" as "bottom-left",
|
20 | BOTTOM_RIGHT: "bottom-right" as "bottom-right",
|
21 | LEFT: "left" as "left",
|
22 | LEFT_BOTTOM: "left-bottom" as "left-bottom",
|
23 | LEFT_TOP: "left-top" as "left-top",
|
24 | RIGHT: "right" as "right",
|
25 | RIGHT_BOTTOM: "right-bottom" as "right-bottom",
|
26 | RIGHT_TOP: "right-top" as "right-top",
|
27 | TOP: "top" as "top",
|
28 | TOP_LEFT: "top-left" as "top-left",
|
29 | TOP_RIGHT: "top-right" as "top-right",
|
30 | };
|
31 |
|
32 | export type Position = typeof Position[keyof typeof Position];
|
33 |
|
34 | export function isPositionHorizontal(position: Position) {
|
35 |
|
36 | return (
|
37 | position === Position.TOP ||
|
38 | position === Position.TOP_LEFT ||
|
39 | position === Position.TOP_RIGHT ||
|
40 | position === Position.BOTTOM ||
|
41 | position === Position.BOTTOM_LEFT ||
|
42 | position === Position.BOTTOM_RIGHT
|
43 | );
|
44 | }
|
45 |
|
46 | export function isPositionVertical(position: Position) {
|
47 |
|
48 | return (
|
49 | position === Position.LEFT ||
|
50 | position === Position.LEFT_TOP ||
|
51 | position === Position.LEFT_BOTTOM ||
|
52 | position === Position.RIGHT ||
|
53 | position === Position.RIGHT_TOP ||
|
54 | position === Position.RIGHT_BOTTOM
|
55 | );
|
56 | }
|
57 |
|
58 | export function getPositionIgnoreAngles(position: Position) {
|
59 | if (position === Position.TOP || position === Position.TOP_LEFT || position === Position.TOP_RIGHT) {
|
60 | return Position.TOP;
|
61 | } else if (
|
62 | position === Position.BOTTOM ||
|
63 | position === Position.BOTTOM_LEFT ||
|
64 | position === Position.BOTTOM_RIGHT
|
65 | ) {
|
66 | return Position.BOTTOM;
|
67 | } else if (position === Position.LEFT || position === Position.LEFT_TOP || position === Position.LEFT_BOTTOM) {
|
68 | return Position.LEFT;
|
69 | } else {
|
70 | return Position.RIGHT;
|
71 | }
|
72 | }
|