22
33( function ( )
44{
5+ var carousel , totalDuration , totalBack , currentPos , startTime ;
56
6- var carousel , total_duration , total_back , currentPos , startTime ;
7-
8- function gotoSlideByIndex ( i , without_animation )
7+ function gotoSlideByIndex ( i , withoutAnimation )
98{
109 var isBoundary ;
1110
@@ -19,7 +18,7 @@ function gotoSlideByIndex(i, without_animation)
1918
2019 changeActiveSlideTo ( i ) ;
2120
22- total_duration = Math . max ( carousel . options . duration
21+ totalDuration = Math . max ( carousel . options . duration
2322 - ( ( 1920 / window . outerWidth ) * Math . abs ( carousel . vars . velocity ) *
2423 9 * ( carousel . options . duration / 230 )
2524 )
@@ -30,11 +29,11 @@ function gotoSlideByIndex(i, without_animation)
3029 , 50
3130 ) ;
3231
33- total_back = ( isBoundary ? ( ( Math . abs ( carousel . vars . velocity ) * 250 ) / window . outerWidth ) : 0 ) ;
32+ totalBack = ( isBoundary ? ( ( Math . abs ( carousel . vars . velocity ) * 250 ) / window . outerWidth ) : 0 ) ;
3433 currentPos = getTranslate3d ( carousel . $el ) . x ;
3534 carousel . currentLandPos = getPositionByIndex ( i ) ;
3635
37- if ( without_animation ) {
36+ if ( withoutAnimation ) {
3837 setTranslate3d ( carousel . $el , getPositionByIndex ( i ) ) ;
3938 return ;
4039 }
@@ -49,9 +48,9 @@ function getLandingSlideIndex(x)
4948{
5049 for ( var i = 0 ; i < carousel . $el . children . length ; i ++ ) {
5150 if ( carousel . getSlidesWidth ( false , i ) + carousel . $el . children [ i ] . offsetWidth / 2 -
52- carousel . $el . children [ i ] . offsetWidth * carousel . options . pan_threshold * carousel . vars . direction - getPositionByIndex ( 0 ) > x ) {
51+ carousel . $el . children [ i ] . offsetWidth * carousel . options . panThreshold * carousel . vars . direction - getPositionByIndex ( 0 ) > x ) {
5352
54- if ( ! carousel . options . one_item )
53+ if ( ! carousel . options . oneItem )
5554 return i ;
5655
5756 else {
@@ -62,7 +61,7 @@ function getLandingSlideIndex(x)
6261 }
6362 }
6463 }
65- return carousel . options . one_item ? carousel . vars . currentIndex + 1 : carousel . $el . children . length - 1 ;
64+ return carousel . options . oneItem ? carousel . vars . currentIndex + 1 : carousel . $el . children . length - 1 ;
6665}
6766
6867function isOutBoundaries ( )
@@ -88,25 +87,25 @@ function getPositionByIndex(i)
8887{
8988 const slidesWidth = carousel . getSlidesWidth ( false , i ) ;
9089 const containerMinusSlideWidth = carousel . $el . parentElement . offsetWidth - carousel . $el . children [ i ] . offsetWidth ;
91- return - ( slidesWidth - ( containerMinusSlideWidth / ( carousel . options . left_sided ? 1 : 2 ) ) ) ;
90+ return - ( slidesWidth - ( containerMinusSlideWidth / ( carousel . options . leftSided ? 1 : 2 ) ) ) ;
9291}
9392
9493function animationRepeat ( )
9594{
9695 var currentTime = Date . now ( ) - startTime ;
9796
98- if ( carousel . options . left_sided ) {
97+ if ( carousel . options . leftSided ) {
9998 carousel . currentLandPos = clamp ( - ( carousel . vars . allSlidesWidth - carousel . $el . parent ( ) . width ( ) ) , 0 , carousel . currentLandPos ) ;
10099 }
101100
102101 carousel . $el . dispatchEvent ( new Event ( "carouselChangePos" ) ) ;
103102
104- const x = currentPos - easeOutBack ( currentTime , 0 , currentPos - carousel . currentLandPos , total_duration , total_back ) ;
103+ const x = currentPos - easeOutBack ( currentTime , 0 , currentPos - carousel . currentLandPos , totalDuration , totalBack ) ;
105104 setTranslate3d ( carousel . $el , x ) ;
106105
107106 // to understand easings refer to: http://upshots.org/actionscript/jsas-understanding-easing
108107
109- if ( currentTime >= total_duration ) {
108+ if ( currentTime >= totalDuration ) {
110109 setTranslate3d ( carousel . $el , carousel . currentLandPos ) ;
111110 return ;
112111 }
@@ -171,7 +170,7 @@ function slideout()
171170
172171 let isSwipeDirectionUp ;
173172
174- carousel . $el . end_animation = true ;
173+ carousel . $el . endAnimation = true ;
175174
176175 carousel . $el . savedSlideIndex = 0 ;
177176
@@ -232,7 +231,7 @@ function slideout()
232231
233232 enableOpacity = true ;
234233
235- carousel . $el . end_animation = false ;
234+ carousel . $el . endAnimation = false ;
236235
237236 swipeOutGlobalID = requestAnimationFrame ( swipeOutAnimation ) ;
238237 } ;
@@ -261,7 +260,7 @@ function slideout()
261260 unwrapElements ( itemslideMoveElement . children ) ;
262261 }
263262
264- carousel . $el . end_animation = true ;
263+ carousel . $el . endAnimation = true ;
265264 currentTime = 0 ;
266265
267266 return ;
@@ -324,7 +323,7 @@ function slideout()
324323
325324 settings . duration = durationSave ;
326325 currentTime = 0 ;
327- carousel . $el . end_animation = true ;
326+ carousel . $el . endAnimation = true ;
328327
329328 return ;
330329 }
@@ -389,19 +388,19 @@ function createEvents()
389388 }
390389}
391390
392- var swipeStartTime , isDown , startPreventDefault , startPointX , startPointY , vertical_pan = false ,
393- horizontal_pan ;
391+ var swipeStartTime , isDown , startPreventDefault , startPointX , startPointY , verticalPan = false ,
392+ horizontalPan ;
394393
395394var verticalSlideFirstTimeCount ;
396395
397396function getVerticalPan ( )
398397{
399- return vertical_pan
398+ return verticalPan
400399}
401400
402401function touchstart ( e )
403402{
404- if ( e . target . getAttribute ( "no-drag" ) === "true" || ! carousel . $el . end_animation ) {
403+ if ( e . target . getAttribute ( "no-drag" ) === "true" || ! carousel . $el . endAnimation ) {
405404 return ;
406405 }
407406
@@ -422,8 +421,8 @@ function touchstart(e)
422421 startPointX = touch . pageX ;
423422 startPointY = touch . pageY ;
424423
425- vertical_pan = false ;
426- horizontal_pan = false ;
424+ verticalPan = false ;
425+ horizontalPan = false ;
427426
428427 carousel . $el . savedSlide = e . target ;
429428
@@ -457,7 +456,7 @@ function mousemove(e)
457456 else {
458457 touch = e ;
459458
460- if ( ! carousel . options . disable_slide && ! carousel . options . swipe_out ) {
459+ if ( ! carousel . options . disableSlide && ! carousel . options . swipeOut ) {
461460 e . preventDefault ( ) ;
462461 }
463462 }
@@ -499,31 +498,31 @@ function mousemove(e)
499498
500499 if ( Math . abs ( touch . pageX - startPointX ) > 6 )
501500 {
502- if ( ! vertical_pan && carousel . $el . end_animation ) {
503- horizontal_pan = true ;
501+ if ( ! verticalPan && carousel . $el . endAnimation ) {
502+ horizontalPan = true ;
504503 }
505504
506505 window . cancelAnimationFrame ( carousel . slidesGlobalID ) ;
507506
508507 }
509508
510509 if ( Math . abs ( touch . pageY - startPointY ) > 6 ) {
511- if ( ! horizontal_pan && carousel . $el . end_animation ) {
512- vertical_pan = true ;
510+ if ( ! horizontalPan && carousel . $el . endAnimation ) {
511+ verticalPan = true ;
513512 }
514513 }
515514
516- if ( horizontal_pan ) {
515+ if ( horizontalPan ) {
517516
518- if ( carousel . options . disable_slide ) {
517+ if ( carousel . options . disableSlide ) {
519518 return ;
520519 }
521520
522- if ( carousel . options . left_sided ) {
521+ if ( carousel . options . leftSided ) {
523522 carousel . currentLandPos = clamp ( - ( carousel . vars . allSlidesWidth - carousel . $el . parent ( ) . width ( ) ) , 0 , carousel . currentLandPos ) ;
524523 }
525524
526- vertical_pan = false ;
525+ verticalPan = false ;
527526
528527 setTranslate3d ( carousel . $el ,
529528 ( ( firstTime == 0 ) ? ( savedStartPt - startPointX + ( touch . pageX - savedStartPt ) / 4 ) : ( touch . pageX - startPointX ) )
@@ -533,7 +532,7 @@ function mousemove(e)
533532 carousel . $el . dispatchEvent ( new Event ( "carouselChangePos" ) ) ;
534533 carousel . $el . dispatchEvent ( new Event ( "carouselPan" ) ) ;
535534
536- } else if ( vertical_pan && carousel . options . swipe_out ) {
535+ } else if ( verticalPan && carousel . options . swipeOut ) {
537536 e . preventDefault ( ) ;
538537
539538 const slideOutWrap = document . querySelector ( ".itemslide_slideoutwrap" ) ;
@@ -566,13 +565,13 @@ function touchend(e)
566565 window . removeEventListener ( 'mousemove' , mousemove ) ;
567566 window . removeEventListener ( 'touchmove' , mousemove ) ;
568567
569- if ( vertical_pan && carousel . options . swipe_out ) {
570- vertical_pan = false ;
568+ if ( verticalPan && carousel . options . swipeOut ) {
569+ verticalPan = false ;
571570
572571 carousel . swipeOut ( ) ;
573572
574573 return ;
575- } else if ( carousel . $el . end_animation && ! carousel . options . disable_slide ) {
574+ } else if ( carousel . $el . endAnimation && ! carousel . options . disableSlide ) {
576575 var deltaTime = ( Date . now ( ) - swipeStartTime ) ;
577576 deltaTime ++ ;
578577 carousel . vars . velocity = - ( touch . pageX - startPointX ) / deltaTime ;
@@ -584,7 +583,7 @@ function touchend(e)
584583 }
585584
586585 carousel . vars . distanceFromStart = ( touch . pageX - startPointX ) * carousel . vars . direction * - 1 ;
587- var landingSlideIndex = getLandingSlideIndex ( carousel . vars . velocity * carousel . options . swipe_sensitivity - getTranslate3d ( carousel . $el ) . x ) ;
586+ var landingSlideIndex = getLandingSlideIndex ( carousel . vars . velocity * carousel . options . swipeSensitivity - getTranslate3d ( carousel . $el ) . x ) ;
588587
589588 if ( carousel . vars . distanceFromStart > 6 ) {
590589 gotoSlideByIndex ( landingSlideIndex ) ;
@@ -598,7 +597,7 @@ function touchend(e)
598597
599598 carousel . $el . dispatchEvent ( clickSlideEvent ) ;
600599
601- if ( carousel . $el . savedSlideIndex != carousel . vars . currentIndex && ! carousel . options . disable_clicktoslide ) {
600+ if ( carousel . $el . savedSlideIndex != carousel . vars . currentIndex && ! carousel . options . disableClickToSlide ) {
602601 e . preventDefault ( ) ;
603602 gotoSlideByIndex ( carousel . $el . savedSlideIndex ) ;
604603 }
@@ -661,7 +660,7 @@ create: function (instance, options, element) {
661660 carousel . $el = element ;
662661 carousel . options = options ;
663662
664- if ( carousel . options . parent_width ) {
663+ if ( carousel . options . parentWidth ) {
665664 element . style . width = element . parentElement . offsetWidth ;
666665 }
667666
@@ -686,7 +685,7 @@ create: function (instance, options, element) {
686685 } ;
687686
688687 carousel . adjustCarouselWidthIfNotDisabled = ( ) => {
689- if ( ! carousel . options . disable_autowidth ) {
688+ if ( ! carousel . options . disableAutoWidth ) {
690689 element . style . width = carousel . getSlidesWidth ( ) + 10 + "px" ;
691690 }
692691 } ;
@@ -695,25 +694,25 @@ create: function (instance, options, element) {
695694
696695 carousel . vars = {
697696 currentIndex : 0 ,
698- parent_width : carousel . options . parent_width ,
697+ parentWidth : carousel . options . parentWidth ,
699698 velocity : 0 ,
700699 slideHeight : element . children [ 0 ] . offsetHeight ,
701700 direction : 1 ,
702701 allSlidesWidth : getCurrentTotalWidth ( element ) ,
703702 instance : instance
704703 } ;
705704
706- element . end_animation = true ;
705+ element . endAnimation = true ;
707706
708- if ( carousel . options . swipe_out ) {
707+ if ( carousel . options . swipeOut ) {
709708 slideout ( carousel ) ;
710709 }
711710
712711 setTranslate3d ( element , 0 ) ;
713712 gotoSlideByIndex ( parseInt ( carousel . options . start ) ) ;
714713 createEvents ( ) ;
715714
716- if ( ! carousel . options . disable_scroll ) {
715+ if ( ! carousel . options . disableScroll ) {
717716 mousewheel . add ( ) ;
718717 }
719718}
@@ -741,7 +740,7 @@ function addExternalFunctions(itemslide, element, carousel)
741740 return ;
742741 }
743742
744- if ( carousel . vars . parent_width ) {
743+ if ( carousel . vars . parentWidth ) {
745744 Array . from ( $el . children ) . forEach ( ( slide ) => slide . style . width = $el . parentElement . offsetWidth ) ;
746745 }
747746
@@ -793,17 +792,17 @@ function addExternalFunctions(itemslide, element, carousel)
793792
794793var defaults = {
795794 duration : 350 ,
796- swipe_sensitivity : 150 ,
797- disable_slide : false ,
798- disable_clicktoslide : false ,
799- disable_scroll : false ,
795+ swipeSensitivity : 150 ,
796+ disableSlide : false ,
797+ disableClickToSlide : false ,
798+ disableScroll : false ,
800799 start : 0 ,
801- one_item : false , // Set true for "one slide per swipe" navigation (used in the full screen navigation example)
802- pan_threshold : 0.3 , // Percentage of slide width
803- disable_autowidth : false ,
804- parent_width : false ,
805- swipe_out : false , // Enable the swipe out feature - enables swiping items out of the carousel
806- left_sided : false // Restricts the movements to the borders instead of the middle
800+ oneItem : false , // Set true for "one slide per swipe" navigation (used in the full screen navigation example)
801+ panThreshold : 0.3 , // Percentage of slide width
802+ disableAutoWidth : false ,
803+ parentWidth : false ,
804+ swipeOut : false , // Enable the swipe out feature - enables swiping items out of the carousel
805+ leftSided : false // Restricts the movements to the borders instead of the middle
807806} ;
808807
809808function Itemslide ( element , options )
0 commit comments