目录

Zoom

The zoom controller that can be used to zoom in and out the browser content.

Zoom factor will be applied to the content of the browser window and associated with the host of the web page. It will be applied to all web pages hosted on the same host. It is stored in the application data directory and restored when the application is launched again.

Example 

import { BrowserWindow, Zoom } from '@mobrowser/api';

const win = new BrowserWindow()
win.browser.loadUrl('https://example.com')
const zoom: Zoom = win.browser.zoom
zoom.setFactor(2.0) // Zoom in example.com/* to 200%.

Properties 

factor 

readonly factor: ZoomFactor;

The current zoom factor: 1.0 is 100%, 3.0 is 300%, 0.5 is 50%, etc.

enabled 

readonly enabled: boolean;

Whether the zoom is enabled. By default, the zoom is enabled.

Methods 

setFactor() 

setFactor(factor: ZoomFactor): void;

Sets the zoom factor (e.g. 2.0 for 200%).

Example 

import { BrowserWindow } from '@mobrowser/api';

const win = new BrowserWindow()
// Zoom in to 200%
win.browser.zoom.setFactor(2.0)

setEnabled() 

setEnabled(enabled: boolean): void;

Sets whether the zoom is enabled. By default, the zoom is enabled.

Example 

import { BrowserWindow } from '@mobrowser/api';

const win = new BrowserWindow()
win.browser.zoom.setEnabled(false)

in() 

in(): void;

Zooms in by one preset step.

If the current zoom is already at the maximum, this method does nothing.

out() 

out(): void;

Zooms out by one preset step.

If the current zoom is already at the minimum, this method does nothing.

reset() 

reset(): void;

Resets the zoom factor to the default 1.0 (100%).

Events 

‘factorChanged’ 

on(event: 'factorChanged', listener: (newFactor: ZoomFactor, oldFactor: ZoomFactor) => void): void;
off(event: 'factorChanged', listener: (newFactor: ZoomFactor, oldFactor: ZoomFactor) => void): void;

Emitted when the zoom factor changes.