@@ -225,14 +225,18 @@ const IWSY = (playerElement, text) => {
225
225
const ratio = 0.5 - Math . cos ( Math . PI * animStep / animSteps ) / 2 ;
226
226
for ( const block of stepBlocks )
227
227
{
228
- block . element . style . opacity = upDown ? ratio : 1.0 - ratio ;
228
+ if ( block . element ) {
229
+ block . element . style . opacity = upDown ? ratio : 1.0 - ratio ;
230
+ }
229
231
}
230
232
animStep ++ ;
231
233
} else {
232
234
for ( const block of stepBlocks )
233
235
{
234
- block . element . style . opacity = upDown ? 1 : 0 ;
235
- block . element . style . display = upDown ? `block` :`none` ;
236
+ if ( block . element ) {
237
+ block . element . style . opacity = upDown ? 1 : 0 ;
238
+ block . element . style . display = upDown ? `block` :`none` ;
239
+ }
236
240
}
237
241
clearInterval ( interval ) ;
238
242
if ( ! continueFlag ) {
@@ -762,7 +766,7 @@ const IWSY = (playerElement, text) => {
762
766
removeStyles ( ) ;
763
767
for ( const block of script . blocks ) {
764
768
const element = block . element ;
765
- if ( typeof element !== `undefined` ) {
769
+ if ( element != null && typeof element !== `undefined` ) {
766
770
removeElement ( element ) ;
767
771
block . element = null ;
768
772
}
@@ -818,6 +822,9 @@ const IWSY = (playerElement, text) => {
818
822
819
823
// Process a single step
820
824
const doStep = step => {
825
+ if ( ! step ) {
826
+ return ;
827
+ }
821
828
if ( step . title ) {
822
829
console . log ( `Step ${ step . index } : ${ step . title } ` ) ;
823
830
} else {
@@ -923,7 +930,7 @@ const IWSY = (playerElement, text) => {
923
930
} ;
924
931
925
932
// Run the presentation
926
- const run = ( mode , then ) => {
933
+ const run = ( mode , startMode , then ) => {
927
934
script . then = then ;
928
935
initScript ( ) ;
929
936
if ( mode === `fullscreen` ) {
@@ -934,10 +941,24 @@ const IWSY = (playerElement, text) => {
934
941
document . onfullscreenchange = ( ) => {
935
942
if ( document . fullscreenElement ) {
936
943
player = document . fullscreenElement ;
937
- script . runMode = `manual` ;
938
- enterManualMode ( null ) ;
944
+ script . nextStep = script . steps [ 0 ] ;
945
+ switch ( startMode ) {
946
+ case `auto` :
947
+ script . runMode = `auto` ;
948
+ release ( ) ;
949
+ break ;
950
+ case `manual` :
951
+ script . runMode = `manual` ;
952
+ release ( ) ;
953
+ break ;
954
+ case `wait` :
955
+ script . runMode = `manual` ;
956
+ enterManualMode ( null ) ;
957
+ break ;
958
+ }
939
959
} else {
940
960
player = playerElement ;
961
+ script . stop = true ;
941
962
}
942
963
} ;
943
964
}
0 commit comments