This commit is contained in:
2024-04-25 23:50:02 +03:00
parent 5f7f687482
commit bc16ad2846
2 changed files with 199 additions and 127 deletions
+195 -124
View File
@@ -1,6 +1,7 @@
/**
* bxSlider v4.2.12
* Copyright 2013-2015 Steven Wanderski
* bxSlider v4.2.1d
* Copyright 2013-2017 Steven Wanderski
* fix https://github.com/stevenwanderski/bxslider-4/issues/1240#issuecomment-482294169
* Written while drinking Belgian ales and listening to jazz
* Licensed under MIT (http://opensource.org/licenses/MIT)
*/
@@ -88,7 +89,8 @@
onSlideAfter: function() { return true; },
onSlideNext: function() { return true; },
onSlidePrev: function() { return true; },
onSliderResize: function() { return true; }
onSliderResize: function() { return true; },
onAutoChange: function() { return true; } //calls when auto slides starts and stops
};
$.fn.bxSlider = function(options) {
@@ -107,11 +109,11 @@
// create a namespace to be used throughout the plugin
var slider = {},
// set a reference to our slider element
el = this,
// get the original window dimens (thanks a lot IE)
windowWidth = $(window).width(),
windowHeight = $(window).height();
// set a reference to our slider element
el = this,
// get the original window dimens (thanks a lot IE)
windowWidth = $(window).width(),
windowHeight = $(window).height();
// Return if slider is already initialized
if ($(el).data('bxSlider')) { return; }
@@ -142,7 +144,7 @@
// store active slide information
slider.active = { index: slider.settings.startSlide };
// store if the slider is in carousel mode (displaying / moving multiple slides)
slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1 ? true : false;
slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1;
// if carousel, force preloadImages = 'all'
if (slider.carousel) { slider.settings.preloadImages = 'all'; }
// calculate the min / max width thresholds based on min / max number of slides
@@ -161,8 +163,8 @@
slider.usingCSS = slider.settings.useCSS && slider.settings.mode !== 'fade' && (function() {
// create our test div element
var div = document.createElement('div'),
// css transition properties
props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
// css transition properties
props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
// test for each property
for (var i = 0; i < props.length; i++) {
if (div.style[props[i]] !== undefined) {
@@ -212,7 +214,7 @@
// if using CSS, add the easing property
if (slider.usingCSS && slider.settings.easing) {
el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing);
// if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
// if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
} else if (!slider.settings.easing) {
slider.settings.easing = 'swing';
}
@@ -227,7 +229,8 @@
});
// apply css to all slider children
slider.children.css({
float: slider.settings.mode === 'horizontal' ? 'left' : 'none',
// the float attribute is a reserved word in compressors like YUI compressor and need to be quoted #48
'float': slider.settings.mode === 'horizontal' ? 'left' : 'none',
listStyle: 'none',
position: 'relative'
});
@@ -254,7 +257,13 @@
slider.active.last = slider.settings.startSlide === getPagerQty() - 1;
// if video is true, set up the fitVids plugin
if (slider.settings.video) { el.fitVids(); }
if (slider.settings.preloadImages === 'all' || slider.settings.ticker) { preloadSelector = slider.children; }
//preloadImages
if (slider.settings.preloadImages === 'none') {
preloadSelector = null;
}
else if (slider.settings.preloadImages === 'all' || slider.settings.ticker) {
preloadSelector = slider.children;
}
// only check for control addition if not in "ticker" mode
if (!slider.settings.ticker) {
// if controls are requested, add them
@@ -265,16 +274,20 @@
if (slider.settings.pager) { appendPager(); }
// if any control option is requested, add the controls wrapper
if (slider.settings.controls || slider.settings.autoControls || slider.settings.pager) { slider.viewport.after(slider.controls.el); }
// if ticker mode, do not allow a pager
// if ticker mode, do not allow a pager
} else {
slider.settings.pager = false;
}
loadElements(preloadSelector, start);
if (preloadSelector === null) {
start();
} else {
loadElements(preloadSelector, start);
}
};
var loadElements = function(selector, callback) {
var total = selector.find('img:not([src=""]), iframe').length,
count = 0;
count = 0;
if (total === 0) {
callback();
return;
@@ -283,7 +296,7 @@
$(this).one('load error', function() {
if (++count === total) { callback(); }
}).each(function() {
if (this.complete) { $(this).trigger('load'); }
if (this.complete || this.src == '') { $(this).trigger('load'); }
});
});
};
@@ -295,8 +308,8 @@
// if infinite loop, prepare additional slides
if (slider.settings.infiniteLoop && slider.settings.mode !== 'fade' && !slider.settings.ticker) {
var slice = slider.settings.mode === 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides,
sliceAppend = slider.children.slice(0, slice).clone(true).addClass('bx-clone'),
slicePrepend = slider.children.slice(-slice).clone(true).addClass('bx-clone');
sliceAppend = slider.children.slice(0, slice).clone(true).addClass('bx-clone'),
slicePrepend = slider.children.slice(-slice).clone(true).addClass('bx-clone');
if (slider.settings.ariaHidden) {
sliceAppend.attr('aria-hidden', true);
slicePrepend.attr('aria-hidden', true);
@@ -317,8 +330,8 @@
slider.settings.onSliderLoad.call(el, slider.active.index);
// slider has been fully initialized
slider.initialized = true;
// bind the resize call to the window
if (slider.settings.responsive) { $(window).bind('resize', resizeWindow); }
// add the resize call to the window
if (slider.settings.responsive) { $(window).on('resize', resizeWindow); }
// if auto is true and has more than 1 page, start the show
if (slider.settings.auto && slider.settings.autoStart && (getPagerQty() > 1 || slider.settings.autoSlideForOnePage)) { initAuto(); }
// if ticker is true, start the ticker
@@ -349,7 +362,7 @@
// if not carousel, return the single active child
if (!slider.carousel) {
children = slider.children.eq(slider.active.index);
// if carousel, return a slice of children
// if carousel, return a slice of children
} else {
// get the individual slide index
var currentIndex = slider.settings.moveSlides === 1 ? slider.active.index : slider.active.index * getMoveBy();
@@ -375,7 +388,7 @@
if (slider.settings.slideMargin > 0) {
height += slider.settings.slideMargin * (slider.settings.minSlides - 1);
}
// if not "vertical" mode, calculate the max height of the children
// if not "vertical" mode, calculate the max height of the children
} else {
height = Math.max.apply(Math, children.map(function() {
return $(this).outerHeight(false);
@@ -384,7 +397,7 @@
if (slider.viewport.css('box-sizing') === 'border-box') {
height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')) +
parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width'));
parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width'));
} else if (slider.viewport.css('box-sizing') === 'padding-box') {
height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom'));
}
@@ -412,13 +425,13 @@
*/
var getSlideWidth = function() {
var newElWidth = slider.settings.slideWidth, // start with any user-supplied slide width
wrapWidth = slider.viewport.width(); // get the current viewport width
wrapWidth = slider.viewport.width(); // get the current viewport width
// if slide width was not supplied, or is larger than the viewport use the viewport width
if (slider.settings.slideWidth === 0 ||
(slider.settings.slideWidth > wrapWidth && !slider.carousel) ||
slider.settings.mode === 'vertical') {
(slider.settings.slideWidth > wrapWidth && !slider.carousel) ||
slider.settings.mode === 'vertical') {
newElWidth = wrapWidth;
// if carousel, use the thresholds to determine the width
// if carousel, use the thresholds to determine the width
} else if (slider.settings.maxSlides > 1 && slider.settings.mode === 'horizontal') {
if (wrapWidth > slider.maxThreshold) {
return newElWidth;
@@ -436,21 +449,21 @@
*/
var getNumberSlidesShowing = function() {
var slidesShowing = 1,
childWidth = null;
childWidth = null;
if (slider.settings.mode === 'horizontal' && slider.settings.slideWidth > 0) {
// if viewport is smaller than minThreshold, return minSlides
if (slider.viewport.width() < slider.minThreshold) {
slidesShowing = slider.settings.minSlides;
// if viewport is larger than maxThreshold, return maxSlides
// if viewport is larger than maxThreshold, return maxSlides
} else if (slider.viewport.width() > slider.maxThreshold) {
slidesShowing = slider.settings.maxSlides;
// if viewport is between min / max thresholds, divide viewport width by first child width
// if viewport is between min / max thresholds, divide viewport width by first child width
} else {
childWidth = slider.children.first().width() + slider.settings.slideMargin;
slidesShowing = Math.floor((slider.viewport.width() +
slider.settings.slideMargin) / childWidth);
slider.settings.slideMargin) / childWidth) || 1;
}
// if "vertical" mode, slides showing will always be minSlides
// if "vertical" mode, slides showing will always be minSlides
} else if (slider.settings.mode === 'vertical') {
slidesShowing = slider.settings.minSlides;
}
@@ -462,8 +475,8 @@
*/
var getPagerQty = function() {
var pagerQty = 0,
breakPoint = 0,
counter = 0;
breakPoint = 0,
counter = 0;
// if moveSlides is specified by the user
if (slider.settings.moveSlides > 0) {
if (slider.settings.infiniteLoop) {
@@ -475,8 +488,9 @@
breakPoint = counter + getNumberSlidesShowing();
counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing();
}
return counter;
}
// if moveSlides is 0 (auto) divide children length by sides showing, then round up
// if moveSlides is 0 (auto) divide children length by sides showing, then round up
} else {
pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing());
}
@@ -515,7 +529,7 @@
// set the top position
setPositionProperty(-position.top, 'reset', 0);
}
// if not last slide
// if not last slide
} else {
// get the position of the first showing slide
position = slider.children.eq(slider.active.index * getMoveBy()).position();
@@ -557,12 +571,12 @@
// set the property value
el.css(slider.animProp, propValue);
if (duration !== 0) {
// bind a callback method - executes when CSS transition completes
el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) {
// add a callback method - executes when CSS transition completes
el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) {
//make sure it's the correct one
if (!$(e.target).is(el)) { return; }
// unbind the callback
el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
// remove the callback
el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
updateAfterSlideTransition();
});
} else { //duration = 0
@@ -575,11 +589,11 @@
el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
el.css(slider.animProp, propValue);
if (duration !== 0) {
el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) {
el.on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) {
//make sure it's the correct one
if (!$(e.target).is(el)) { return; }
// unbind the callback
el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
// remove the callback
el.off('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
// reset the position
setPositionProperty(params.resetValue, 'reset', 0);
// start the loop again
@@ -590,7 +604,7 @@
tickerLoop();
}
}
// use JS animate
// use JS animate
} else {
animateObj = {};
animateObj[slider.animProp] = value;
@@ -615,8 +629,8 @@
*/
var populatePager = function() {
var pagerHtml = '',
linkContent = '',
pagerQty = getPagerQty();
linkContent = '',
pagerQty = getPagerQty();
// loop through each pager item
for (var i = 0; i < pagerQty; i++) {
linkContent = '';
@@ -646,7 +660,7 @@
// if a pager selector was supplied, populate it with the pager
if (slider.settings.pagerSelector) {
$(slider.settings.pagerSelector).html(slider.pagerEl);
// if no pager selector was supplied, add it after the wrapper
// if no pager selector was supplied, add it after the wrapper
} else {
slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
}
@@ -665,9 +679,9 @@
var appendControls = function() {
slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
// bind click actions to the controls
slider.controls.next.bind('click touchend', clickNextBind);
slider.controls.prev.bind('click touchend', clickPrevBind);
// add click actions to the controls
slider.controls.next.on('click touchend', clickNextBind);
slider.controls.prev.on('click touchend', clickPrevBind);
// if nextSelector was supplied, populate it
if (slider.settings.nextSelector) {
$(slider.settings.nextSelector).append(slider.controls.next);
@@ -695,20 +709,20 @@
slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
// add the controls to the DOM
slider.controls.autoEl = $('<div class="bx-controls-auto" />');
// bind click actions to the controls
// on click actions to the controls
slider.controls.autoEl.on('click', '.bx-start', clickStartBind);
slider.controls.autoEl.on('click', '.bx-stop', clickStopBind);
// if autoControlsCombine, insert only the "start" control
if (slider.settings.autoControlsCombine) {
slider.controls.autoEl.append(slider.controls.start);
// if autoControlsCombine is false, insert both controls
// if autoControlsCombine is false, insert both controls
} else {
slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
}
// if auto controls selector was supplied, populate it with the controls
if (slider.settings.autoControlsSelector) {
$(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
// if auto controls selector was not supplied, add it after the wrapper
// if auto controls selector was not supplied, add it after the wrapper
} else {
slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
}
@@ -836,10 +850,10 @@
if (slider.active.index === 0) {
// set the new position
position = slider.children.eq(0).position();
// carousel, last slide
// carousel, last slide
} else if (slider.active.index === getPagerQty() - 1 && slider.carousel) {
position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
// last slide
// last slide
} else if (slider.active.index === slider.children.length - 1) {
position = slider.children.eq(slider.children.length - 1).position();
}
@@ -864,7 +878,7 @@
// if autoControlsCombine is true, replace the current control with the new state
if (slider.settings.autoControlsCombine) {
slider.controls.autoEl.html(slider.controls[state]);
// if autoControlsCombine is false, apply the "active" class to the appropriate control
// if autoControlsCombine is false, apply the "active" class to the appropriate control
} else {
slider.controls.autoEl.find('a').removeClass('active');
slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active');
@@ -883,35 +897,33 @@
if (slider.active.index === 0) {
slider.controls.prev.addClass('disabled');
slider.controls.next.removeClass('disabled');
// if last slide
// if last slide
} else if (slider.active.index === getPagerQty() - 1) {
slider.controls.next.addClass('disabled');
slider.controls.prev.removeClass('disabled');
// if any slide in the middle
// if any slide in the middle
} else {
slider.controls.prev.removeClass('disabled');
slider.controls.next.removeClass('disabled');
}
}
};
/* auto start and stop functions */
var windowFocusHandler = function() { el.startAuto(); };
var windowBlurHandler = function() { el.stopAuto(); };
/**
* Initializes the auto process
*/
var initAuto = function() {
// if autoDelay was supplied, launch the auto show using a setTimeout() call
if (slider.settings.autoDelay > 0) {
var timeout = setTimeout(el.startAuto, slider.settings.autoDelay);
// if autoDelay was not supplied, start the auto show normally
setTimeout(el.startAuto, slider.settings.autoDelay);
// if autoDelay was not supplied, start the auto show normally
} else {
el.startAuto();
//add focus and blur events to ensure its running if timeout gets paused
$(window).focus(function() {
el.startAuto();
}).blur(function() {
el.stopAuto();
});
$(window).focus(windowFocusHandler).blur(windowBlurHandler);
}
// if autoHover is requested
if (slider.settings.autoHover) {
@@ -941,11 +953,11 @@
*/
var initTicker = function() {
var startPosition = 0,
position, transform, value, idx, ratio, property, newSpeed, totalDimens;
position, transform, value, idx, ratio, property, newSpeed, totalDimens;
// if autoDirection is "next", append a clone of the entire slider
if (slider.settings.autoDirection === 'next') {
el.append(slider.children.clone().addClass('bx-clone'));
// if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
// if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
} else {
el.prepend(slider.children.clone().addClass('bx-clone'));
position = slider.children.first().position();
@@ -1006,14 +1018,14 @@
*/
var tickerLoop = function(resumeSpeed) {
var speed = resumeSpeed ? resumeSpeed : slider.settings.speed,
position = {left: 0, top: 0},
reset = {left: 0, top: 0},
animateProperty, resetValue, params;
position = {left: 0, top: 0},
reset = {left: 0, top: 0},
animateProperty, resetValue, params;
// if "next" animate left position to last child, then reset left to 0
if (slider.settings.autoDirection === 'next') {
position = el.find('.bx-clone').first().position();
// if "prev" animate left position to 0, then reset left to first non-clone child
// if "prev" animate left position to 0, then reset left to first non-clone child
} else {
reset = slider.children.first().position();
}
@@ -1028,11 +1040,11 @@
*/
var isOnScreen = function(el) {
var win = $(window),
viewport = {
top: win.scrollTop(),
left: win.scrollLeft()
},
bounds = el.offset();
viewport = {
top: win.scrollTop(),
left: win.scrollLeft()
},
bounds = el.offset();
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
@@ -1047,9 +1059,9 @@
*/
var keyPress = function(e) {
var activeElementTag = document.activeElement.tagName.toLowerCase(),
tagFilters = 'input|textarea',
p = new RegExp(activeElementTag,['i']),
result = p.exec(tagFilters);
tagFilters = 'input|textarea',
p = new RegExp(activeElementTag,['i']),
result = p.exec(tagFilters);
if (result == null && isOnScreen(el)) {
if (e.keyCode === 39) {
@@ -1071,7 +1083,7 @@
start: {x: 0, y: 0},
end: {x: 0, y: 0}
};
slider.viewport.bind('touchstart MSPointerDown pointerdown', onTouchStart);
slider.viewport.on('touchstart MSPointerDown pointerdown', onTouchStart);
//for browsers that have implemented pointer events and fire a click after
//every pointerup regardless of whether pointerup is on same screen location as pointerdown or not
@@ -1090,30 +1102,48 @@
* - DOM event object
*/
var onTouchStart = function(e) {
// watch only for left mouse, touch contact and pen contact
// touchstart event object doesn`t have button property
if (e.type !== 'touchstart' && e.button !== 0) {
return;
}
//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
slider.controls.el.addClass('disabled');
if (slider.working) {
e.preventDefault();
slider.controls.el.removeClass('disabled');
} else {
// record the original position when touch starts
slider.touch.originalPos = el.position();
var orig = e.originalEvent,
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig];
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig];
var chromePointerEvents = typeof PointerEvent === 'function';
if (chromePointerEvents) {
if (orig.pointerId === undefined) {
return;
}
}
// record the starting touch x, y coordinates
slider.touch.start.x = touchPoints[0].pageX;
slider.touch.start.y = touchPoints[0].pageY;
slider.hasPointerCapture = false;
if (slider.viewport.get(0).setPointerCapture) {
slider.pointerId = orig.pointerId;
slider.viewport.get(0).setPointerCapture(slider.pointerId);
}
// bind a "touchmove" event to the viewport
slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove);
// bind a "touchend" event to the viewport
slider.viewport.bind('touchend MSPointerUp pointerup', onTouchEnd);
slider.viewport.bind('MSPointerCancel pointercancel', onPointerCancel);
// store original event data for click fixation
slider.originalClickTarget = orig.originalTarget || orig.target;
slider.originalClickButton = orig.button;
slider.originalClickButtons = orig.buttons;
slider.originalEventType = orig.type;
// at this moment we don`t know what it is click or swipe
slider.hasMove = false;
// on a "touchmove" event to the viewport
slider.viewport.on('touchmove MSPointerMove pointermove', onTouchMove);
// on a "touchend" event to the viewport
slider.viewport.on('touchend MSPointerUp pointerup', onTouchEnd);
slider.viewport.on('MSPointerCancel pointercancel', onPointerCancel);
}
};
@@ -1124,17 +1154,19 @@
* - DOM event object
*/
var onPointerCancel = function(e) {
e.preventDefault();
/* onPointerCancel handler is needed to deal with situations when a touchend
doesn't fire after a touchstart (this happens on windows phones only) */
setPositionProperty(slider.touch.originalPos.left, 'reset', 0);
//remove handlers
slider.controls.el.removeClass('disabled');
slider.viewport.unbind('MSPointerCancel pointercancel', onPointerCancel);
slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
if (slider.viewport.get(0).releasePointerCapture) {
slider.viewport.off('MSPointerCancel pointercancel', onPointerCancel);
slider.viewport.off('touchmove MSPointerMove pointermove', onTouchMove);
slider.viewport.off('touchend MSPointerUp pointerup', onTouchEnd);
if (slider.viewport.get(0).releasePointerCapture && slider.hasPointerCapture) {
slider.viewport.get(0).releasePointerCapture(slider.pointerId);
slider.hasPointerCapture = false;
}
};
@@ -1146,26 +1178,41 @@
*/
var onTouchMove = function(e) {
var orig = e.originalEvent,
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig],
// if scrolling on y axis, do not prevent default
xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x),
yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y),
value = 0,
change = 0;
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig],
// if scrolling on y axis, do not prevent default
xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x),
yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y),
value = 0,
change = 0;
// this is swipe
slider.hasMove = true;
var hasSwiped = false;
if ((xMovement > 5) || (yMovement > 5)) {
hasSwiped = true;
}
if (slider.viewport.get(0).setPointerCapture && !slider.hasPointerCapture && hasSwiped && (slider.pointerId === 1)) {
slider.viewport.get(0).setPointerCapture(slider.pointerId);
slider.hasPointerCapture = true;
}
// x axis swipe
if ((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX) {
e.preventDefault();
// y axis swipe
// y axis swipe
} else if ((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY) {
e.preventDefault();
}
if (e.type !== 'touchmove') {
e.preventDefault();
}
if (slider.settings.mode !== 'fade' && slider.settings.oneToOneTouch) {
// if horizontal, drag along x axis
if (slider.settings.mode === 'horizontal') {
change = touchPoints[0].pageX - slider.touch.start.x;
value = slider.touch.originalPos.left + change;
// if vertical, drag along y axis
// if vertical, drag along y axis
} else {
change = touchPoints[0].pageY - slider.touch.start.y;
value = slider.touch.originalPos.top + change;
@@ -1181,13 +1228,14 @@
* - DOM event object
*/
var onTouchEnd = function(e) {
slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove);
e.preventDefault();
slider.viewport.off('touchmove MSPointerMove pointermove', onTouchMove);
//enable slider controls as soon as user stops interacing with slides
slider.controls.el.removeClass('disabled');
var orig = e.originalEvent,
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig],
value = 0,
distance = 0;
touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig],
value = 0,
distance = 0;
// record end x, y positions
slider.touch.end.x = touchPoints[0].pageX;
slider.touch.end.y = touchPoints[0].pageY;
@@ -1202,7 +1250,7 @@
}
el.stopAuto();
}
// not fade mode
// not fade mode
} else {
// calculate distance and el's animate property
if (slider.settings.mode === 'horizontal') {
@@ -1230,10 +1278,24 @@
}
}
}
slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd);
slider.viewport.off('touchend MSPointerUp pointerup', onTouchEnd);
if (slider.viewport.get(0).releasePointerCapture) {
slider.viewport.get(0).releasePointerCapture(slider.pointerId);
}
// if slider had swipe with left mouse, touch contact and pen contact
if (slider.hasMove === false && (slider.originalClickButton === 0 || slider.originalEventType === 'touchstart')) {
// trigger click event (fix for Firefox59 and PointerEvent standard compatibility)
$(slider.originalClickTarget).trigger({
type: 'click',
button: slider.originalClickButton,
buttons: slider.originalClickButtons
});
}
if (slider.viewport.get(0).releasePointerCapture && slider.hasPointerCapture) {
slider.viewport.get(0).releasePointerCapture(slider.pointerId);
slider.hasPointerCapture = false;
}
};
/**
@@ -1248,7 +1310,7 @@
} else {
// get the new window dimens (again, thank you IE)
var windowWidthNew = $(window).width(),
windowHeightNew = $(window).height();
windowHeightNew = $(window).height();
// make sure that it is a true window resize
// *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
// are resized. Can you just die already?*
@@ -1295,7 +1357,7 @@
//we don't go to undefined slides
return slider.active.index;
}
// if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
// if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
} else if (slideIndex >= getPagerQty()) {
if (slider.settings.infiniteLoop) {
return 0;
@@ -1303,7 +1365,7 @@
//we don't move to undefined pages
return slider.active.index;
}
// set active index to requested slide
// set active index to requested slide
} else {
return slideIndex;
}
@@ -1328,10 +1390,10 @@
// onSlideBefore, onSlideNext, onSlidePrev callbacks
// Allow transition canceling based on returned value
var performTransition = true,
moveBy = 0,
position = {left: 0, top: 0},
lastChild = null,
lastShowingIndex, eq, value, requestEl;
moveBy = 0,
position = {left: 0, top: 0},
lastChild = null,
lastShowingIndex, eq, value, requestEl;
// store the old index
slider.oldIndex = slider.active.index;
//set new index
@@ -1382,7 +1444,7 @@
$(this).css('zIndex', slider.settings.slideZIndex);
updateAfterSlideTransition();
});
// slider mode is not "fade"
// slider mode is not "fade"
} else {
// if adaptiveHeight is true and next height is different from current height, animate to the new height
if (slider.settings.adaptiveHeight && slider.viewport.height() !== getViewportHeight()) {
@@ -1407,12 +1469,12 @@
eq = slider.settings.moveSlides === 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
lastChild = el.children('.bx-clone').eq(eq);
position = lastChild.position();
// if infinite loop and "Next" is clicked on the last slide
// if infinite loop and "Next" is clicked on the last slide
} else if (direction === 'next' && slider.active.index === 0) {
// get the last clone position
position = el.find('> .bx-clone').eq(slider.settings.maxSlides).position();
slider.active.last = false;
// normal non-zero requests
// normal non-zero requests
} else if (slideIndex >= 0) {
//parseInt is applied to allow floats for slides/page
requestEl = slideIndex * parseInt(getMoveBy());
@@ -1427,9 +1489,8 @@
value = slider.settings.mode === 'horizontal' ? -(position.left - moveBy) : -position.top;
// plugin values to be animated
setPositionProperty(value, 'slide', slider.settings.speed);
} else {
slider.working = false;
}
slider.working = false;
}
if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); }
};
@@ -1440,6 +1501,7 @@
el.goToNextSlide = function() {
// if infiniteLoop is false and last page is showing, disregard call
if (!slider.settings.infiniteLoop && slider.active.last) { return; }
if (slider.working === true){ return ;}
var pagerIndex = parseInt(slider.active.index) + 1;
el.goToSlide(pagerIndex, 'next');
};
@@ -1450,6 +1512,7 @@
el.goToPrevSlide = function() {
// if infiniteLoop is false and last page is showing, disregard call
if (!slider.settings.infiniteLoop && slider.active.index === 0) { return; }
if (slider.working === true){ return ;}
var pagerIndex = parseInt(slider.active.index) - 1;
el.goToSlide(pagerIndex, 'prev');
};
@@ -1471,6 +1534,8 @@
el.goToPrevSlide();
}
}, slider.settings.pause);
//allback for when the auto rotate status changes
slider.settings.onAutoChange.call(el, true);
// if auto controls are displayed and preventControlUpdate is not true
if (slider.settings.autoControls && preventControlUpdate !== true) { updateAutoControls('stop'); }
};
@@ -1482,11 +1547,15 @@
* - if true, auto controls state will not be updated
*/
el.stopAuto = function(preventControlUpdate) {
// if slider is auto paused, just clear that state
if (slider.autoPaused) slider.autoPaused = false;
// if no interval exists, disregard call
if (!slider.interval) { return; }
// clear the interval
clearInterval(slider.interval);
slider.interval = null;
//allback for when the auto rotate status changes
slider.settings.onAutoChange.call(el, false);
// if auto controls are displayed and preventControlUpdate is not true
if (slider.settings.autoControls && preventControlUpdate !== true) { updateAutoControls('start'); }
};
@@ -1579,10 +1648,12 @@
$('.bx-caption', this).remove();
if (slider.controls.autoEl) { slider.controls.autoEl.remove(); }
clearInterval(slider.interval);
if (slider.settings.responsive) { $(window).unbind('resize', resizeWindow); }
if (slider.settings.keyboardEnabled) { $(document).unbind('keydown', keyPress); }
if (slider.settings.responsive) { $(window).off('resize', resizeWindow); }
if (slider.settings.keyboardEnabled) { $(document).off('keydown', keyPress); }
//remove self reference in data
$(this).removeData('bxSlider');
// remove global window handlers
$(window).off('blur', windowBlurHandler).off('focus', windowFocusHandler);
};
/**
@@ -1604,4 +1675,4 @@
return this;
};
})(jQuery);
})(jQuery);
File diff suppressed because one or more lines are too long