Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
96ced666
Verified
Commit
96ced666
authored
2 years ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
refactor: better fullscreen handling
parent
37f63afa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1520
passed
2 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/web/react/app.tsx
+7
-0
7 additions, 0 deletions
examples/web/react/app.tsx
examples/web/react/components/display/display.tsx
+3
-2
3 additions, 2 deletions
examples/web/react/components/display/display.tsx
with
10 additions
and
2 deletions
examples/web/react/app.tsx
+
7
−
0
View file @
96ced666
...
...
@@ -326,6 +326,11 @@ export const App: FC<AppProps> = ({
}
},
[
keyaction
]);
useEffect
(()
=>
{
const
onFullChange
=
(
event
:
Event
)
=>
{
if
(
!
document
.
fullscreenElement
)
{
setFullscreenState
(
false
);
}
};
const
onKeyDown
=
(
event
:
KeyboardEvent
)
=>
{
switch
(
event
.
key
)
{
case
"
+
"
:
...
...
@@ -360,10 +365,12 @@ export const App: FC<AppProps> = ({
)
=>
{
showToast
(
params
.
text
,
params
.
error
,
params
.
timeout
);
};
document
.
addEventListener
(
"
fullscreenchange
"
,
onFullChange
);
document
.
addEventListener
(
"
keydown
"
,
onKeyDown
);
emulator
.
bind
(
"
booted
"
,
onBooted
);
emulator
.
bind
(
"
message
"
,
onMessage
);
return
()
=>
{
document
.
removeEventListener
(
"
fullscreenchange
"
,
onFullChange
);
document
.
removeEventListener
(
"
keydown
"
,
onKeyDown
);
emulator
.
unbind
(
"
booted
"
,
onBooted
);
emulator
.
unbind
(
"
message
"
,
onMessage
);
...
...
This diff is collapsed.
Click to expand it.
examples/web/react/components/display/display.tsx
+
3
−
2
View file @
96ced666
...
...
@@ -97,7 +97,8 @@ export const Display: FC<DisplayProps> = ({
// requests the browser to go fullscreen using the
// body of the document as the entry HTML element
nativeFullscreen
&&
document
.
body
?.
requestFullscreen
();
nativeFullscreen
&&
document
.
body
?.
requestFullscreen
().
catch
(()
=>
{});
}
else
{
setWidth
(
undefined
);
setHeight
(
undefined
);
...
...
@@ -108,7 +109,7 @@ export const Display: FC<DisplayProps> = ({
// restores the window mode, returning from the
// fullscreen browser
nativeFullscreen
&&
document
?.
exitFullscreen
();
nativeFullscreen
&&
document
?.
exitFullscreen
()
.
catch
(()
=>
{})
;
}
return
()
=>
{
window
.
removeEventListener
(
"
resize
"
,
resizeRef
.
current
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment