File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,18 @@ exports[`<Manager /> should render correctly. 1`] = `
110110 lastSlideIndex = { 0 }
111111 print = { false }
112112 slideIndex = { 0 }
113+ slideReference = {
114+ Array [
115+ Object {
116+ " id" : 0 ,
117+ " rootIndex" : 0 ,
118+ },
119+ Object {
120+ " id" : 1 ,
121+ " rootIndex" : 1 ,
122+ },
123+ ]
124+ }
113125 transition = {
114126 Array [
115127 " zoom" ,
@@ -655,6 +667,24 @@ exports[`<Manager /> should render with slideset slides 1`] = `
655667 lastSlideIndex = { 1 }
656668 print = { false }
657669 slideIndex = { 1 }
670+ slideReference = {
671+ Array [
672+ Object {
673+ " id" : 0 ,
674+ " rootIndex" : 0 ,
675+ },
676+ Object {
677+ " id" : 1 ,
678+ " rootIndex" : 1 ,
679+ " setIndex" : 0 ,
680+ },
681+ Object {
682+ " id" : 2 ,
683+ " rootIndex" : 1 ,
684+ " setIndex" : 1 ,
685+ },
686+ ]
687+ }
658688 transition = { Array []}
659689 transitionDuration = { 500 }
660690 >
Original file line number Diff line number Diff line change @@ -462,6 +462,7 @@ export default class Manager extends Component {
462462 transitionDuration : ( slide . props . transition || { } ) . transitionDuration
463463 ? slide . props . transitionDuration
464464 : this . props . transitionDuration ,
465+ slideReference : this . state . slideReference
465466 } ) ;
466467 }
467468 render ( ) {
Original file line number Diff line number Diff line change 11/*eslint new-cap:0, max-statements:0*/
22import React , { cloneElement } from 'react' ;
33import { VictoryAnimation } from 'victory-core' ;
4+ import findIndex from 'lodash/findIndex' ;
45
56/**
67 * Decorator for adding Spectacle transition support
@@ -36,8 +37,8 @@ const Transitionable = function (target) {
3637
3738 transitionDirection ( ) {
3839 const { slideIndex, lastSlideIndex } = this . props ;
39- const slide = this . context . store . getState ( ) . route . slide || 0 ;
40- return this . state . reverse ? slideIndex > slide : slideIndex > lastSlideIndex ;
40+ const routeSlideIndex = this . _getRouteSlideIndex ( ) ;
41+ return this . state . reverse ? slideIndex > routeSlideIndex : slideIndex > lastSlideIndex ;
4142 } ,
4243
4344 getTransitionStyles ( ) {
@@ -68,7 +69,16 @@ const Transitionable = function (target) {
6869 }
6970
7071 return { ...styles , transform : transformValue } ;
71- }
72+ } ,
73+
74+ _getRouteSlideIndex ( ) {
75+ const { slideReference } = this . props ;
76+ const slide = this . context . store . getState ( ) . route . slide ;
77+ const slideIndex = findIndex ( slideReference , reference => {
78+ return slide === String ( reference . id ) ;
79+ } ) ;
80+ return Math . max ( 0 , slideIndex ) ;
81+ } ,
7282 } ;
7383
7484 Object . assign ( target . prototype , transitionable ) ;
You can’t perform that action at this time.
0 commit comments