Skip to content

Commit

Permalink
Trigger event on substep enter (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
willamesoares authored and henrikingo committed Apr 25, 2019
1 parent c6d468e commit c61403d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions js/impress.js
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@
reloadTimeout( event );
}, false );

document.addEventListener( "impress:substep:stepleaveaborted", function( event ) {
document.addEventListener( "impress:substep:enter", function( event ) {
reloadTimeout( event );
}, false );

Expand Down Expand Up @@ -3957,10 +3957,13 @@
if ( el ) {

// Send a message to others, that we aborted a stepleave event.
// Autoplay will reload itself from this, as there won't be a stepenter event now.
triggerEvent( step, "impress:substep:stepleaveaborted",
{ reason: "next", substep: el } );

// Autoplay uses this for reloading itself
triggerEvent( step, "impress:substep:enter",
{ reason: "next", substep: el } );

// Returning false aborts the stepleave event
return false;
}
Expand All @@ -3970,6 +3973,10 @@
if ( el ) {
triggerEvent( step, "impress:substep:stepleaveaborted",
{ reason: "prev", substep: el } );

triggerEvent( step, "impress:substep:leave",
{ reason: "prev", substep: el } );

return false;
}
}
Expand Down Expand Up @@ -4032,7 +4039,6 @@

} )( document, window );


/**
* Support for swipe and tap on touch devices
*
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
reloadTimeout( event );
}, false );

document.addEventListener( "impress:substep:stepleaveaborted", function( event ) {
document.addEventListener( "impress:substep:enter", function( event ) {
reloadTimeout( event );
}, false );

Expand Down
10 changes: 8 additions & 2 deletions src/plugins/substep/substep.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
if ( el ) {

// Send a message to others, that we aborted a stepleave event.
// Autoplay will reload itself from this, as there won't be a stepenter event now.
triggerEvent( step, "impress:substep:stepleaveaborted",
{ reason: "next", substep: el } );

// Autoplay uses this for reloading itself
triggerEvent( step, "impress:substep:enter",
{ reason: "next", substep: el } );

// Returning false aborts the stepleave event
return false;
}
Expand All @@ -47,6 +50,10 @@
if ( el ) {
triggerEvent( step, "impress:substep:stepleaveaborted",
{ reason: "prev", substep: el } );

triggerEvent( step, "impress:substep:leave",
{ reason: "prev", substep: el } );

return false;
}
}
Expand Down Expand Up @@ -108,4 +115,3 @@
}, false );

} )( document, window );

0 comments on commit c61403d

Please sign in to comment.