Skip to content

[Image] | (UX) | Scale up SVG images to fill screen when zoomed#3252

Open
nishasy wants to merge 3 commits intomainfrom
scale-zoomed-graphies
Open

[Image] | (UX) | Scale up SVG images to fill screen when zoomed#3252
nishasy wants to merge 3 commits intomainfrom
scale-zoomed-graphies

Conversation

@nishasy
Copy link
Contributor

@nishasy nishasy commented Feb 12, 2026

Summary:

Currently, the zoomed view of an image will show it at its original/natural size.

It was implemented this way so that the images are at their largest size without compromising
quality, but that doesn't apply to SVGs. SVGs can be scaled up without quality drop.

In this PR:

  • Scale up SVGs to fit the whole screen on zoom
  • Do not scale up non-SVGs on zoom - keep them at their natural size

Issue: https://khanacademy.atlassian.net/browse/LEMS-3740

Test plan:

pnpm jest packages/perseus/src/widgets/image/image.test.ts

Storybook

  • /?path=/story/widgets-image-widget-demo--graphie-image
  • /?path=/story/widgets-image-widget-demo--image

Before

Screenshot 2026-02-12 at 3 17 57 PM

After

Screenshot 2026-02-12 at 3 18 28 PM

…screen when zoomed

Currently, the zoomed view of an image will show it at its original/natural size.

It was implemented this way so that the images are at their largest size without compromising
quality, but that doesn't apply to SVGs. SVGs can be scaled up without quality drop.

In this PR:
- Scale up SVGs to fit the whole screen on zoom
- Do not scale up non-SVGs on zoom - keep them at their natural size

Issue: https://khanacademy.atlassian.net/browse/LEMS-3740

Test plan:
`pnpm jest packages/perseus/src/widgets/image/image.test.ts`

Storybook
- `/?path=/story/widgets-image-widget-demo--graphie-image`
- `/?path=/story/widgets-image-widget-demo--image`
@nishasy nishasy self-assigned this Feb 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

Size Change: +88 B (+0.02%)

Total Size: 484 kB

Filename Size Change
packages/perseus/dist/es/index.js 187 kB +88 B (+0.05%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 11.8 kB
packages/perseus-core/dist/es/index.js 24.8 kB
packages/perseus-editor/dist/es/index.js 99.2 kB
packages/perseus-linter/dist/es/index.js 8.83 kB
packages/perseus-score/dist/es/index.js 9.26 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 7.44 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (f422944) and published it to npm. You
can install it using the tag PR3252.

Example:

pnpm add @khanacademy/perseus@PR3252

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3252

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3252

/**
* When the content is at least as wide as the viewport (i.e. mobile),
* allow the content to fill the entire viewport.
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused about what this meant, so I added a comment so it wouldn't confuse me again later.

@nishasy nishasy marked this pull request as ready for review February 13, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant