📄 useDevicePixelRatio¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 9 |
| 📐 Interfaces | 2 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/core/useDevicePixelRatio/index.ts
📦 Imports¶
| Name | Source |
|---|---|
ShallowRef |
vue |
WatchStopHandle |
vue |
ConfigurableWindow |
../_configurable |
noop |
@vueuse/shared |
watchImmediate |
@vueuse/shared |
shallowReadonly |
vue |
shallowRef |
vue |
defaultWindow |
../_configurable |
useMediaQuery |
../useMediaQuery |
Functions¶
useDevicePixelRatio(options: UseDevicePixelRatioOptions): UseDevicePixelRatioReturn¶
Reactively track window.devicePixelRatio.
See: https://vueuse.org/useDevicePixelRatio
Tags: @__NO_SIDE_EFFECTS__
Raw JSDoc
Calls:
shallowRef (from vue)useMediaQuery (from ../useMediaQuery)watchImmediate (from @vueuse/shared)shallowReadonly (from vue)
Code
export function useDevicePixelRatio(options: UseDevicePixelRatioOptions = {}): UseDevicePixelRatioReturn {
const {
window = defaultWindow,
} = options
const pixelRatio = shallowRef(1)
const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options)
let stop: WatchStopHandle = noop
if (window) {
stop = watchImmediate(query, () => pixelRatio.value = window!.devicePixelRatio)
}
return {
pixelRatio: shallowReadonly(pixelRatio),
stop,
}
}
Interfaces¶
UseDevicePixelRatioOptions¶
UseDevicePixelRatioReturn¶
Interface Code
Properties¶
| Name | Type | Optional | Description |
|---|---|---|---|
pixelRatio |
Readonly<ShallowRef<number>> |
✗ | not shown |
stop |
WatchStopHandle |
✗ | not shown |
Generated by Syntax Scribe