Skip to content

Add support for setting zoom factor on windows #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JulianGlueck
Copy link

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 a zoomFactor, 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. 😊

This commit allows to define a zoom factor for new and existing windows. The zoom factor is the zoom percent divided by 100, so 150% = 1.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant