( pct )
| 655 | // is the UI counterpart to this). It is a semi-internal API and intentionally not |
| 656 | // documented in DOCUMENTATION.md. |
| 657 | var swipe = function( pct ) { |
| 658 | if ( Math.abs( pct ) > 1 ) { |
| 659 | return; |
| 660 | } |
| 661 | |
| 662 | // Prepare & execute the preStepLeave event |
| 663 | var event = { target: activeStep, detail: {} }; |
| 664 | event.detail.swipe = pct; |
| 665 | |
| 666 | // Will be ignored within swipe animation, but just in case a plugin wants to read this, |
| 667 | // humor them |
| 668 | event.detail.transitionDuration = config.transitionDuration; |
| 669 | var idx; // Needed by jshint |
| 670 | if ( pct < 0 ) { |
| 671 | idx = steps.indexOf( activeStep ) + 1; |
| 672 | event.detail.next = idx < steps.length ? steps[ idx ] : steps[ 0 ]; |
| 673 | event.detail.reason = "next"; |
| 674 | } else if ( pct > 0 ) { |
| 675 | idx = steps.indexOf( activeStep ) - 1; |
| 676 | event.detail.next = idx >= 0 ? steps[ idx ] : steps[ steps.length - 1 ]; |
| 677 | event.detail.reason = "prev"; |
| 678 | } else { |
| 679 | |
| 680 | // No move |
| 681 | return; |
| 682 | } |
| 683 | if ( execPreStepLeavePlugins( event ) === false ) { |
| 684 | |
| 685 | // If a preStepLeave plugin wants to abort the transition, don't animate a swipe |
| 686 | // For stop, this is probably ok. For substep, the plugin it self might want to do |
| 687 | // some animation, but that's not the current implementation. |
| 688 | return false; |
| 689 | } |
| 690 | var nextElement = event.detail.next; |
| 691 | |
| 692 | var nextStep = stepsData[ "impress-" + nextElement.id ]; |
| 693 | |
| 694 | // If the same step is re-selected, force computing window scaling, |
| 695 | var nextScale = nextStep.scale * windowScale; |
| 696 | var k = Math.abs( pct ); |
| 697 | |
| 698 | var interpolatedStep = { |
| 699 | translate: { |
| 700 | x: interpolate( currentState.translate.x, -nextStep.translate.x, k ), |
| 701 | y: interpolate( currentState.translate.y, -nextStep.translate.y, k ), |
| 702 | z: interpolate( currentState.translate.z, -nextStep.translate.z, k ) |
| 703 | }, |
| 704 | rotate: { |
| 705 | x: interpolate( currentState.rotate.x, -nextStep.rotate.x, k ), |
| 706 | y: interpolate( currentState.rotate.y, -nextStep.rotate.y, k ), |
| 707 | z: interpolate( currentState.rotate.z, -nextStep.rotate.z, k ), |
| 708 | |
| 709 | // Unfortunately there's a discontinuity if rotation order changes. Nothing I |
| 710 | // can do about it? |
| 711 | order: k < 0.7 ? currentState.rotate.order : nextStep.rotate.order |
| 712 | }, |
| 713 | scale: interpolate( currentState.scale * windowScale, nextScale, k ) |
| 714 | }; |
nothing calls this directly
no test coverage detected