Skip to content

Commit f768e6f

Browse files
committed
refactor: 精简代码
1 parent 4116d5c commit f768e6f

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

src/BootstrapBlazor/wwwroot/modules/fullscreen.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
import { isElement, registerBootstrapBlazorModule } from "./utility.js"
2-
import EventHandler from "./event-handler.js"
1+
import { isElement } from "./utility.js"
32

43
export async function toggle(options) {
5-
registerBootstrapBlazorModule("FullScreen", null, () => {
6-
EventHandler.on(document, "fullscreenchange", () => {
7-
if (document.fullscreenElement === null) {
8-
[...document.querySelectorAll('.bb-fs-open')].forEach(el => {
9-
el.classList.remove('bb-fs-open');
10-
})
11-
}
12-
});
13-
})
144
let el = null;
155
options = options || {};
166
if (options.id) {
@@ -35,24 +25,10 @@ export async function toggle(options) {
3525

3626
const enterFullscreen = async el => {
3727
await el.requestFullscreen();
38-
39-
updateFullscreenState(el);
4028
}
4129

4230
const exitFullscreen = async el => {
4331
await document.exitFullscreen()
44-
45-
updateFullscreenState(el);
46-
}
47-
48-
const updateFullscreenState = el => {
49-
if (isFullscreen()) {
50-
el.classList.add('bb-fs-open')
51-
}
52-
else {
53-
el.classList.remove('bb-fs-open');
54-
document.documentElement.classList.remove('bb-fs-open');
55-
}
5632
}
5733

5834
const isFullscreen = () => {

0 commit comments

Comments
 (0)