( e: UIEvent, positionAtCursor = false, )
| 1114 | ); |
| 1115 | |
| 1116 | async function showCropOptionsMenu( |
| 1117 | e: UIEvent, |
| 1118 | positionAtCursor = false, |
| 1119 | ) { |
| 1120 | e.preventDefault(); |
| 1121 | e.stopPropagation(); |
| 1122 | const items = createCropOptionsMenuItems({ |
| 1123 | aspect: aspect(), |
| 1124 | snapToRatioEnabled: snapToRatio(), |
| 1125 | onAspectSet: setAspect, |
| 1126 | onSnapToRatioSet: setSnapToRatioEnabled, |
| 1127 | }); |
| 1128 | const menu = await Menu.new({ items }); |
| 1129 | let pos: LogicalPosition | undefined; |
| 1130 | if (!positionAtCursor) { |
| 1131 | const rect = ( |
| 1132 | e.currentTarget as HTMLDivElement |
| 1133 | ).getBoundingClientRect(); |
| 1134 | pos = new LogicalPosition(rect.x, rect.y + 40); |
| 1135 | } |
| 1136 | await menu.popup(pos); |
| 1137 | } |
| 1138 | |
| 1139 | function BoundInput(props: { |
| 1140 | field: keyof CropBounds; |
no test coverage detected