Commit 098e9cf33db68ed9534129c5ef25e58c602eeb87
1 parent
e6ffb67e
perf(src/packages): 优化图表全屏按esc退出全屏背景是白色的问题
Showing
1 changed file
with
19 additions
and
0 deletions
@@ -5,8 +5,10 @@ export const useFullScreen = (domName: any, htmlName: HTMLHtmlElement) => { | @@ -5,8 +5,10 @@ export const useFullScreen = (domName: any, htmlName: HTMLHtmlElement) => { | ||
5 | if (isFullScreen) { | 5 | if (isFullScreen) { |
6 | if (document.exitFullscreen) { | 6 | if (document.exitFullscreen) { |
7 | document.exitFullscreen() | 7 | document.exitFullscreen() |
8 | + domName.style.background = currentDatkTheme === 'light' ? '' : '' | ||
8 | } | 9 | } |
9 | } else { | 10 | } else { |
11 | + //兼容其他浏览器 | ||
10 | if (domName.requestFullscreen) { | 12 | if (domName.requestFullscreen) { |
11 | domName.requestFullscreen() | 13 | domName.requestFullscreen() |
12 | domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c' | 14 | domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c' |
@@ -21,4 +23,21 @@ export const useFullScreen = (domName: any, htmlName: HTMLHtmlElement) => { | @@ -21,4 +23,21 @@ export const useFullScreen = (domName: any, htmlName: HTMLHtmlElement) => { | ||
21 | domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c' | 23 | domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c' |
22 | } | 24 | } |
23 | } | 25 | } |
26 | + //fix 浏览器监听esc退出 | ||
27 | + function exitHandler() { | ||
28 | + if ( | ||
29 | + !(document as any).webkitIsFullScreen && | ||
30 | + !(document as any).mozFullScreen && | ||
31 | + !(document as any).msFullscreenElement | ||
32 | + ) { | ||
33 | + domName.style.background = currentDatkTheme === 'light' ? '' : '' | ||
34 | + } | ||
35 | + } | ||
36 | + // 监听fullscreenchange事件(全屏模式的变化) | ||
37 | + if (document.addEventListener) { | ||
38 | + document.addEventListener('webkitfullscreenchange', exitHandler, false) | ||
39 | + document.addEventListener('mozfullscreenchange', exitHandler, false) | ||
40 | + document.addEventListener('fullscreenchange', exitHandler, false) | ||
41 | + document.addEventListener('MSFullscreenChange', exitHandler, false) | ||
42 | + } | ||
24 | } | 43 | } |