File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
packages/jspsych/src/modules/plugin-api Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -176,24 +176,24 @@ export class MediaAPI {
176
176
return ;
177
177
}
178
178
179
- for ( var i = 0 ; i < images . length ; i ++ ) {
180
- var img = new Image ( ) ;
181
-
182
- img . onload = function ( ) {
179
+ for ( let i = 0 ; i < images . length ; i ++ ) {
180
+ const img = new Image ( ) ;
181
+ const src = images [ i ] ;
182
+ img . onload = ( ) => {
183
183
n_loaded ++ ;
184
- callback_load ( img . src ) ;
184
+ callback_load ( src ) ;
185
185
if ( n_loaded === images . length ) {
186
186
callback_complete ( ) ;
187
187
}
188
188
} ;
189
189
190
- img . onerror = function ( e ) {
191
- callback_error ( { source : img . src , error : e } ) ;
190
+ img . onerror = ( e ) => {
191
+ callback_error ( { source : src , error : e } ) ;
192
192
} ;
193
193
194
- img . src = images [ i ] ;
194
+ img . src = src ;
195
195
196
- this . img_cache [ images [ i ] ] = img ;
196
+ this . img_cache [ src ] = img ;
197
197
this . preload_requests . push ( img ) ;
198
198
}
199
199
}
You can’t perform that action at this time.
0 commit comments