Skip to content

usePointerLock

Category
Export Size
1.44 kB
Last Changed
last month

Reactive pointer lock.

Demo

Basic Usage

ts
import { 
usePointerLock
} from '@vueuse/core'
const {
isSupported
,
lock
,
unlock
,
element
,
triggerElement
} =
usePointerLock
()

Component Usage

This function also provides a renderless component version via the @vueuse/components package. Learn more about the usage.

vue
<template>
  <UsePointerLock v-slot="{ 
lock
}">
<
canvas
/>
<
button
@
click
="
lock
">
Lock Pointer on Canvas </
button
>
</UsePointerLock> </template>

Type Declarations

ts
export interface UsePointerLockOptions extends ConfigurableDocument {}
export interface UsePointerLockReturn extends Supportable {
  
element
:
ShallowRef
<
MaybeElement
>
triggerElement
:
ShallowRef
<
MaybeElement
>
lock
: (
e
:
MaybeElementRef
| Event) =>
Promise
<
MaybeElement
>
unlock
: () =>
Promise
<boolean>
} /** * Reactive pointer lock. * * @see https://vueuse.org/usePointerLock * @param target * @param options * * @__NO_SIDE_EFFECTS__ */ export declare function
usePointerLock
(
target
?:
MaybeElementRef
,
options
?: UsePointerLockOptions,
): UsePointerLockReturn

Source

SourceDemoDocs

Contributors

Anthony Fu
Vida Xie
IlyaL
SerKo
IlyaL
Robin
Fernando Fernández
Robin
Anthony Fu
Sergey Danilchenko

Changelog

v14.0.0-alpha.0 on
8c521 - feat(components)!: refactor components and make them consistent (#4912)
v13.6.0 on
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
v12.6.0 on
ce9e5 - fix(useMouse): check for MouseEvent instead of Touch to work with FF (#4457)
v12.4.0 on
dd316 - feat: use passive event handlers everywhere is possible (#4477)
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v10.8.0 on
a086e - fix: stricter types

Released under the MIT License.

40% Off  yearly access to Vue School, Full course library + Vue.js Master Class.
Claim Offer