Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useParallax.md
1---2category: Sensors3---45# useParallax67Create parallax effect easily. It uses `useDeviceOrientation` and fallback to `useMouse` if orientation is not supported.89## Usage1011```vue12<script setup lang="ts">13import { useParallax } from '@vueuse/core'1415const container = ref(null)16const { tilt, roll, source } = useParallax(container)17</script>1819<template>20<div ref="container" />21</template>22```2324## Type Declarations2526```ts27export interface UseParallaxOptions extends ConfigurableWindow {28deviceOrientationTiltAdjust?: (i: number) => number29deviceOrientationRollAdjust?: (i: number) => number30mouseTiltAdjust?: (i: number) => number31mouseRollAdjust?: (i: number) => number32}33export interface UseParallaxReturn {34/**35* Roll value. Scaled to `-0.5 ~ 0.5`36*/37roll: ComputedRef<number>38/**39* Tilt value. Scaled to `-0.5 ~ 0.5`40*/41tilt: ComputedRef<number>42/**43* Sensor source, can be `mouse` or `deviceOrientation`44*/45source: ComputedRef<"deviceOrientation" | "mouse">46}47/**48* Create parallax effect easily. It uses `useDeviceOrientation` and fallback to `useMouse`49* if orientation is not supported.50*51* @param target52* @param options53*/54export declare function useParallax(55target: MaybeElementRef,56options?: UseParallaxOptions,57): UseParallaxReturn58```59