-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now you can visually connect to particles in brain
- Loading branch information
1 parent
f36112c
commit c42d5ea
Showing
11 changed files
with
446 additions
and
160 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
12 changes: 12 additions & 0 deletions
12
src/features/cyberlinks/GraphFullscreenBtn/GraphFullscreenBtn.module.scss
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,12 @@ | ||
.btn { | ||
position: absolute; | ||
right: 50px; | ||
z-index: 10; | ||
top: 200px; | ||
font-size: 18px; | ||
color: var(--primary-color); | ||
|
||
&:hover { | ||
opacity: 0.7; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/features/cyberlinks/GraphFullscreenBtn/GraphFullscreenBtn.tsx
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,47 @@ | ||
import { PORTAL_ID } from 'src/containers/application/App'; | ||
import { useState } from 'react'; | ||
import useEventListener from 'src/hooks/dom/useEventListener'; | ||
import styles from './GraphFullscreenBtn.module.scss'; | ||
|
||
export function useFullscreen() { | ||
const [isFullscreen, setIsFullscreen] = useState(false); | ||
|
||
const handleFullscreenChange = () => { | ||
setIsFullscreen(document.fullscreenElement !== null); | ||
}; | ||
|
||
useEventListener('fullscreenchange', handleFullscreenChange, document); | ||
|
||
function toggleFullscreen(element?: HTMLElement = document) { | ||
if (!document.fullscreenElement) { | ||
element.requestFullscreen(); | ||
} else if (document.exitFullscreen) { | ||
document.exitFullscreen(); | ||
} | ||
} | ||
|
||
return { | ||
isFullscreen, | ||
toggleFullscreen, | ||
}; | ||
} | ||
|
||
function GraphFullscreenBtn() { | ||
const { isFullscreen, toggleFullscreen } = useFullscreen(); | ||
|
||
function onClick() { | ||
if (!document.fullscreenElement) { | ||
toggleFullscreen(document.getElementById(PORTAL_ID)); | ||
} else if (document.exitFullscreen) { | ||
document.exitFullscreen(); | ||
} | ||
} | ||
|
||
return ( | ||
<button className={styles.btn} onClick={onClick} type="button"> | ||
{isFullscreen ? 'Exit Fullscreen' : 'Enter Fullscreen'} | ||
</button> | ||
); | ||
} | ||
|
||
export default GraphFullscreenBtn; |
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.