Skip to content

useParallax

轻松创建视差效果。如果不支持方向,它使用 useDeviceOrientation 并回退到 useMouse

¥Create parallax effect easily. It uses useDeviceOrientation and fallback to useMouse if orientation is not supported.

示例

roll: .nan
tilt: .nan
source: mouse
Credit of images to Jarom Vogel

用法

¥Usage

vue
<script setup lang="ts">
import { 
useParallax
} from '@vueuse/core'
const
container
=
ref
(null)
const {
tilt
,
roll
,
source
} =
useParallax
(
container
)
</script> <template> <
div
ref
="
container
" />
</template>