@@ -35,6 +35,23 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
35
35
this . container = React . createRef ( ) ;
36
36
}
37
37
38
+ private createStaticLogo ( ) {
39
+ if ( this . container . current ) {
40
+ const staticLogo = document . createElement ( "IMG" ) as HTMLImageElement ;
41
+ staticLogo . src = "/logo.svg" ;
42
+ staticLogo . alt = "Ruffle Logo" ;
43
+ staticLogo . style . width = "85%" ;
44
+ staticLogo . style . height = "auto" ;
45
+ staticLogo . style . margin = "0 auto" ;
46
+ staticLogo . style . display = "block" ;
47
+ staticLogo . style . position = "relative" ;
48
+ staticLogo . style . top = "50%" ;
49
+ staticLogo . style . transform = "translateY(-50%)" ;
50
+ this . container . current . textContent = "" ;
51
+ this . container . current . appendChild ( staticLogo ) ;
52
+ }
53
+ }
54
+
38
55
private load ( ) {
39
56
if ( this . player ) {
40
57
// Already loaded.
@@ -54,16 +71,16 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
54
71
contextMenu : "off" ,
55
72
splashScreen : false ,
56
73
preferredRenderer : "canvas" ,
74
+ } ) . catch ( ( ) => {
75
+ this . createStaticLogo ( ) ;
57
76
} ) ;
58
77
this . player . style . width = "100%" ;
59
78
this . player . style . height = "100%" ;
79
+ } else {
80
+ this . createStaticLogo ( ) ;
60
81
}
61
82
}
62
83
63
- componentDidMount ( ) {
64
- this . load ( ) ;
65
- }
66
-
67
84
componentWillUnmount ( ) {
68
85
this . player ?. remove ( ) ;
69
86
this . player = null ;
@@ -75,6 +92,7 @@ export default class InteractiveLogo extends React.Component<LogoProps> {
75
92
< Script
76
93
src = "https://unpkg.com/@ruffle-rs/ruffle"
77
94
onReady = { ( ) => this . load ( ) }
95
+ onError = { ( ) => this . createStaticLogo ( ) }
78
96
/>
79
97
< div ref = { this . container } className = { this . props . className } />
80
98
</ >
0 commit comments