-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(useFullscreen): support page fullscreen (#1893)
* feat: 添加了默认状态值hook函数 * feat: 添加了修改hash值的hook函数 * fix: 修改了文档描述 * feat: useFullscreen添加了是否是浏览器全屏的配置 * refactor: support pass className and z-index * docs: update demo * docs: add detail explain for pageFullscreen * chore: restore lock * refactor: resolve confict * style: rename * chore: resolve warning in test case * fix: onExit is invoked twice * refactor: reuse logic * refactor: prevent repeated calls * refactor: update * test: add case for pageFullscreen * docs: fix typo --------- Co-authored-by: liuyib <[email protected]>
- Loading branch information
1 parent
fa9afea
commit b3fd1bb
Showing
5 changed files
with
216 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* title: Page full screen | ||
* | ||
* title.zh-CN: 页面全屏 | ||
*/ | ||
|
||
import React, { useRef } from 'react'; | ||
import { useFullscreen } from 'ahooks'; | ||
|
||
export default () => { | ||
const ref = useRef(null); | ||
const [isFullscreen, { toggleFullscreen, enterFullscreen, exitFullscreen }] = useFullscreen(ref, { | ||
pageFullscreen: true, | ||
}); | ||
|
||
return ( | ||
<div style={{ background: 'white' }}> | ||
<div ref={ref} style={{ background: '#4B6BCD', padding: 12 }}> | ||
<div style={{ marginBottom: 16 }}>{isFullscreen ? 'Fullscreen' : 'Not fullscreen'}</div> | ||
<button type="button" onClick={enterFullscreen}> | ||
enterFullscreen | ||
</button> | ||
<button type="button" onClick={exitFullscreen} style={{ margin: '0 8px' }}> | ||
exitFullscreen | ||
</button> | ||
<button type="button" onClick={toggleFullscreen}> | ||
toggleFullscreen | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.