@@ -17,53 +17,36 @@ function useDeck(
1717  function  reducer ( state ,  action )  { 
1818    switch  ( action . type )  { 
1919      case  'NEXT_SLIDE' :
20+         return  { 
21+           ...state , 
22+           currentSlide : state . currentSlide  +  1 , 
23+           currentSlideElement : 0 , 
24+           immediate : false , 
25+           immediateElement : false , 
26+           reverseDirection : false 
27+         } ; 
2028      case  'NEXT_SLIDE_IMMEDIATE' :
21-         // If next slide is going to be greater than number 
22-         // of slides, if it is looping then go to initial state 
23-         // if not then stop 
24-         if  ( state . currentSlide  +  1  ===  numSlides )  { 
25-           if  ( looping )  { 
26-             return  action . type  ===  'NEXT_SLIDE_IMMEDIATE' 
27-               ? { 
28-                   ...initialState , 
29-                   immediate : true , 
30-                   reverseDirection : false , 
31-                   immediateElement : false 
32-                 } 
33-               : initialState ; 
34-           } 
35-           return  {  ...state  } ; 
36-         } 
37-         return  action . type  ===  'NEXT_SLIDE_IMMEDIATE' 
38-           ? { 
39-               currentSlide : state . currentSlide  +  1 , 
40-               immediate : true , 
41-               currentSlideElement : 0 , 
42-               immediateElement : false , 
43-               reverseDirection : false 
44-             } 
45-           : { 
46-               currentSlide : state . currentSlide  +  1 , 
47-               currentSlideElement : 0 , 
48-               immediate : false , 
49-               immediateElement : false , 
50-               reverseDirection : false 
51-             } ; 
29+         return  { 
30+           ...state , 
31+           currentSlide : state . currentSlide  +  1 , 
32+           immediate : true , 
33+           currentSlideElement : 0 , 
34+           immediateElement : false , 
35+           reverseDirection : false 
36+         } ; 
37+       case  'GO_TO_SLIDE' : { 
38+         return  { 
39+           ...state , 
40+           currentSlideElement : 0 , 
41+           currentSlide : action . payload . slideNumber , 
42+           immediate : action . payload . immediate , 
43+           immediateElement : false , 
44+           reverseDirection : action . payload . reverseDirection 
45+         } ; 
46+       } 
5247      case  'PREV_SLIDE' :
53-         // If current slide is initial slide then if looping go 
54-         // to last slide else stop 
55-         if  ( state . currentSlide  ===  initialState . currentSlide )  { 
56-           if  ( looping )  { 
57-             return  { 
58-               currentSlide : numSlides  -  1 , 
59-               currentSlideElement : Math . max ( slideElementMap [ numSlides  -  1 ] ,  0 ) , 
60-               immediate : ! ! animationsWhenGoingBack , 
61-               reverseDirection : true 
62-             } ; 
63-           } 
64-           return  {  ...state  } ; 
65-         } 
6648        return  { 
49+           ...state , 
6750          currentSlide : state . currentSlide  -  1 , 
6851          currentSlideElement : Math . max ( 
6952            slideElementMap [ state . currentSlide  -  1 ] , 
@@ -73,37 +56,39 @@ function useDeck(
7356          immediateElement : true , 
7457          reverseDirection : true 
7558        } ; 
76-       case  'NEXT_SLIDE_ELEMENT' :  { 
59+       case  'NEXT_SLIDE_ELEMENT' :
7760        return  { 
7861          ...state , 
7962          currentSlideElement : state . currentSlideElement  +  1 , 
8063          immediateElement : false , 
8164          reverseDirection : false 
8265        } ; 
83-       } 
84-       case  'NEXT_SLIDE_ELEMENT_IMMEDIATE' : { 
66+       case  'NEXT_SLIDE_ELEMENT_IMMEDIATE' :
8567        return  { 
8668          ...state , 
8769          currentSlideElement : state . currentSlideElement  +  1 , 
8870          immediateElement : true , 
8971          reverseDirection : false 
9072        } ; 
91-       } 
92-       case  'PREV_SLIDE_ELEMENT' : { 
73+       case  'PREV_SLIDE_ELEMENT' :
9374        return  { 
9475          ...state , 
9576          currentSlideElement : Math . max ( state . currentSlideElement  -  1 ,  0 ) , 
9677          immediateElement : false , 
9778          reverseDirection : true 
9879        } ; 
99-       } 
100-       case  'PREV_SLIDE_ELEMENT_IMMEDIATE' : { 
80+       case  'PREV_SLIDE_ELEMENT_IMMEDIATE' :
10181        return  { 
10282          ...state , 
10383          currentSlideElement : Math . max ( state . currentSlideElement  -  1 ,  0 ) , 
10484          immediateElement : true , 
10585          reverseDirection : true 
10686        } ; 
87+       case  'SET_PRESENTER_MODE' : { 
88+         return  { 
89+           ...state , 
90+           presenterMode : action . payload . presenterMode 
91+         } ; 
10792      } 
10893      default :
10994        return  {  ...state  } ; 
0 commit comments