Skip to content

Commit

Permalink
fix(image): sensitivity of image scaling (#6784)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovsu authored Jul 29, 2023
1 parent f1f8919 commit e8c2860
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions components/vc-image/src/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,22 @@ const Preview = defineComponent({
emit('afterClose');
};

const onZoomIn = () => {
scale.value++;
const onZoomIn = (isWheel?: boolean) => {
if (!isWheel) {
scale.value++;
} else {
scale.value += 0.5;
}

setPosition(initialPosition);
};
const onZoomOut = () => {
const onZoomOut = (isWheel?: boolean) => {
if (scale.value > 1) {
scale.value--;
if (!isWheel) {
scale.value--;
} else {
scale.value -= 0.5;
}
}
setPosition(initialPosition);
};
Expand Down Expand Up @@ -152,12 +161,12 @@ const Preview = defineComponent({
},
{
icon: zoomIn,
onClick: onZoomIn,
onClick: () => onZoomIn(),
type: 'zoomIn',
},
{
icon: zoomOut,
onClick: onZoomOut,
onClick: () => onZoomOut(),
type: 'zoomOut',
disabled: computed(() => scale.value === 1),
},
Expand Down Expand Up @@ -299,9 +308,9 @@ const Preview = defineComponent({
watch([lastWheelZoomDirection], () => {
const { wheelDirection } = lastWheelZoomDirection.value;
if (wheelDirection > 0) {
onZoomOut();
onZoomOut(true);
} else if (wheelDirection < 0) {
onZoomIn();
onZoomIn(true);
}
});
});
Expand Down

0 comments on commit e8c2860

Please sign in to comment.