()
| 481 | } |
| 482 | |
| 483 | function computeInitialBounds(): CropBounds { |
| 484 | const target = targetSize(); |
| 485 | const initialCrop = |
| 486 | typeof props.initialCrop === "function" |
| 487 | ? props.initialCrop() |
| 488 | : props.initialCrop; |
| 489 | |
| 490 | const startBoundsReal = initialCrop ?? { |
| 491 | x: 0, |
| 492 | y: 0, |
| 493 | width: Math.round(target.x / 2), |
| 494 | height: Math.round(target.y / 2), |
| 495 | }; |
| 496 | |
| 497 | let bounds = boundsToRaw(startBoundsReal); |
| 498 | const ratioValue = aspectState.value; |
| 499 | if (ratioValue) |
| 500 | bounds = constrainBoundsToRatio(bounds, ratioValue, ORIGIN_CENTER); |
| 501 | const container = containerSize(); |
| 502 | |
| 503 | if (bounds.width > container.x) |
| 504 | bounds = scaleBounds(bounds, container.x / bounds.width, ORIGIN_CENTER); |
| 505 | if (bounds.height > container.y) |
| 506 | bounds = scaleBounds(bounds, container.y / bounds.height, ORIGIN_CENTER); |
| 507 | |
| 508 | bounds = slideBoundsIntoContainer(bounds, container.x, container.y); |
| 509 | |
| 510 | if (!initialCrop) |
| 511 | bounds = moveBounds( |
| 512 | bounds, |
| 513 | container.x / 2 - bounds.width / 2, |
| 514 | container.y / 2 - bounds.height / 2, |
| 515 | ); |
| 516 | return bounds; |
| 517 | } |
| 518 | |
| 519 | function rawSizeConstraint() { |
| 520 | const scale = logicalScale(); |
no test coverage detected