Update MkImageEffectorDialog.vue
This commit is contained in:
parent
616e2a4623
commit
ec1a1ffc04
|
@ -219,8 +219,6 @@ watch(enabled, () => {
|
||||||
const fillSquare = ref(false);
|
const fillSquare = ref(false);
|
||||||
|
|
||||||
function onImagePointerdown(ev: PointerEvent) {
|
function onImagePointerdown(ev: PointerEvent) {
|
||||||
const PADDING = 0; // TODO
|
|
||||||
|
|
||||||
if (canvasEl.value == null || imageBitmap == null || !fillSquare.value) return;
|
if (canvasEl.value == null || imageBitmap == null || !fillSquare.value) return;
|
||||||
|
|
||||||
const AW = canvasEl.value.clientWidth;
|
const AW = canvasEl.value.clientWidth;
|
||||||
|
@ -244,11 +242,11 @@ function onImagePointerdown(ev: PointerEvent) {
|
||||||
let startY = ev.offsetY - yOffset;
|
let startY = ev.offsetY - yOffset;
|
||||||
|
|
||||||
if (AW / AH < BW / BH) { // 横長
|
if (AW / AH < BW / BH) { // 横長
|
||||||
startX = (startX - PADDING) / ((Math.max(AW, AH) / Math.max(BH / BW, 1)) - (PADDING * 2));
|
startX = startX / (Math.max(AW, AH) / Math.max(BH / BW, 1));
|
||||||
startY = (startY - PADDING) / ((Math.max(AW, AH) / Math.max(BW / BH, 1)) - (PADDING * 2));
|
startY = startY / (Math.max(AW, AH) / Math.max(BW / BH, 1));
|
||||||
} else { // 縦長
|
} else { // 縦長
|
||||||
startX = (startX - PADDING) / ((Math.min(AW, AH) / Math.max(BH / BW, 1)) - (PADDING * 2));
|
startX = startX / (Math.min(AW, AH) / Math.max(BH / BW, 1));
|
||||||
startY = (startY - PADDING) / ((Math.min(AW, AH) / Math.max(BW / BH, 1)) - (PADDING * 2));
|
startY = startY / (Math.min(AW, AH) / Math.max(BW / BH, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const id = genId();
|
const id = genId();
|
||||||
|
@ -273,11 +271,11 @@ function onImagePointerdown(ev: PointerEvent) {
|
||||||
let y = pointerY - yOffset;
|
let y = pointerY - yOffset;
|
||||||
|
|
||||||
if (AW / AH < BW / BH) { // 横長
|
if (AW / AH < BW / BH) { // 横長
|
||||||
x = (x - PADDING) / ((Math.max(AW, AH) / Math.max(BH / BW, 1)) - (PADDING * 2));
|
x = x / (Math.max(AW, AH) / Math.max(BH / BW, 1));
|
||||||
y = (y - PADDING) / ((Math.max(AW, AH) / Math.max(BW / BH, 1)) - (PADDING * 2));
|
y = y / (Math.max(AW, AH) / Math.max(BW / BH, 1));
|
||||||
} else { // 縦長
|
} else { // 縦長
|
||||||
x = (x - PADDING) / ((Math.min(AW, AH) / Math.max(BH / BW, 1)) - (PADDING * 2));
|
x = x / (Math.min(AW, AH) / Math.max(BH / BW, 1));
|
||||||
y = (y - PADDING) / ((Math.min(AW, AH) / Math.max(BW / BH, 1)) - (PADDING * 2));
|
y = y / (Math.min(AW, AH) / Math.max(BW / BH, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const scaleX = Math.abs(x - startX);
|
const scaleX = Math.abs(x - startX);
|
||||||
|
@ -392,9 +390,11 @@ function onImagePointerdown(ev: PointerEvent) {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: -webkit-fill-available;
|
||||||
height: 100%;
|
width: stretch;
|
||||||
padding: 0px; /* TODO */
|
height: -webkit-fill-available;
|
||||||
|
height: stretch;
|
||||||
|
margin: 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue