Skip to content

Conversation

JulianGlueck
Copy link
Contributor

@JulianGlueck JulianGlueck commented Aug 13, 2025

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.

Laravel PR: NativePHP/laravel#678

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.
@gwleuverink gwleuverink merged commit a7f4ded into NativePHP:main Aug 18, 2025
1 check passed
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.

3 participants