Appearance
useZoomFactor
Reactive WebFrame zoom factor.
Demo
Usage
tsx
import { useZoomFactor } from '@reause/electron'
// enable nodeIntegration if you don't provide webFrame explicitly
// see: https://www.electronjs.org/docs/api/webview-tag#nodeintegration
// tuple result will return
const [factor, setFactor] = useZoomFactor()
console.log(factor) // print current zoom factor
setFactor(2) // change current zoom factorSet initial zoom factor immediately
tsx
import { useZoomFactor } from '@reause/electron'
const [factor] = useZoomFactor(2)Pass a state value and the factor will be updated when the source value changes
tsx
import { useZoomFactor } from '@reause/electron'
import { useState } from 'react'
const [factor, setFactor] = useState(1)
useZoomFactor(factor) // zoom factor will match with the state
setFactor(2) // zoom factor will changeType Declarations
ts
export type ZoomFactorSetter = (value: number) => void
export function useZoomFactor(factor?: number): [
number,
ZoomFactorSetter
]
export function useZoomFactor(webFrame: WebFrame, factor?: number): [
number,
ZoomFactorSetter
]