@@ -149,6 +149,8 @@ const IWSY = (playerElement, scriptObject) => {
149
149
150
150
// Set the content of one or more blocks
151
151
const setcontent = step => {
152
+ const imagesToLoad = [ ] ;
153
+ const imagesLoading = [ ] ;
152
154
let continueFlag = true ;
153
155
for ( const item of step . blocks )
154
156
{
@@ -165,7 +167,6 @@ const IWSY = (playerElement, scriptObject) => {
165
167
const converted = converter . makeHtml ( text . content . split ( `%0a` ) . join ( `\n` ) ) ;
166
168
const tag = converted . match ( / d a t a - s l i d e = " ( [ \w - _ . ] * ) " / ) ;
167
169
if ( tag ) {
168
- const imagesLoading = [ ] ;
169
170
for ( const vfx of script . vfx ) {
170
171
if ( vfx . name === tag [ 1 ] ) {
171
172
vfx . container = block . textPanel ;
@@ -192,25 +193,12 @@ const IWSY = (playerElement, scriptObject) => {
192
193
break ;
193
194
}
194
195
} else {
196
+ vfx . block = block ;
195
197
block . vfx . push ( vfx ) ;
196
198
continueFlag = false ;
197
199
block . textPanel . innerHTML = converted ;
198
- const image = new Image ( ) ;
199
- vfx . image = image ;
200
- image . id = vfx . name ;
201
- image . src = vfx . url ;
202
- image . addEventListener ( `load` , ( ) => {
203
- initImage ( vfx ) ;
204
- const index = imagesLoading . indexOf ( image ) ;
205
- if ( index > - 1 ) {
206
- imagesLoading . splice ( index , 1 ) ;
207
- }
208
- if ( imagesLoading . length === 0 ) {
209
- step . next ( ) ;
210
- }
211
- } ) ;
212
- imagesLoading . push ( image ) ;
213
- block . textPanel . appendChild ( image ) ;
200
+ imagesToLoad . push ( vfx ) ;
201
+ imagesLoading . push ( vfx ) ;
214
202
}
215
203
break ;
216
204
}
@@ -228,6 +216,26 @@ const IWSY = (playerElement, scriptObject) => {
228
216
}
229
217
}
230
218
}
219
+ for ( const vfx of imagesToLoad ) {
220
+ const image = new Image ( ) ;
221
+ vfx . image = image ;
222
+ image . vfx = vfx ;
223
+ image . id = vfx . name ;
224
+ image . src = vfx . url ;
225
+ image . addEventListener ( `load` , ( event ) => {
226
+ const image = event . target ;
227
+ const vfx = image . vfx ;
228
+ initImage ( vfx ) ;
229
+ const index = imagesLoading . indexOf ( vfx ) ;
230
+ if ( index > - 1 ) {
231
+ imagesLoading . splice ( index , 1 ) ;
232
+ }
233
+ if ( imagesLoading . length === 0 ) {
234
+ step . next ( ) ;
235
+ }
236
+ } ) ;
237
+ vfx . block . textPanel . appendChild ( image ) ;
238
+ }
231
239
if ( continueFlag ) {
232
240
step . next ( ) ;
233
241
}
@@ -468,9 +476,13 @@ const IWSY = (playerElement, scriptObject) => {
468
476
image . style . height = `${ vfx . h2 } px` ;
469
477
image . style . left = `${ vfx . xoff2 } px` ;
470
478
image . style . top = `${ vfx . yoff2 } px` ;
471
- if ( vfx . then ) {
472
- vfx . then ( ) ;
473
- }
479
+ // if (!vfx.continueFlag) {
480
+ // if (script.runMode === `manual`) {
481
+ // enterManualMode(vfx.step);
482
+ // } else {
483
+ // vfx.step.next();
484
+ // }
485
+ // }
474
486
}
475
487
} ;
476
488
@@ -485,15 +497,6 @@ const IWSY = (playerElement, scriptObject) => {
485
497
step . vfx = [ ] ;
486
498
}
487
499
step . vfx . push ( item ) ;
488
- vfx . then = ( ) => {
489
- const index = step . vfx . indexOf ( item ) ;
490
- if ( index > - 1 ) {
491
- step . vfx . splice ( index , 1 ) ;
492
- }
493
- if ( step . vfx . length === 0 && step . continue !== `yes` ) {
494
- step . next ( ) ;
495
- }
496
- } ;
497
500
delete ( vfx . start ) ;
498
501
if ( script . speed === `scan` ) {
499
502
vfx . image . style . width = `${ vfx . w2 } px` ;
@@ -502,6 +505,7 @@ const IWSY = (playerElement, scriptObject) => {
502
505
vfx . image . style . top = `${ vfx . yoff2 } px` ;
503
506
step . next ( ) ;
504
507
} else {
508
+ vfx . step = step ;
505
509
requestAnimationFrame ( timestamp => {
506
510
animatePanzoom ( timestamp , vfx ) ;
507
511
} ) ;
@@ -516,21 +520,24 @@ const IWSY = (playerElement, scriptObject) => {
516
520
517
521
// Animate a block
518
522
const animate = step => {
519
- let continueFlag = true ;
523
+ // let continueFlag = true;
520
524
for ( const block of script . blocks ) {
521
525
if ( block . defaults . name === step . block ) {
522
526
for ( const vfx of block . vfx ) {
523
- continueFlag = step . continue === `yes` ;
527
+ // continueFlag = step.continue === `yes`;
524
528
startVFX ( step , vfx ) ;
525
529
}
526
530
break ;
527
531
}
528
532
}
529
- if ( script . runMode === `manual` ) {
530
- enterManualMode ( step ) ;
531
- } else if ( continueFlag ) {
532
- step . next ( ) ;
533
- }
533
+ // if (script.runMode === `manual`) {
534
+ // enterManualMode(step);
535
+ // } else if (continueFlag) {
536
+ // step.next();
537
+ // }
538
+
539
+ // An animation is not a transition, so move on immediately
540
+ step . next ( ) ;
534
541
} ;
535
542
536
543
// Run a pan-zoom (for testing animations)
@@ -1139,8 +1146,8 @@ const IWSY = (playerElement, scriptObject) => {
1139
1146
script . labels [ step . label ] = index ;
1140
1147
}
1141
1148
if ( index < script . steps . length - 1 ) {
1142
- const nextStep = script . steps [ step . index + 1 ] ;
1143
1149
step . next = ( ) => {
1150
+ const nextStep = script . steps [ step . index + 1 ] ;
1144
1151
if ( script . scanFinished ) {
1145
1152
script . scanFinished = false ;
1146
1153
} else {
@@ -1355,7 +1362,7 @@ const IWSY = (playerElement, scriptObject) => {
1355
1362
const run = ( mode , startMode , then ) => {
1356
1363
try {
1357
1364
player . innerHTML = `` ;
1358
- homeScript = JSON . parse ( JSON . stringify ( script ) ) ;
1365
+ // homeScript = JSON.parse(JSON.stringify(script));
1359
1366
afterRun = then ;
1360
1367
initScript ( ) ;
1361
1368
if ( mode === `fullscreen` ) {
0 commit comments