This repository was archived by the owner on Feb 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed
_pages/LandingPage/components/HeaderView Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -7,21 +7,23 @@ import GithubButton from '../../../../components/buttons/GithubButton';
7
7
import styles from './styles.module.css' ;
8
8
import { useWindowSize } from '../../../../hooks/useWindowSize' ;
9
9
import MouseScroller from './components/MouseScroller' ;
10
- import { animated , useSpring } from 'react-spring' ;
11
10
import Astronaut from './components/Astronaut' ;
11
+ import { shuffle } from '../../../../utils' ;
12
12
13
13
const HeaderView : React . FC = ( ) => {
14
14
const { siteConfig } = useDocusaurusContext ( ) ;
15
15
const { windowHeight } = useWindowSize ( ) ;
16
- const [ toTypeWords ] = useState ( [
17
- 'simple' ,
18
- 'straightforward' ,
19
- 'fast' ,
20
- 'understandable' ,
21
- 'boilerplate free' ,
22
- 'spacy' ,
23
- 'fun' ,
24
- ] ) ;
16
+ const [ toTypeWords ] = useState (
17
+ shuffle ( [
18
+ 'simple' ,
19
+ 'straightforward' ,
20
+ 'fast' ,
21
+ 'understandable' ,
22
+ 'boilerplate free' ,
23
+ 'spacy' ,
24
+ 'fun' ,
25
+ ] )
26
+ ) ;
25
27
26
28
return (
27
29
< div className = { styles . Container } >
Original file line number Diff line number Diff line change
1
+ export function shuffle < X extends Array < any > > ( array : X ) {
2
+ let currentIndex = array . length ;
3
+ let temporaryValue = null ;
4
+ let randomIndex = 0 ;
5
+
6
+ // While there remain elements to shuffle...
7
+ while ( 0 !== currentIndex ) {
8
+ // Pick a remaining element...
9
+ randomIndex = Math . floor ( Math . random ( ) * currentIndex ) ;
10
+ currentIndex -= 1 ;
11
+
12
+ // And swap it with the current element.
13
+ temporaryValue = array [ currentIndex ] ;
14
+ array [ currentIndex ] = array [ randomIndex ] ;
15
+ array [ randomIndex ] = temporaryValue ;
16
+ }
17
+
18
+ return array ;
19
+ }
You can’t perform that action at this time.
0 commit comments