|
|
|
@ -7938,8 +7938,7 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
|
this.imageCache.get(croppingElement.fileId)?.image;
|
|
|
|
|
|
|
|
|
|
if (image && !(image instanceof Promise)) {
|
|
|
|
|
// scale the offset by at least a factor of 2 to improve ux
|
|
|
|
|
let instantDragOffset = vectorScale(
|
|
|
|
|
const instantDragOffset = vectorScale(
|
|
|
|
|
vector(
|
|
|
|
|
pointerCoords.x - lastPointerCoords.x,
|
|
|
|
|
pointerCoords.y - lastPointerCoords.y,
|
|
|
|
@ -7947,7 +7946,6 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
|
Math.max(this.state.zoom.value, 2),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (croppingElement.angle !== 0) {
|
|
|
|
|
const [x1, y1, x2, y2, cx, cy] = getElementAbsoluteCoords(
|
|
|
|
|
croppingElement,
|
|
|
|
|
elementsMap,
|
|
|
|
@ -7981,29 +7979,23 @@ class App extends React.Component<AppProps, AppState> {
|
|
|
|
|
vectorSubtract(bottomLeft, topLeft),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* project instantDrafOffset onto leftEdge and topEdge to decompose
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
instantDragOffset = vector(
|
|
|
|
|
// project instantDrafOffset onto leftEdge and topEdge to decompose
|
|
|
|
|
const offsetVector = vector(
|
|
|
|
|
vectorDot(instantDragOffset, topEdge),
|
|
|
|
|
vectorDot(instantDragOffset, leftEdge),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const nextCrop = {
|
|
|
|
|
...crop,
|
|
|
|
|
x: clamp(
|
|
|
|
|
crop.x -
|
|
|
|
|
instantDragOffset[0] *
|
|
|
|
|
Math.sign(croppingElement.scale[0]),
|
|
|
|
|
offsetVector[0] * Math.sign(croppingElement.scale[0]),
|
|
|
|
|
0,
|
|
|
|
|
image.naturalWidth - crop.width,
|
|
|
|
|
),
|
|
|
|
|
y: clamp(
|
|
|
|
|
crop.y -
|
|
|
|
|
instantDragOffset[1] *
|
|
|
|
|
Math.sign(croppingElement.scale[1]),
|
|
|
|
|
offsetVector[1] * Math.sign(croppingElement.scale[1]),
|
|
|
|
|
0,
|
|
|
|
|
image.naturalHeight - crop.height,
|
|
|
|
|
),
|
|
|
|
|