( el, duration, reason, origEvent )
| 428 | // preStepLeave plugins. |
| 429 | // `origEvent` may contain event that caused the call to goto, such as a key press event |
| 430 | var goto = function( el, duration, reason, origEvent ) { |
| 431 | reason = reason || "goto"; |
| 432 | origEvent = origEvent || null; |
| 433 | |
| 434 | if ( !initialized ) { |
| 435 | return false; |
| 436 | } |
| 437 | |
| 438 | // Re-execute initAllSteps for each transition. This allows to edit step attributes |
| 439 | // dynamically, such as change their coordinates, or even remove or add steps, and have |
| 440 | // that change apply when goto() is called. |
| 441 | initAllSteps(); |
| 442 | |
| 443 | if ( !( el = getStep( el ) ) ) { |
| 444 | return false; |
| 445 | } |
| 446 | |
| 447 | // Sometimes it's possible to trigger focus on first link with some keyboard action. |
| 448 | // Browser in such a case tries to scroll the page to make this element visible |
| 449 | // (even that body overflow is set to hidden) and it breaks our careful positioning. |
| 450 | // |
| 451 | // So, as a lousy (and lazy) workaround we will make the page scroll back to the top |
| 452 | // whenever slide is selected |
| 453 | // |
| 454 | // If you are reading this and know any better way to handle it, I'll be glad to hear |
| 455 | // about it! |
| 456 | window.scrollTo( 0, 0 ); |
| 457 | |
| 458 | var step = stepsData[ "impress-" + el.id ]; |
| 459 | duration = ( duration !== undefined ? duration : step.transitionDuration ); |
| 460 | |
| 461 | // If we are in fact moving to another step, start with executing the registered |
| 462 | // preStepLeave plugins. |
| 463 | if ( activeStep && activeStep !== el ) { |
| 464 | var event = { target: activeStep, detail: {} }; |
| 465 | event.detail.next = el; |
| 466 | event.detail.transitionDuration = duration; |
| 467 | event.detail.reason = reason; |
| 468 | if ( origEvent ) { |
| 469 | event.origEvent = origEvent; |
| 470 | } |
| 471 | |
| 472 | if ( execPreStepLeavePlugins( event ) === false ) { |
| 473 | |
| 474 | // PreStepLeave plugins are allowed to abort the transition altogether, by |
| 475 | // returning false. |
| 476 | // see stop and substep plugins for an example of doing just that |
| 477 | return false; |
| 478 | } |
| 479 | |
| 480 | // Plugins are allowed to change the detail values |
| 481 | el = event.detail.next; |
| 482 | step = stepsData[ "impress-" + el.id ]; |
| 483 | duration = event.detail.transitionDuration; |
| 484 | } |
| 485 | |
| 486 | if ( activeStep ) { |
| 487 | activeStep.classList.remove( "active" ); |
no test coverage detected