Skip to content

Commit

Permalink
tap for fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbowen committed Mar 2, 2024
1 parent d6df37b commit a5ca87d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ class SphereWithRods {

addEventListeners(): void {
window.addEventListener('resize', this.onWindowResize.bind(this), false);
// Add click event listener for toggling fullscreen
window.addEventListener('click', this.toggleFullScreen.bind(this), false);
}

toggleFullScreen(): void {
if (!document.fullscreenElement) {
if (document.body.requestFullscreen) {
document.body.requestFullscreen();
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}

onWindowResize(): void {
Expand Down

0 comments on commit a5ca87d

Please sign in to comment.