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';
77import styles from './styles.module.css' ;
88import { useWindowSize } from '../../../../hooks/useWindowSize' ;
99import MouseScroller from './components/MouseScroller' ;
10- import { animated , useSpring } from 'react-spring' ;
1110import Astronaut from './components/Astronaut' ;
11+ import { shuffle } from '../../../../utils' ;
1212
1313const HeaderView : React . FC = ( ) => {
1414 const { siteConfig } = useDocusaurusContext ( ) ;
1515 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+ ) ;
2527
2628 return (
2729 < 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