useFullscreen
管理 DOM 全屏的 Hook。
代码演示
图片全屏
API
const [
isFullscreen,
{
enterFullscreen,
exitFullscreen,
toggleFullscreen,
isEnabled,
}] = useFullScreen(
target,
options?: Options
);
const [
isFullscreen,
{
enterFullscreen,
exitFullscreen,
toggleFullscreen,
isEnabled,
}] = useFullScreen(
target,
options?: Options
);
Params
参数 | 说明 | 类型 |
---|---|---|
target | DOM 节点或者 ref | Element |
option | 设置 | Options |
Options
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
onExit | 退出全屏触发 | () => void | - |
onEnter | 全屏触发 | () => void | - |
defaultElement | 默认全屏元素 | Element | HTMLElement | html |
Result
参数 | 说明 | 类型 |
---|---|---|
isFullscren | 是否全屏 | Readonly<Ref<boolean>> |
enterFullscreen | 设置全屏 | () => void |
exitFullscreen | 退出全屏 | () => void |
toggleFullscreen | 切换全屏 | () => void |
isEnabled | 是否支持全屏 | boolean |