mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Implement new resizing algorithm
* resizes against the original parameters
This commit is contained in:
parent
d3e46e9da4
commit
69f1c353df
1 changed files with 9 additions and 18 deletions
|
@ -19,7 +19,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
$: aspectRatio = naturalWidth && naturalHeight ? naturalWidth / naturalHeight : NaN;
|
$: aspectRatio = naturalWidth && naturalHeight ? naturalWidth / naturalHeight : NaN;
|
||||||
|
|
||||||
$: showDimensions = activeImage ? Number(activeImage!.height) >= 50 : false;
|
$: showDimensions = activeImage ? Number(activeImage!.height) >= 50 : false;
|
||||||
|
|
||||||
$: showFloat = activeImage ? Number(activeImage!.width) >= 100 : false;
|
$: showFloat = activeImage ? Number(activeImage!.width) >= 100 : false;
|
||||||
|
|
||||||
let actualWidth = "";
|
let actualWidth = "";
|
||||||
|
@ -117,27 +116,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const containerRect = container.getBoundingClientRect();
|
|
||||||
const imageRect = activeImage!.getBoundingClientRect();
|
const imageRect = activeImage!.getBoundingClientRect();
|
||||||
|
|
||||||
const originalContainerY = containerRect.top;
|
const imageLeft = imageRect!.left;
|
||||||
const originalContainerX = containerRect.left;
|
const imageRight = imageRect!.right;
|
||||||
const originalY = imageRect!.top - containerTop;
|
const [multX, imageX] = west ? [-1, imageRight] : [1, -imageLeft];
|
||||||
const originalX = imageRect!.left - containerLeft;
|
|
||||||
|
|
||||||
getDragWidth = (event) =>
|
getDragWidth = ({ clientX }) => multX * clientX + imageX;
|
||||||
west
|
|
||||||
? activeImage!.clientWidth -
|
|
||||||
event.clientX +
|
|
||||||
(originalContainerX + originalX)
|
|
||||||
: event.clientX - originalContainerX - originalX;
|
|
||||||
|
|
||||||
getDragHeight = (event) =>
|
const imageTop = imageRect!.top;
|
||||||
north
|
const imageBottom = imageRect!.bottom;
|
||||||
? activeImage!.clientHeight -
|
const [multY, imageY] = north ? [-1, imageBottom] : [1, -imageTop];
|
||||||
event.clientY +
|
|
||||||
(originalContainerY + originalY)
|
getDragHeight = ({ clientY }) => multY * clientY + imageY;
|
||||||
: event.clientY - originalContainerY - originalY;
|
|
||||||
|
|
||||||
stopObserving();
|
stopObserving();
|
||||||
(event.target as Element).setPointerCapture(event.pointerId);
|
(event.target as Element).setPointerCapture(event.pointerId);
|
||||||
|
|
Loading…
Reference in a new issue