Skip to content

useDevicePixelRatio

Category
Export Size
367 B
Last Changed
5 days ago

Reactively track window.devicePixelRatio

NOTE: there is no event listener for window.devicePixelRatio change. So this function uses Testing media queries programmatically (window.matchMedia) applying the same mechanism as described in this example.

Demo

Usage

tsx
import { 
useDevicePixelRatio
} from '@reause/core'
const {
pixelRatio
} =
useDevicePixelRatio
()
console
.
log
(
pixelRatio
)

Type Declarations

ts
export interface UseDevicePixelRatioOptions extends ConfigurableWindow {
}

export interface UseDevicePixelRatioReturn {
    pixelRatio: number;
    stop: () => void;
}

export function useDevicePixelRatio(options?: UseDevicePixelRatioOptions): UseDevicePixelRatioReturn

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
dfaaa - fix(core): resolve useDevicePixelRatio audit findings (#541)

Released under the MIT License. v0.1.8