@@ -3,13 +3,14 @@ import {getTrackCSS, getTrackLeft, getTrackAnimateCSS} from './trackHelper';
3
3
import helpers from './helpers' ;
4
4
import assign from 'object-assign' ;
5
5
import ReactDOM from 'react-dom' ;
6
+ import { siblingDirection } from '../utils/trackUtils'
6
7
7
8
var EventHandlers = {
8
9
// Event handler for previous and next
9
10
// gets called if slide is changed via arrows or dots but not swiping/dragging
10
11
changeSlide : function ( options ) {
11
12
var indexOffset , previousInt , slideOffset , unevenOffset , targetSlide ;
12
- const { slidesToScroll, slidesToShow} = this . props
13
+ const { slidesToScroll, slidesToShow, centerMode , rtl } = this . props
13
14
const { slideCount, currentSlide} = this . state
14
15
unevenOffset = ( slideCount % slidesToScroll !== 0 ) ;
15
16
indexOffset = unevenOffset ? 0 : ( slideCount - currentSlide ) % slidesToScroll ;
@@ -27,19 +28,32 @@ var EventHandlers = {
27
28
if ( this . props . lazyLoad && ! this . props . infinite ) {
28
29
targetSlide = ( ( currentSlide + slidesToScroll ) % slideCount ) + indexOffset ;
29
30
}
30
- } else if ( options . message === 'dots' || options . message === 'children' ) {
31
+ } else if ( options . message === 'dots' ) {
31
32
// Click on dots
32
- targetSlide = options . index * options . slidesToScroll ;
33
+ targetSlide = options . index * options . slidesToScroll
33
34
if ( targetSlide === options . currentSlide ) {
34
35
return ;
35
36
}
37
+ } else if ( options . message === 'children' ) {
38
+ // Click on the slides
39
+ targetSlide = options . index
40
+ if ( targetSlide === options . currentSlide ) {
41
+ return
42
+ }
43
+ if ( this . props . infinite ) {
44
+ let direction = siblingDirection ( { currentSlide, targetSlide, slidesToShow, centerMode, slideCount, rtl} )
45
+ if ( targetSlide > options . currentSlide && direction === 'left' ) {
46
+ targetSlide = targetSlide - slideCount
47
+ } else if ( targetSlide < options . currentSlide && direction === 'right' ) {
48
+ targetSlide = targetSlide + slideCount
49
+ }
50
+ }
36
51
} else if ( options . message === 'index' ) {
37
52
targetSlide = Number ( options . index ) ;
38
53
if ( targetSlide === options . currentSlide ) {
39
54
return ;
40
55
}
41
56
}
42
-
43
57
this . slideHandler ( targetSlide ) ;
44
58
} ,
45
59
@@ -66,7 +80,8 @@ var EventHandlers = {
66
80
swipeStart : function ( e ) {
67
81
var touches , posX , posY ;
68
82
69
- if ( ( this . props . swipe === false ) || ( 'ontouchend' in document && this . props . swipe === false ) ) {
83
+ // the condition after or looked redundant
84
+ if ( ( this . props . swipe === false ) ) { // || ('ontouchend' in document && this.props.swipe === false)) {
70
85
return ;
71
86
} else if ( this . props . draggable === false && e . type . indexOf ( 'mouse' ) !== - 1 ) {
72
87
return ;
@@ -112,7 +127,7 @@ var EventHandlers = {
112
127
touchObject . swipeLength = Math . round ( Math . sqrt ( Math . pow ( touchObject . curX - touchObject . startX , 2 ) ) ) ;
113
128
var verticalSwipeLength = Math . round ( Math . sqrt ( Math . pow ( touchObject . curY - touchObject . startY , 2 ) ) ) ;
114
129
115
- if ( ! this . props . verticalSwiping && ! this . state . swiping && verticalSwipeLength > 4 ) {
130
+ if ( ! this . props . verticalSwiping && ! this . state . swiping && verticalSwipeLength > 10 ) {
116
131
this . setState ( {
117
132
scrolling : true
118
133
} )
@@ -172,7 +187,7 @@ var EventHandlers = {
172
187
173
188
if ( Math . abs ( touchObject . curX - touchObject . startX ) < Math . abs ( touchObject . curY - touchObject . startY ) * 0.8 )
174
189
{ return ; }
175
- if ( touchObject . swipeLength > 4 ) {
190
+ if ( touchObject . swipeLength > 10 ) {
176
191
this . setState ( {
177
192
swiping : true
178
193
} )
@@ -301,21 +316,22 @@ var EventHandlers = {
301
316
case 'down' :
302
317
newSlide = this . state . currentSlide + this . getSlideCount ( ) ;
303
318
slideCount = this . props . swipeToSlide ? this . checkNavigable ( newSlide ) : newSlide ;
304
- this . state . currentDirection = 0 ;
319
+ // this.state.currentDirection = 0; // critical: change this line with setState statement
320
+ this . setState ( { currentDirection : 0 } ) // unverified fix of above line
305
321
break ;
306
322
307
323
case 'right' :
308
324
case 'up' :
309
325
newSlide = this . state . currentSlide - this . getSlideCount ( ) ;
310
326
slideCount = this . props . swipeToSlide ? this . checkNavigable ( newSlide ) : newSlide ;
311
- this . state . currentDirection = 1 ;
327
+ // this.state.currentDirection = 1; // critical: change this line with setState statement
328
+ this . setState ( { currentDirection : 1 } ) // unverified fix of above line
312
329
break ;
313
330
314
331
default :
315
332
slideCount = this . state . currentSlide ;
316
333
317
334
}
318
-
319
335
this . slideHandler ( slideCount ) ;
320
336
} else {
321
337
// Adjust the track back to it's original position.
0 commit comments