Add support for setting zoom factor on windows #678
+17
−0
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.
This PR introduces the ability to set a custom zoom factor for newly created or already open windows.
This can be especially useful in scenarios where you do not have control over the content being displayed within a window. For example, our team is currently working on a kiosk-style application that opens secondary windows to display certain (semi-)external websites. As the application will be shown on devices with a large resolution, I was searching for a way to scale the content for better readability and accessibility.
While NativePHP already allows passing options to the
webPreferences
, including azoomFactor
, this approach has a weird limitation: The zoom factor is applied once and then "sticks" to the domain, making it impossible to adjust later on (even if you close and reopen the window).With this change, you can now programmatically set the zoom level at runtime using Electron’s
webContents.setZoomFactor()
, giving you more flexibility when dealing with third-party content (or even own content if you don't want to implement a custom scaling possibility). The zoom factor is the zoom percent divided by 100, so let's say you want a 125% zoom, you would pass the value 1.25.Electron PR: NativePHP/electron#246
If there's anything you'd like me to tweak or improve in this PR, please let me know. 😊