bxslider-rails 4.2.1 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba9b6c62ba64f88c56e10648ad8c6da1f13bd1a3
4
- data.tar.gz: 1f11bbe0ba1a03116eeee2a5d3b9ec7ba879703a
3
+ metadata.gz: 616638ba19aaa709408499143730907126bf5c26
4
+ data.tar.gz: 55f6ceb412d9c941972f77e81bda120b563cbf1e
5
5
  SHA512:
6
- metadata.gz: 64ec459da7cee6cdc6424fdcf09dded76fa6a32003debc5e6cf7291cfa64d873155ad7124fd403e04b8d39f7223735ba9a2c9c79ff4c9a2159d28790f4bced7a
7
- data.tar.gz: 230cc97033a6cef36413a3dcfe1057a29191333d4acb19f65db6f34e5ee3cab673c651834e0562ca91862605020722cbe40e5be9b76e4eaff0f4083dc39659ea
6
+ metadata.gz: 4daedaf8ad39eeb97cb75e4f3a1725fd8284afbf9ad407039e0ebe3fa60047712d5acd80e12702b8bd3249db452ca6dcbe872160f07ffd42c226d3c725d41654
7
+ data.tar.gz: 2906b35304268309e6f539ea6c37da7e7e3f2fbb38c676c26f40587ecca4b05eaa96c5299fbdeac9dfa62b88aea5ec152e2e671894deff09bf38d4a6c90373c3
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # bxSlider Rails Gem - v4.2.1
1
+ # bxSlider Rails Gem - v4.2.2
2
2
 
3
- jQuery bxSlider v4.2.1 - http://bxslider.com
3
+ jQuery bxSlider v4.2.2 - http://bxslider.com
4
4
 
5
5
  bxSlider Author: Steven Wanderski, Copyright 2011
6
6
  bxslider-rails Author: Mauricio Natanael Ferreira.
7
7
 
8
8
  ### Extra info
9
9
 
10
- bxSlider 4.2.1 == bxslider-rails (4.2.1)
10
+ bxSlider 4.2.2 == bxslider-rails (4.2.2)
11
11
 
12
12
  ## Installation
13
13
 
@@ -1,5 +1,5 @@
1
1
  module Bxslider
2
2
  module Rails
3
- VERSION = "4.2.1"
3
+ VERSION = "4.2.2"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /***
2
- * BxSlider v4.2.1 - Fully loaded, responsive content slider
2
+ * BxSlider v4.2.2 - Fully loaded, responsive content slider
3
3
  * http://bxslider.com
4
4
  *
5
5
  * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com
@@ -10,8 +10,6 @@
10
10
 
11
11
  ;(function($){
12
12
 
13
- var plugin = {};
14
-
15
13
  var defaults = {
16
14
 
17
15
  // GENERAL
@@ -43,6 +41,9 @@
43
41
  preventDefaultSwipeX: true,
44
42
  preventDefaultSwipeY: false,
45
43
 
44
+ // KEYBOARD
45
+ keyboardEnabled: false,
46
+
46
47
  // PAGER
47
48
  pager: true,
48
49
  pagerType: 'full',
@@ -79,12 +80,12 @@
79
80
  slideWidth: 0,
80
81
 
81
82
  // CALLBACKS
82
- onSliderLoad: function(){},
83
- onSlideBefore: function(){},
84
- onSlideAfter: function(){},
85
- onSlideNext: function(){},
86
- onSlidePrev: function(){},
87
- onSliderResize: function(){}
83
+ onSliderLoad: function(){ return true },
84
+ onSlideBefore: function(){ return true },
85
+ onSlideAfter: function(){ return true },
86
+ onSlideNext: function(){ return true },
87
+ onSlidePrev: function(){ return true },
88
+ onSliderResize: function(){ return true }
88
89
  };
89
90
 
90
91
  $.fn.bxSlider = function(options){
@@ -105,7 +106,6 @@
105
106
  var slider = {};
106
107
  // set a reference to our slider element
107
108
  var el = this;
108
- plugin.el = this;
109
109
 
110
110
  /**
111
111
  * Makes slideshow responsive
@@ -140,7 +140,7 @@
140
140
  // store active slide information
141
141
  slider.active = { index: slider.settings.startSlide };
142
142
  // store if the slider is in carousel mode (displaying / moving multiple slides)
143
- slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1 ? false : true;
143
+ slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1 ? true : false;
144
144
  // if carousel, force preloadImages = 'all'
145
145
  if(slider.carousel){ slider.settings.preloadImages = 'all'; }
146
146
  // calculate the min / max width thresholds based on min / max number of slides
@@ -197,7 +197,7 @@
197
197
  // also strip any margin and padding from el
198
198
  el.css({
199
199
  width: slider.settings.mode === 'horizontal' ? (slider.children.length * 1000 + 215) + '%' : 'auto',
200
- position: 'relative'
200
+ position: 'absolute'
201
201
  });
202
202
  // if using CSS, add the easing property
203
203
  if(slider.usingCSS && slider.settings.easing){
@@ -217,7 +217,7 @@
217
217
  maxWidth: getViewportMaxWidth()
218
218
  });
219
219
  // make modification to the wrapper (.bx-wrapper)
220
- if(!slider.settings.pager){
220
+ if(!slider.settings.pager && !slider.settings.controls){
221
221
  slider.viewport.parent().css({
222
222
  margin: '0 auto 0px'
223
223
  });
@@ -253,7 +253,7 @@
253
253
  if(slider.settings.video){ el.fitVids(); }
254
254
  // set the default preload selector (visible)
255
255
  var preloadSelector = slider.children.eq(slider.settings.startSlide);
256
- if(slider.settings.preloadImages === "all"){ preloadSelector = slider.children; }
256
+ if(slider.settings.preloadImages === "all" || slider.settings.ticker){ preloadSelector = slider.children; }
257
257
  // only check for control addition if not in "ticker" mode
258
258
  if(!slider.settings.ticker){
259
259
  // if controls are requested, add them
@@ -268,19 +268,22 @@
268
268
  } else {
269
269
  slider.settings.pager = false;
270
270
  }
271
- // preload all images, then perform final DOM / CSS modifications that depend on images being loaded
272
- loadElements(preloadSelector, start);
271
+ // preload first image and apply height to viewport, then load all others and do final DOM / CSS modifications that depend on images being loaded
272
+ preloadSelector.find('img:not([src=""]), iframe').first().one('load error', function(){
273
+ slider.viewport.height($(this).height());
274
+ loadElements(preloadSelector, start);
275
+ });
273
276
  };
274
277
 
275
278
  var loadElements = function(selector, callback){
276
- var total = selector.find('img, iframe').length;
279
+ var total = selector.find('img:not([src=""]), iframe').length;
277
280
  if(total === 0){
278
281
  callback();
279
282
  return;
280
283
  }
281
284
  var count = 0;
282
- selector.find('img, iframe').each(function(){
283
- $(this).one('load', function(){
285
+ selector.find('img:not([src=""]), iframe').each(function(){
286
+ $(this).one('load error', function(){
284
287
  if(++count === total){ callback(); }
285
288
  }).each(function(){
286
289
  if(this.complete){ $(this).load(); }
@@ -310,7 +313,7 @@
310
313
  // make sure everything is positioned just right (same as a window resize)
311
314
  el.redrawSlider();
312
315
  // onSliderLoad callback
313
- slider.settings.onSliderLoad(slider.active.index);
316
+ slider.settings.onSliderLoad(slider,slider.active.index);
314
317
  // slider has been fully initialized
315
318
  slider.initialized = true;
316
319
  // bind the resize call to the window
@@ -325,6 +328,10 @@
325
328
  if(slider.settings.controls){ updateDirectionControls(); }
326
329
  // if touchEnabled is true, setup the touch events
327
330
  if(slider.settings.touchEnabled && !slider.settings.ticker){ initTouch(); }
331
+ // if keyboardEnabled is true, setup the keyboard events
332
+ if (slider.settings.keyboardEnabled && !slider.settings.ticker) {
333
+ $(document).keydown(keyPress);
334
+ }
328
335
  };
329
336
 
330
337
  /**
@@ -432,7 +439,7 @@
432
439
  // if viewport is smaller than minThreshold, return minSlides
433
440
  if(slider.viewport.width() < slider.minThreshold){
434
441
  slidesShowing = slider.settings.minSlides;
435
- // if viewport is larger than minThreshold, return maxSlides
442
+ // if viewport is larger than maxThreshold, return maxSlides
436
443
  }else if(slider.viewport.width() > slider.maxThreshold){
437
444
  slidesShowing = slider.settings.maxSlides;
438
445
  // if viewport is between min / max thresholds, divide viewport width by first child width
@@ -528,7 +535,7 @@
528
535
  * @param value (int)
529
536
  * - the animating property's value
530
537
  *
531
- * @param type (string) 'slider', 'reset', 'ticker'
538
+ * @param type (string) 'slide', 'reset', 'ticker'
532
539
  * - the type of instance for which the function is being
533
540
  *
534
541
  * @param duration (int)
@@ -545,14 +552,21 @@
545
552
  // add the CSS transition-duration
546
553
  el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's');
547
554
  if(type === 'slide'){
548
- // set the property value
549
- el.css(slider.animProp, propValue);
550
- // bind a callback method - executes when CSS transition completes
551
- el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
552
- // unbind the callback
553
- el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
554
- updateAfterSlideTransition();
555
- });
555
+ setTimeout(function() {
556
+ // set the property value
557
+ el.css(slider.animProp, propValue);
558
+ // if value 0, just update
559
+ if(value === 0) {
560
+ updateAfterSlideTransition();
561
+ } else {
562
+ // bind a callback method - executes when CSS transition completes
563
+ el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
564
+ // unbind the callback
565
+ el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
566
+ updateAfterSlideTransition();
567
+ });
568
+ }
569
+ }, 0);
556
570
  }else if(type === 'reset'){
557
571
  el.css(slider.animProp, propValue);
558
572
  }else if(type === 'ticker'){
@@ -634,7 +648,7 @@
634
648
  slider.pagerEl = $(slider.settings.pagerCustom);
635
649
  }
636
650
  // assign the pager click binding
637
- slider.pagerEl.on('click', 'a', clickPagerBind);
651
+ slider.pagerEl.on('click touchend', 'a', clickPagerBind);
638
652
  };
639
653
 
640
654
  /**
@@ -644,8 +658,8 @@
644
658
  slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
645
659
  slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
646
660
  // bind click actions to the controls
647
- slider.controls.next.bind('click', clickNextBind);
648
- slider.controls.prev.bind('click', clickPrevBind);
661
+ slider.controls.next.bind('click touchend', clickNextBind);
662
+ slider.controls.prev.bind('click touchend', clickPrevBind);
649
663
  // if nextSelector was supplied, populate it
650
664
  if(slider.settings.nextSelector){
651
665
  $(slider.settings.nextSelector).append(slider.controls.next);
@@ -704,8 +718,8 @@
704
718
  var title = $(this).find('img:first').attr('title');
705
719
  // append the caption
706
720
  if(title !== undefined && ('' + title).length){
707
- $(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
708
- }
721
+ $(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
722
+ }
709
723
  });
710
724
  };
711
725
 
@@ -716,10 +730,13 @@
716
730
  * - DOM event object
717
731
  */
718
732
  var clickNextBind = function(e){
733
+ e.preventDefault();
734
+ if (slider.controls.el.hasClass('disabled')) {
735
+ return;
736
+ }
719
737
  // if auto show is running, stop it
720
738
  if(slider.settings.auto){ el.stopAuto(); }
721
739
  el.goToNextSlide();
722
- e.preventDefault();
723
740
  };
724
741
 
725
742
  /**
@@ -729,10 +746,13 @@
729
746
  * - DOM event object
730
747
  */
731
748
  var clickPrevBind = function(e){
749
+ e.preventDefault();
750
+ if (slider.controls.el.hasClass('disabled')) {
751
+ return;
752
+ }
732
753
  // if auto show is running, stop it
733
754
  if(slider.settings.auto){ el.stopAuto(); }
734
755
  el.goToPrevSlide();
735
- e.preventDefault();
736
756
  };
737
757
 
738
758
  /**
@@ -764,6 +784,10 @@
764
784
  * - DOM event object
765
785
  */
766
786
  var clickPagerBind = function(e){
787
+ e.preventDefault();
788
+ if (slider.controls.el.hasClass('disabled')) {
789
+ return;
790
+ }
767
791
  // if auto show is running, stop it
768
792
  if(slider.settings.auto){ el.stopAuto(); }
769
793
  var pagerLink = $(e.currentTarget);
@@ -771,7 +795,6 @@
771
795
  var pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
772
796
  // if clicked pager link is not active, continue with the goToSlide call
773
797
  if(pagerIndex !== slider.active.index){ el.goToSlide(pagerIndex); }
774
- e.preventDefault();
775
798
  }
776
799
  };
777
800
 
@@ -877,6 +900,15 @@
877
900
  // if autoDelay was not supplied, start the auto show normally
878
901
  }else{
879
902
  el.startAuto();
903
+
904
+ //add focus and blur events to ensure its running if timeout gets paused
905
+ $(window).focus(function() {
906
+ el.startAuto();
907
+ }).blur(function() {
908
+ el.stopAuto();
909
+ });
910
+
911
+
880
912
  }
881
913
  // if autoHover is requested
882
914
  if(slider.settings.autoHover){
@@ -921,24 +953,46 @@
921
953
  slider.settings.controls = false;
922
954
  slider.settings.autoControls = false;
923
955
  // if autoHover is requested
924
- if(slider.settings.tickerHover && !slider.usingCSS){
925
- // on el hover
926
- slider.viewport.hover(function(){
927
- el.stop();
928
- }, function(){
929
- // calculate the total width of children (used to calculate the speed ratio)
930
- var totalDimens = 0;
931
- slider.children.each(function(index){
932
- totalDimens += slider.settings.mode === 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
956
+ if(slider.settings.tickerHover){
957
+ if(slider.usingCSS){
958
+ var value;
959
+ var idx = slider.settings.mode == 'horizontal' ? 4 : 5;
960
+ slider.viewport.hover(function(){
961
+ var transform = el.css('-' + slider.cssPrefix + '-transform');
962
+ value = parseFloat(transform.split(',')[idx]);
963
+ setPositionProperty(value, 'reset', 0);
964
+ }, function(){
965
+ var totalDimens = 0;
966
+ slider.children.each(function(index){
967
+ totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
968
+ });
969
+ // calculate the speed ratio (used to determine the new speed to finish the paused animation)
970
+ var ratio = slider.settings.speed / totalDimens;
971
+ // determine which property to use
972
+ var property = slider.settings.mode == 'horizontal' ? 'left' : 'top';
973
+ // calculate the new speed
974
+ var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(value))));
975
+ tickerLoop(newSpeed);
933
976
  });
934
- // calculate the speed ratio (used to determine the new speed to finish the paused animation)
935
- var ratio = slider.settings.speed / totalDimens;
936
- // determine which property to use
937
- var property = slider.settings.mode === 'horizontal' ? 'left' : 'top';
938
- // calculate the new speed
939
- var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
940
- tickerLoop(newSpeed);
941
- });
977
+ } else {
978
+ // on el hover
979
+ slider.viewport.hover(function(){
980
+ el.stop();
981
+ }, function(){
982
+ // calculate the total width of children (used to calculate the speed ratio)
983
+ var totalDimens = 0;
984
+ slider.children.each(function(index){
985
+ totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
986
+ });
987
+ // calculate the speed ratio (used to determine the new speed to finish the paused animation)
988
+ var ratio = slider.settings.speed / totalDimens;
989
+ // determine which property to use
990
+ var property = slider.settings.mode == 'horizontal' ? 'left' : 'top';
991
+ // calculate the new speed
992
+ var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
993
+ tickerLoop(newSpeed);
994
+ });
995
+ }
942
996
  }
943
997
  // start the ticker loop
944
998
  tickerLoop();
@@ -964,6 +1018,45 @@
964
1018
  setPositionProperty(animateProperty, 'ticker', speed, params);
965
1019
  };
966
1020
 
1021
+ /**
1022
+ * Check if el is on screen
1023
+ */
1024
+ var isOnScreen = function(el){
1025
+ var win = $(window);
1026
+ var viewport = {
1027
+ top : win.scrollTop(),
1028
+ left : win.scrollLeft()
1029
+ };
1030
+ viewport.right = viewport.left + win.width();
1031
+ viewport.bottom = viewport.top + win.height();
1032
+
1033
+ var bounds = el.offset();
1034
+ bounds.right = bounds.left + el.outerWidth();
1035
+ bounds.bottom = bounds.top + el.outerHeight();
1036
+
1037
+ return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
1038
+ };
1039
+
1040
+ /**
1041
+ * Initializes keyboard events
1042
+ */
1043
+ var keyPress = function(e){
1044
+ var activeElementTag = document.activeElement.tagName.toLowerCase();
1045
+ var tagFilters='input|textarea';
1046
+ var p = new RegExp(activeElementTag,["i"]);
1047
+ var result = p.exec(tagFilters);
1048
+ if (result == null && isOnScreen(el)) {
1049
+ if (e.keyCode == 39) {
1050
+ clickNextBind(e);
1051
+ return false;
1052
+ }
1053
+ else if (e.keyCode == 37) {
1054
+ clickPrevBind(e);
1055
+ return false;
1056
+ }
1057
+ }
1058
+ };
1059
+
967
1060
  /**
968
1061
  * Initializes touch events
969
1062
  */
@@ -973,7 +1066,16 @@
973
1066
  start: {x: 0, y: 0},
974
1067
  end: {x: 0, y: 0}
975
1068
  };
976
- slider.viewport.bind('touchstart', onTouchStart);
1069
+ slider.viewport.bind('touchstart MSPointerDown pointerdown', onTouchStart);
1070
+
1071
+ //for browsers that have implemented pointer events and fire a click after
1072
+ //every pointerup regardless of whether pointerup is on same screen location as pointerdown or not
1073
+ slider.viewport.on('click', '.bxslider a', function(e) {
1074
+ if (slider.viewport.hasClass('click-disabled')) {
1075
+ e.preventDefault();
1076
+ slider.viewport.removeClass('click-disabled');
1077
+ }
1078
+ });
977
1079
  };
978
1080
 
979
1081
  /**
@@ -983,22 +1085,54 @@
983
1085
  * - DOM event object
984
1086
  */
985
1087
  var onTouchStart = function(e){
1088
+ //disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls
1089
+ slider.controls.el.addClass('disabled');
1090
+
986
1091
  if(slider.working){
987
1092
  e.preventDefault();
1093
+ slider.controls.el.removeClass('disabled');
988
1094
  }else{
989
1095
  // record the original position when touch starts
990
1096
  slider.touch.originalPos = el.position();
991
1097
  var orig = e.originalEvent;
1098
+ var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig];
992
1099
  // record the starting touch x, y coordinates
993
- slider.touch.start.x = orig.changedTouches[0].pageX;
994
- slider.touch.start.y = orig.changedTouches[0].pageY;
1100
+ slider.touch.start.x = touchPoints[0].pageX;
1101
+ slider.touch.start.y = touchPoints[0].pageY;
1102
+
1103
+ if (slider.viewport.get(0).setPointerCapture) {
1104
+ slider.pointerId = orig.pointerId;
1105
+ slider.viewport.get(0).setPointerCapture(slider.pointerId);
1106
+ }
995
1107
  // bind a "touchmove" event to the viewport
996
- slider.viewport.bind('touchmove', onTouchMove);
1108
+ slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove);
997
1109
  // bind a "touchend" event to the viewport
998
- slider.viewport.bind('touchend', onTouchEnd);
1110
+ slider.viewport.bind('touchend MSPointerUp pointerup', onTouchEnd);
1111
+ slider.viewport.bind('MSPointerCancel pointercancel', onPointerCancel);
999
1112
  }
1000
1113
  };
1001
1114
 
1115
+ /**
1116
+ * Cancel Pointer for Windows Phone
1117
+ *
1118
+ * @param e (event)
1119
+ * - DOM event object
1120
+ */
1121
+ var onPointerCancel = function(e) {
1122
+ /* onPointerCancel handler is needed to deal with situations when a touchend
1123
+ doesn't fire after a touchstart (this happens on windows phones only) */
1124
+ setPositionProperty(slider.touch.originalPos.left, 'reset', 0);
1125
+
1126
+ //remove handlers
1127
+ slider.controls.el.removeClass('disabled');
1128
+ slider.viewport.unbind('MSPointerCancel pointercancel', onPointerCancel);
1129
+ slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
1130
+ slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
1131
+ if (slider.viewport.get(0).releasePointerCapture) {
1132
+ slider.viewport.get(0).releasePointerCapture(slider.pointerId);
1133
+ }
1134
+ }
1135
+
1002
1136
  /**
1003
1137
  * Event handler for "touchmove"
1004
1138
  *
@@ -1007,9 +1141,10 @@
1007
1141
  */
1008
1142
  var onTouchMove = function(e){
1009
1143
  var orig = e.originalEvent;
1144
+ var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig];
1010
1145
  // if scrolling on y axis, do not prevent default
1011
- var xMovement = Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x);
1012
- var yMovement = Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y);
1146
+ var xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x);
1147
+ var yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y);
1013
1148
  // x axis swipe
1014
1149
  if((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX){
1015
1150
  e.preventDefault();
@@ -1021,11 +1156,11 @@
1021
1156
  var value = 0, change = 0;
1022
1157
  // if horizontal, drag along x axis
1023
1158
  if(slider.settings.mode === 'horizontal'){
1024
- change = orig.changedTouches[0].pageX - slider.touch.start.x;
1159
+ change = touchPoints[0].pageX - slider.touch.start.x;
1025
1160
  value = slider.touch.originalPos.left + change;
1026
1161
  // if vertical, drag along y axis
1027
1162
  }else{
1028
- change = orig.changedTouches[0].pageY - slider.touch.start.y;
1163
+ change = touchPoints[0].pageY - slider.touch.start.y;
1029
1164
  value = slider.touch.originalPos.top + change;
1030
1165
  }
1031
1166
  setPositionProperty(value, 'reset', 0);
@@ -1039,13 +1174,16 @@
1039
1174
  * - DOM event object
1040
1175
  */
1041
1176
  var onTouchEnd = function(e){
1042
- slider.viewport.unbind('touchmove', onTouchMove);
1177
+ slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
1178
+ //enable slider controls as soon as user stops interacing with slides
1179
+ slider.controls.el.removeClass('disabled');
1043
1180
  var orig = e.originalEvent;
1181
+ var touchPoints = (typeof orig.changedTouches != 'undefined') ? orig.changedTouches : [orig];
1044
1182
  var value = 0;
1045
1183
  var distance = 0;
1046
1184
  // record end x, y positions
1047
- slider.touch.end.x = orig.changedTouches[0].pageX;
1048
- slider.touch.end.y = orig.changedTouches[0].pageY;
1185
+ slider.touch.end.x = touchPoints[0].pageX;
1186
+ slider.touch.end.y = touchPoints[0].pageY;
1049
1187
  // if fade mode, check if absolute x distance clears the threshold
1050
1188
  if(slider.settings.mode === 'fade'){
1051
1189
  distance = Math.abs(slider.touch.start.x - slider.touch.end.x);
@@ -1085,7 +1223,10 @@
1085
1223
  }
1086
1224
  }
1087
1225
  }
1088
- slider.viewport.unbind('touchend', onTouchEnd);
1226
+ slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
1227
+ if (slider.viewport.get(0).releasePointerCapture) {
1228
+ slider.viewport.get(0).releasePointerCapture(slider.pointerId);
1229
+ }
1089
1230
  };
1090
1231
 
1091
1232
  /**
@@ -1094,20 +1235,25 @@
1094
1235
  var resizeWindow = function(e){
1095
1236
  // don't do anything if slider isn't initialized.
1096
1237
  if(!slider.initialized){ return; }
1097
- // get the new window dimens (again, thank you IE)
1098
- var windowWidthNew = $(window).width();
1099
- var windowHeightNew = $(window).height();
1100
- // make sure that it is a true window resize
1101
- // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
1102
- // are resized. Can you just die already?*
1103
- if(windowWidth !== windowWidthNew || windowHeight !== windowHeightNew){
1104
- // set the new window dimens
1105
- windowWidth = windowWidthNew;
1106
- windowHeight = windowHeightNew;
1107
- // update all dynamic elements
1108
- el.redrawSlider();
1109
- // Call user resize handler
1110
- slider.settings.onSliderResize.call(el, slider.active.index);
1238
+ // Delay if slider working.
1239
+ if (slider.working) {
1240
+ window.setTimeout(resizeWindow, 10);
1241
+ } else {
1242
+ // get the new window dimens (again, thank you IE)
1243
+ var windowWidthNew = $(window).width();
1244
+ var windowHeightNew = $(window).height();
1245
+ // make sure that it is a true window resize
1246
+ // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
1247
+ // are resized. Can you just die already?*
1248
+ if(windowWidth !== windowWidthNew || windowHeight !== windowHeightNew){
1249
+ // set the new window dimens
1250
+ windowWidth = windowWidthNew;
1251
+ windowHeight = windowHeightNew;
1252
+ // update all dynamic elements
1253
+ el.redrawSlider();
1254
+ // Call user resize handler
1255
+ slider.settings.onSliderResize.call(el, slider.active.index);
1256
+ }
1111
1257
  }
1112
1258
  };
1113
1259
 
@@ -1144,12 +1290,35 @@
1144
1290
  slider.active.index = slideIndex;
1145
1291
  }
1146
1292
  // onSlideBefore, onSlideNext, onSlidePrev callbacks
1147
- slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1293
+ // Allow transition canceling based on returned value
1294
+ var performTransition = true;
1295
+
1296
+ performTransition = slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1297
+
1298
+ if ( typeof(performTransition) !== "undefined" && !performTransition ) {
1299
+ slider.active.index = slider.oldIndex; // restore old index
1300
+ slider.working = false; // is not in motion
1301
+ return;
1302
+ }
1148
1303
  if(direction === 'next'){
1149
- slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1304
+ // Prevent canceling in future functions or lack there-of from negating previous commands to cancel
1305
+ if(!slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)){
1306
+ performTransition = false;
1307
+ }
1150
1308
  }else if(direction === 'prev'){
1151
- slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
1309
+ // Prevent canceling in future functions or lack there-of from negating previous commands to cancel
1310
+ if(!slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)){
1311
+ performTransition = false;
1312
+ }
1152
1313
  }
1314
+
1315
+ // If transitions canceled, reset and return
1316
+ if ( typeof(performTransition) !== "undefined" && !performTransition ) {
1317
+ slider.active.index = slider.oldIndex; // restore old index
1318
+ slider.working = false; // is not in motion
1319
+ return;
1320
+ }
1321
+
1153
1322
  // check if last slide
1154
1323
  slider.active.last = slider.active.index >= getPagerQty() - 1;
1155
1324
  // update the pager with active class
@@ -1208,6 +1377,7 @@
1208
1377
  position = slider.children.eq(requestEl).position();
1209
1378
  }
1210
1379
 
1380
+
1211
1381
  /* If the position doesn't exist
1212
1382
  * (e.g. if you destroy the slider on a next click),
1213
1383
  * it doesn't throw an error.
@@ -1298,6 +1468,13 @@
1298
1468
  return slider.children.length;
1299
1469
  };
1300
1470
 
1471
+ /**
1472
+ * Return slider.working variable
1473
+ */
1474
+ el.isWorking = function() {
1475
+ return slider.working;
1476
+ }
1477
+
1301
1478
  /**
1302
1479
  * Update all dynamic slider elements
1303
1480
  */
@@ -1307,7 +1484,7 @@
1307
1484
  // adjust the height
1308
1485
  slider.viewport.css('height', getViewportHeight());
1309
1486
  // update the slide position
1310
- if(!slider.settings.ticker) { setSlidePosition(); }
1487
+ if(!slider.settings.ticker) { setSlidePosition(); }
1311
1488
  // if active.last was true before the screen resize, we want
1312
1489
  // to keep it last no matter what screen size we end on
1313
1490
  if (slider.active.last) { slider.active.index = getPagerQty() - 1; }
@@ -1349,6 +1526,7 @@
1349
1526
  if(slider.controls.autoEl){ slider.controls.autoEl.remove(); }
1350
1527
  clearInterval(slider.interval);
1351
1528
  if(slider.settings.responsive){ $(window).unbind('resize', resizeWindow); }
1529
+ if(slider.settings.keyboardEnabled){ $(document).unbind('keydown', keyPress); }
1352
1530
  };
1353
1531
 
1354
1532
  /**
@@ -1,5 +1,5 @@
1
1
  /***
2
- * BxSlider v4.2.1 - Fully loaded, responsive content slider
2
+ * BxSlider v4.2.2 - Fully loaded, responsive content slider
3
3
  * http://bxslider.com
4
4
  *
5
5
  * Written by: Steven Wanderski, 2014
@@ -16,6 +16,8 @@
16
16
  margin: 0 auto 60px;
17
17
  padding: 0;
18
18
  *zoom: 1;
19
+ -ms-touch-action: pan-y;
20
+ touch-action: pan-y;
19
21
  }
20
22
  .bx-wrapper img {
21
23
  max-width: 100%;
@@ -25,6 +27,9 @@
25
27
  margin: 0;
26
28
  padding: 0;
27
29
  }
30
+ ul.bxslider {
31
+ list-style: none;
32
+ }
28
33
  .bx-viewport {
29
34
  /*fix other elements on the page moving (on Chrome)*/
30
35
  -webkit-transform: translatez(0);
@@ -84,6 +89,10 @@
84
89
  *zoom: 1;
85
90
  *display: inline;
86
91
  }
92
+ .bx-wrapper .bx-pager-item {
93
+ font-size: 0;
94
+ line-height: 0;
95
+ }
87
96
  /* DIRECTION CONTROLS (NEXT / PREV) */
88
97
  .bx-wrapper .bx-prev {
89
98
  left: 10px;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bxslider-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio N. Ferreira