rust-lang / rust-lang/mdBook

Consider zooming images with a horizontal fit + scrolling support

Open
#3,161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement
Dominant language
Rust
Stars
22.2k
Forks
1.9k
PR merge metrics
PR metrics pending

Description

Problem

First of all, thanks a lot for the zoomable image feature of mdbook v0.5.4! It allowed me to remove heaps of the annoying <a href='foobar.png' target='_blank'><img src='foobar.png' /></a> pattern from some of my static sites.

However, I noticed that it does not work so well with images that have a very tall aspect ratio designed to be scrolled through, as it adjusts them to the browser window height which can make them excessively narrow.

Here's an example of the kind of image that I am talking about: https://grasland.pages.in2p3.fr/tp-perf/perf-script/perf_script_call_trace_main.png...

Notice how it does not look good with the CSS zoom that was introduced in mdbook v0.5.4:
Image

Proposed Solution

My former "open in new tab" solution handles this kind of images better because the web browser starts with a vertical image fit but let you switch to a horizontal fit by clicking on the image. The reader can then scroll to see the whole content, then close the tab once done.

With the current mdbook zoomable image UX, a second click wouldn't work as 1/double clicking is annoying and 2/the interaction of clicking on a zoomed image is already used to un-zoom the image.

What I think could work however, is to adjust the CSS so that images have a horizontal fit only and can be scrolled by the user as needed. But I'm not proficient enough with CSS to tell if this is actually doable without javascript or not.

Notes

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the CSS zoomable-image behavior introduced in mdBook v0.5.4 and identify the styles controlling image fitting and scrolling. Test with a very tall image like the linked example. Done means tall images use a horizontal fit, remain scrollable, and preserve the existing zoom and un-zoom interaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.