Fix touch position offset in image masking on iOS devices (#16702)
* Initial plan * Fix iOS touch position offset in image masking feature Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
parent
81cea6aed5
commit
456504cf82
|
|
@ -257,8 +257,12 @@ function onImagePointerdown(ev: PointerEvent) {
|
||||||
xOffset /= 2;
|
xOffset /= 2;
|
||||||
yOffset /= 2;
|
yOffset /= 2;
|
||||||
|
|
||||||
let startX = ev.offsetX - xOffset;
|
const rect = canvasEl.value.getBoundingClientRect();
|
||||||
let startY = ev.offsetY - yOffset;
|
const pointerOffsetX = ev.clientX - rect.left;
|
||||||
|
const pointerOffsetY = ev.clientY - rect.top;
|
||||||
|
|
||||||
|
let startX = pointerOffsetX - xOffset;
|
||||||
|
let startY = pointerOffsetY - yOffset;
|
||||||
|
|
||||||
if (AW / AH < BW / BH) { // 横長
|
if (AW / AH < BW / BH) { // 横長
|
||||||
startX = startX / (Math.max(AW, AH) / Math.max(BH / BW, 1));
|
startX = startX / (Math.max(AW, AH) / Math.max(BH / BW, 1));
|
||||||
|
|
@ -311,9 +315,11 @@ function onImagePointerdown(ev: PointerEvent) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_move(ev.offsetX, ev.offsetY);
|
_move(ev.clientX, ev.clientY);
|
||||||
|
|
||||||
function _move(pointerX: number, pointerY: number) {
|
function _move(pointerClientX: number, pointerClientY: number) {
|
||||||
|
const pointerX = pointerClientX - rect.left;
|
||||||
|
const pointerY = pointerClientY - rect.top;
|
||||||
let x = pointerX - xOffset;
|
let x = pointerX - xOffset;
|
||||||
let y = pointerY - yOffset;
|
let y = pointerY - yOffset;
|
||||||
|
|
||||||
|
|
@ -340,7 +346,7 @@ function onImagePointerdown(ev: PointerEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function move(ev: PointerEvent) {
|
function move(ev: PointerEvent) {
|
||||||
_move(ev.offsetX, ev.offsetY);
|
_move(ev.clientX, ev.clientY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function up() {
|
function up() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue