Skip to content

Commit

Permalink
fix: prevent zoom from being stuck at extreme levels
Browse files Browse the repository at this point in the history
  • Loading branch information
woelper committed Feb 24, 2024
1 parent 55bf05a commit 32c6b02
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ fn event(app: &mut App, state: &mut OculanteState, evt: Event) {
let divisor = if cfg!(macos) { 0.1 } else { 10. };
// Normal scaling
let delta = zoomratio(
(delta_y / divisor).max(-5.0).min(5.0),
((delta_y / divisor) * state.persistent_settings.zoom_multiplier)
.max(-5.0)
.min(5.0),
state.image_geometry.scale,
);
trace!("Delta {delta}, raw {delta_y}");
Expand All @@ -597,10 +599,9 @@ fn event(app: &mut App, state: &mut OculanteState, evt: Event) {
state.image_geometry.offset,
state.cursor,
state.image_geometry.scale,
delta * state.persistent_settings.zoom_multiplier,
delta,
);
state.image_geometry.scale +=
delta * state.persistent_settings.zoom_multiplier;
state.image_geometry.scale += delta;
}
}
}
Expand Down

0 comments on commit 32c6b02

Please sign in to comment.