fix(image): sensitivity of image scaling (#6784)
parent
f1f89191ee
commit
e8c2860c7d
|
@ -103,13 +103,22 @@ const Preview = defineComponent({
|
||||||
emit('afterClose');
|
emit('afterClose');
|
||||||
};
|
};
|
||||||
|
|
||||||
const onZoomIn = () => {
|
const onZoomIn = (isWheel?: boolean) => {
|
||||||
|
if (!isWheel) {
|
||||||
scale.value++;
|
scale.value++;
|
||||||
|
} else {
|
||||||
|
scale.value += 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
setPosition(initialPosition);
|
setPosition(initialPosition);
|
||||||
};
|
};
|
||||||
const onZoomOut = () => {
|
const onZoomOut = (isWheel?: boolean) => {
|
||||||
if (scale.value > 1) {
|
if (scale.value > 1) {
|
||||||
|
if (!isWheel) {
|
||||||
scale.value--;
|
scale.value--;
|
||||||
|
} else {
|
||||||
|
scale.value -= 0.5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setPosition(initialPosition);
|
setPosition(initialPosition);
|
||||||
};
|
};
|
||||||
|
@ -152,12 +161,12 @@ const Preview = defineComponent({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: zoomIn,
|
icon: zoomIn,
|
||||||
onClick: onZoomIn,
|
onClick: () => onZoomIn(),
|
||||||
type: 'zoomIn',
|
type: 'zoomIn',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: zoomOut,
|
icon: zoomOut,
|
||||||
onClick: onZoomOut,
|
onClick: () => onZoomOut(),
|
||||||
type: 'zoomOut',
|
type: 'zoomOut',
|
||||||
disabled: computed(() => scale.value === 1),
|
disabled: computed(() => scale.value === 1),
|
||||||
},
|
},
|
||||||
|
@ -299,9 +308,9 @@ const Preview = defineComponent({
|
||||||
watch([lastWheelZoomDirection], () => {
|
watch([lastWheelZoomDirection], () => {
|
||||||
const { wheelDirection } = lastWheelZoomDirection.value;
|
const { wheelDirection } = lastWheelZoomDirection.value;
|
||||||
if (wheelDirection > 0) {
|
if (wheelDirection > 0) {
|
||||||
onZoomOut();
|
onZoomOut(true);
|
||||||
} else if (wheelDirection < 0) {
|
} else if (wheelDirection < 0) {
|
||||||
onZoomIn();
|
onZoomIn(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue