Skip to content

Commit df93cb4

Browse files
committed
Preload game background images
1 parent 5dca737 commit df93cb4

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/components/powered.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { MouseEvent } from 'react';
1+
import React from 'react';
2+
import Head from 'next/head';
23
import styles from '@/styles/powered.module.css';
34
import drawnDownAbyss1 from '@/assets/drawn-down-abyss-1.png';
45
import froggo1 from '@/assets/froggo-swing-n-grapple-1.png';
@@ -66,26 +67,33 @@ class Powered extends React.Component<any, any> {
6667
}
6768

6869
return (
69-
<div
70-
className={styles.powered}
71-
style={{
72-
backgroundImage: `url(${currentGame.image})`,
73-
}}
74-
>
75-
<div className={styles.poweredcontainer}>
76-
<div className={styles.header}>Pygame Powered</div>
77-
Over the many years pygame has been around, there have been amazing projects created by the community.
78-
<div className={styles.poweredcards}>
79-
{games.map((data, key) => {
80-
return (
81-
<div key={key} onMouseEnter={this.changeBackground} data-info={key}>
82-
<PoweredCard name={data.name} author={data.author} link={data.mainlink} />
83-
</div>
84-
);
85-
})}
70+
<>
71+
<Head>
72+
{games.map((data, key) => {
73+
return <link key={key} rel="preload" href={data.image} as="image" />;
74+
})}
75+
</Head>
76+
<div
77+
className={styles.powered}
78+
style={{
79+
backgroundImage: `url(${currentGame.image})`,
80+
}}
81+
>
82+
<div className={styles.poweredcontainer}>
83+
<div className={styles.header}>Pygame Powered</div>
84+
Over the many years pygame has been around, there have been amazing projects created by the community.
85+
<div className={styles.poweredcards}>
86+
{games.map((data, key) => {
87+
return (
88+
<div key={key} onMouseEnter={this.changeBackground} data-info={key}>
89+
<PoweredCard name={data.name} author={data.author} link={data.mainlink} />
90+
</div>
91+
);
92+
})}
93+
</div>
8694
</div>
8795
</div>
88-
</div>
96+
</>
8997
);
9098
}
9199
}

0 commit comments

Comments
 (0)