Skip to content

useParallax

类别
导出大小
2.41 kB
最近修改
2 days ago

轻松创建视差效果。它使用 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>