Skip to content

BUG: Zoom-on-Scroll Behavior Does Not Match Expected Media Viewer UX #656

@rohan-pandeyy

Description

@rohan-pandeyy

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

The previously implemented Zoom-on-Scroll feature (refer issue #528) does not fully meet the expected behavior, usability requirements. Several core zoom mechanics such as minimum zoom limits, axis-dependent centering, and auto-recentering are implemented incorrectly.

Current Behavior

  1. minScale and maxScale are hardcoded to {0.1} and {8}.
  2. The image can be zoomed out to a tiny size, much smaller than the viewport.
  3. Zooming is always mouse-anchored, even when the image still fits inside the screen.
  4. When zooming out to minimum, the image may remain off-center due to preserved panning offsets.

Expected Behavior

  1. Dynamic Minimum Zoom ("Fit to Screen")

    • The viewer should compute a dynamic fitScale based on the image’s natural dimensions & the viewer container size.
    • The minimum zoom level should be the "fit-to-screen" scale only when the image is larger than the viewport, and original resolution scale when the image is smaller than or equal to the viewport. Users should not be able to zoom out past this point.
    • No tiny or floating images.
  2. Axis-Dependent Zoom Anchoring
    Zooming should behave differently depending on image overflow:
    Case 1 - No Overflow

    • Image fully fits inside viewport in both directions
    • Zoom is centered
    • No panning or mouse anchoring yet.

    Case 2 - Overflow in One Axis

    • If width overflows >> mouse-anchored zoom horizontally
    • If height overflows >> mouse-anchored zoom vertically
    • Non-overflowing axis stays centered (position locked to 0)

    Case 3 - Overflow in Both Axes

    • Full mouse-anchored zoom behavior
  3. Automatic Re-centering at Minimum Zoom
    When zooming out back to minimum:
    Case 1 - Overflow in Both Axes

    • Full mouse-anchored zoom behavior

    Case 2 - No Overflow

    • The image should snap back to centered
    • All panning offsets should gradually reset to 0
    • Prevents the image from being stuck in a corner after zooming/panning

Steps to Reproduce

  1. Open any image in Media View.
  2. Scroll up and down randomly
  3. See issue

Video explaination:

https://drive.google.com/file/d/1yr7jHZgVyK4-930m20peNzkj9uw7ihto/view?usp=sharing

Record

  • I agree to follow this project's Code of Conduct

Checklist before Submitting

  • Have you updated docs for it?
  • Have you added unit tests?
  • Have you made sure unit tests pass?
  • Have you made sure code formatting is correct?
  • Do Your changes passes all tests?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfrontend

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions