Repository navigation
Conversation
Let a consumer cap how far the editor zooms. The hook clamps the zoom the setters receive, and reports the cap as the controller's maxZoom, which the canvas already hands to wheel and pinch zoom. The editor's own ceiling stays the default and the upper bound; a cap below 1 or outside the range is ignored. The coverage floor still wins over a cap below it, so the image keeps covering the crop.
🤖 PR meta 🤖🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
Member
Author
|
Closing: the zoom cap only existed for the cropper rebuild, which #86417 replaces with a plain deprecation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Stacked on #86405. Follow-up to #86223, part of #86145. Adds a
maxZoomoption touseImageEditorso a consumer can cap how far the editor zooms, below the editor's own ceiling of 10.Why?
The rebuilt
@wordpress/image-cropperkeeps its oldmaxZoomprop with a default of 5. Clamping in the wrapper is not enough: the canvas feedscontroller.maxZoomto wheel and pinch zoom, so the cap has to come from the hook.How?
The hook validates the option (a value below 1, non-finite or above the ceiling is ignored) and reports it as
controller.maxZoom, which the canvas already passes to the interaction code.setZoomandsetZoomAtPointclamp to it before dispatch. The coverage floor still wins over a cap below it, so the image keeps covering the crop. The reducer andMAX_ZOOMare unchanged, so nothing changes for the media editor.Testing Instructions