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