1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update components

This commit is contained in:
Luke Pulverenti 2016-02-07 14:19:56 -05:00
parent f4fb963fab
commit 484e60e328
23 changed files with 494 additions and 218 deletions

View file

@ -5,7 +5,7 @@
"url": "https://github.com/nolimits4web/Swiper.git" "url": "https://github.com/nolimits4web/Swiper.git"
}, },
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions", "description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"version": "3.3.0", "version": "3.3.1",
"author": "Vladimir Kharlampidi", "author": "Vladimir Kharlampidi",
"homepage": "http://www.idangero.us/swiper/", "homepage": "http://www.idangero.us/swiper/",
"keywords": [ "keywords": [
@ -45,14 +45,13 @@
"playground", "playground",
"package.json" "package.json"
], ],
"_release": "3.3.0", "_release": "3.3.1",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v3.3.0", "tag": "v3.3.1",
"commit": "d1b5b19c872068ebb14bfb854af838c30285cecd" "commit": "33101a659e579146f5462e4a9d6a7fdfd7436c35"
}, },
"_source": "git://github.com/nolimits4web/Swiper.git", "_source": "git://github.com/nolimits4web/Swiper.git",
"_target": "~3.3.0", "_target": "~3.3.0",
"_originalSource": "swiper", "_originalSource": "swiper"
"_direct": true
} }

View file

@ -1,5 +1,14 @@
# Change Log # Change Log
## Swiper 3.3.1 - Released on February 7, 2016
* New `uniqueNavElements` parameter. If enabled (by default) and navigation elements' parameters passed as the string (like `.pagination`) then Swiper will look for such elements through child elements first. Applies for pagination, prev/next buttons and scrollbar
* New `onPaginationRendered` callback. Will be fired after pagination elements generated and added to DOM
* New `.reLoop()` method, which combines `.destroyLoop()` + `.createLoop()` methods with additional positioning fixes. Useful to call after you have changed `slidesPerView` parameter, it will dynamically recreate duplicated slides required for loop
* Fixed not working mousewheel control in IE 11
* Fixed issue with lazy loading images not being recalculated after window resize
* Fixed issues when using loop with breakpoints changing `slidesPerView/Group` parameters
* Numerous minor fixes
## Swiper 3.3.0 - Released on January 10, 2016 ## Swiper 3.3.0 - Released on January 10, 2016
* New 3D Flip effect. Can be enabled with `effect: 'flip' parameter * New 3D Flip effect. Can be enabled with `effect: 'flip' parameter
* New types of pagination with new parameters: * New types of pagination with new parameters:

View file

@ -5,7 +5,7 @@
"url": "https://github.com/nolimits4web/Swiper.git" "url": "https://github.com/nolimits4web/Swiper.git"
}, },
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions", "description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"version": "3.3.0", "version": "3.3.1",
"author": "Vladimir Kharlampidi", "author": "Vladimir Kharlampidi",
"homepage": "http://www.idangero.us/swiper/", "homepage": "http://www.idangero.us/swiper/",
"keywords": ["swiper", "swipe", "slider", "touch", "ios", "mobile", "cordova", "phonegap", "app", "framework", "carousel", "gallery"], "keywords": ["swiper", "swipe", "slider", "touch", "ios", "mobile", "cordova", "phonegap", "app", "framework", "carousel", "gallery"],

View file

@ -2,7 +2,7 @@
"name": "swiper", "name": "swiper",
"repo": "https://github.com/nolimits4web/Swiper.git", "repo": "https://github.com/nolimits4web/Swiper.git",
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions", "description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"version": "3.3.0", "version": "3.3.1",
"keywords": ["swiper", "swipe", "slider", "touch", "ios", "mobile", "cordova", "phonegap", "app", "framework", "carousel", "gallery"], "keywords": ["swiper", "swipe", "slider", "touch", "ios", "mobile", "cordova", "phonegap", "app", "framework", "carousel", "gallery"],
"dependencies": { "dependencies": {
}, },

View file

@ -1,5 +1,5 @@
/** /**
* Swiper 3.3.0 * Swiper 3.3.1
* Most modern mobile touch slider and framework with hardware accelerated transitions * Most modern mobile touch slider and framework with hardware accelerated transitions
* *
* http://www.idangero.us/swiper/ * http://www.idangero.us/swiper/
@ -10,7 +10,7 @@
* *
* Licensed under MIT * Licensed under MIT
* *
* Released on: January 10, 2016 * Released on: February 7, 2016
*/ */
.swiper-container { .swiper-container {
margin: 0 auto; margin: 0 auto;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/** /**
* Swiper 3.3.0 * Swiper 3.3.1
* Most modern mobile touch slider and framework with hardware accelerated transitions * Most modern mobile touch slider and framework with hardware accelerated transitions
* *
* http://www.idangero.us/swiper/ * http://www.idangero.us/swiper/
@ -10,7 +10,7 @@
* *
* Licensed under MIT * Licensed under MIT
* *
* Released on: January 10, 2016 * Released on: February 7, 2016
*/ */
(function () { (function () {
'use strict'; 'use strict';
@ -110,6 +110,8 @@
onlyExternal: false, onlyExternal: false,
threshold: 0, threshold: 0,
touchMoveStopPropagation: true, touchMoveStopPropagation: true,
// Unique Navigation Elements
uniqueNavElements: true,
// Pagination // Pagination
pagination: null, pagination: null,
paginationElement: 'span', paginationElement: 'span',
@ -298,10 +300,14 @@
var breakpoint = s.getActiveBreakpoint(); var breakpoint = s.getActiveBreakpoint();
if (breakpoint && s.currentBreakpoint !== breakpoint) { if (breakpoint && s.currentBreakpoint !== breakpoint) {
var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams; var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
for ( var param in breakPointsParams ) { for ( var param in breakPointsParams ) {
s.params[param] = breakPointsParams[param]; s.params[param] = breakPointsParams[param];
} }
s.currentBreakpoint = breakpoint; s.currentBreakpoint = breakpoint;
if(needsReLoop && s.destroyLoop) {
s.reLoop(true);
}
} }
}; };
// Set breakpoint on load // Set breakpoint on load
@ -315,10 +321,12 @@
s.container = $(container); s.container = $(container);
if (s.container.length === 0) return; if (s.container.length === 0) return;
if (s.container.length > 1) { if (s.container.length > 1) {
var swipers = [];
s.container.each(function () { s.container.each(function () {
new Swiper(this, params); var container = this;
swipers.push(new Swiper(this, params));
}); });
return; return swipers;
} }
// Save instance in container HTML Element and in data // Save instance in container HTML Element and in data
@ -387,6 +395,10 @@
// Pagination // Pagination
if (s.params.pagination) { if (s.params.pagination) {
s.paginationContainer = $(s.params.pagination); s.paginationContainer = $(s.params.pagination);
if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
s.paginationContainer = s.container.find(s.params.pagination);
}
if (s.params.paginationType === 'bullets' && s.params.paginationClickable) { if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
s.paginationContainer.addClass('swiper-pagination-clickable'); s.paginationContainer.addClass('swiper-pagination-clickable');
} }
@ -395,6 +407,21 @@
} }
s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType); s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType);
} }
// Next/Prev Buttons
if (s.params.nextButton || s.params.prevButton) {
if (s.params.nextButton) {
s.nextButton = $(s.params.nextButton);
if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
s.nextButton = s.container.find(s.params.nextButton);
}
}
if (s.params.prevButton) {
s.prevButton = $(s.params.prevButton);
if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
s.prevButton = s.container.find(s.params.prevButton);
}
}
}
// Is Horizontal // Is Horizontal
s.isHorizontal = function () { s.isHorizontal = function () {
@ -642,6 +669,7 @@
i, i,
prevSlideSize = 0, prevSlideSize = 0,
index = 0; index = 0;
if (typeof s.size === 'undefined') return;
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size; spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
} }
@ -780,7 +808,7 @@
} }
} }
s.snapGrid = newSlidesGrid; s.snapGrid = newSlidesGrid;
if (Math.floor(s.virtualSize - s.size) > Math.floor(s.snapGrid[s.snapGrid.length - 1])) { if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
s.snapGrid.push(s.virtualSize - s.size); s.snapGrid.push(s.virtualSize - s.size);
} }
} }
@ -902,8 +930,16 @@
var activeSlide = s.slides.eq(s.activeIndex); var activeSlide = s.slides.eq(s.activeIndex);
// Active classes // Active classes
activeSlide.addClass(s.params.slideActiveClass); activeSlide.addClass(s.params.slideActiveClass);
activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass); // Next Slide
activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass); var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
if (s.params.loop && nextSlide.length === 0) {
s.slides.eq(0).addClass(s.params.slideNextClass);
}
// Prev Slide
var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
if (s.params.loop && prevSlide.length === 0) {
s.slides.eq(-1).addClass(s.params.slidePrevClass);
}
// Pagination // Pagination
if (s.paginationContainer && s.paginationContainer.length > 0) { if (s.paginationContainer && s.paginationContainer.length > 0) {
@ -911,7 +947,7 @@
var current, var current,
total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length; total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
if (s.params.loop) { if (s.params.loop) {
current = Math.ceil(s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup; current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
if (current > s.slides.length - 1 - s.loopedSlides * 2) { if (current > s.slides.length - 1 - s.loopedSlides * 2) {
current = current - (s.slides.length - s.loopedSlides * 2); current = current - (s.slides.length - s.loopedSlides * 2);
} }
@ -954,29 +990,30 @@
} }
if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) { if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total)); s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
} }
} }
// Next/active buttons // Next/active buttons
if (!s.params.loop) { if (!s.params.loop) {
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
if (s.isBeginning) { if (s.isBeginning) {
$(s.params.prevButton).addClass(s.params.buttonDisabledClass); s.prevButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
} }
else { else {
$(s.params.prevButton).removeClass(s.params.buttonDisabledClass); s.prevButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
} }
} }
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
if (s.isEnd) { if (s.isEnd) {
$(s.params.nextButton).addClass(s.params.buttonDisabledClass); s.nextButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
} }
else { else {
$(s.params.nextButton).removeClass(s.params.buttonDisabledClass); s.nextButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
} }
} }
} }
@ -1026,6 +1063,9 @@
} }
s.paginationContainer.html(paginationHTML); s.paginationContainer.html(paginationHTML);
} }
if (s.params.paginationType !== 'custom') {
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
}
} }
}; };
/*========================= /*=========================
@ -1097,6 +1137,7 @@
if (s.controller && s.controller.spline) { if (s.controller && s.controller.spline) {
s.controller.spline = undefined; s.controller.spline = undefined;
} }
var slideChangedBySlideTo = false;
if (s.params.freeMode) { if (s.params.freeMode) {
var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate()); var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
s.setWrapperTranslate(newTranslate); s.setWrapperTranslate(newTranslate);
@ -1110,12 +1151,15 @@
else { else {
s.updateClasses(); s.updateClasses();
if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) { if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
s.slideTo(s.slides.length - 1, 0, false, true); slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
} }
else { else {
s.slideTo(s.activeIndex, 0, false, true); slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
} }
} }
if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
s.lazy.load();
}
// Return locks after resize // Return locks after resize
s.params.allowSwipeToPrev = allowSwipeToPrev; s.params.allowSwipeToPrev = allowSwipeToPrev;
s.params.allowSwipeToNext = allowSwipeToNext; s.params.allowSwipeToNext = allowSwipeToNext;
@ -1171,23 +1215,23 @@
window[action]('resize', s.onResize); window[action]('resize', s.onResize);
// Next, Prev, Index // Next, Prev, Index
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
$(s.params.nextButton)[actionDom]('click', s.onClickNext); s.nextButton[actionDom]('click', s.onClickNext);
if (s.params.a11y && s.a11y) $(s.params.nextButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
$(s.params.prevButton)[actionDom]('click', s.onClickPrev); s.prevButton[actionDom]('click', s.onClickPrev);
if (s.params.a11y && s.a11y) $(s.params.prevButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.pagination && s.params.paginationClickable) { if (s.params.pagination && s.params.paginationClickable) {
$(s.paginationContainer)[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex); s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
if (s.params.a11y && s.a11y) $(s.paginationContainer)[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
} }
// Prevent Links Clicks // Prevent Links Clicks
if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true); if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
}; };
s.attachEvents = function (detach) { s.attachEvents = function () {
s.initEvents(); s.initEvents();
}; };
s.detachEvents = function () { s.detachEvents = function () {
@ -1383,7 +1427,11 @@
s.onTouchMove = function (e) { s.onTouchMove = function (e) {
if (e.originalEvent) e = e.originalEvent; if (e.originalEvent) e = e.originalEvent;
if (isTouchEvent && e.type === 'mousemove') return; if (isTouchEvent && e.type === 'mousemove') return;
if (e.preventedByNestedSwiper) return; if (e.preventedByNestedSwiper) {
s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
return;
}
if (s.params.onlyExternal) { if (s.params.onlyExternal) {
// isMoved = true; // isMoved = true;
s.allowClick = false; s.allowClick = false;
@ -2148,6 +2196,16 @@
s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
s.slides.removeAttr('data-swiper-slide-index'); s.slides.removeAttr('data-swiper-slide-index');
}; };
s.reLoop = function (updatePosition) {
var oldIndex = s.activeIndex - s.loopedSlides;
s.destroyLoop();
s.createLoop();
s.updateSlidesSize();
if (updatePosition) {
s.slideTo(oldIndex + s.loopedSlides, 0, false);
}
};
s.fixLoop = function () { s.fixLoop = function () {
var newIndex; var newIndex;
//Fix For Negative Oversliding //Fix For Negative Oversliding
@ -2555,7 +2613,7 @@
srcset = _img.attr('data-srcset'); srcset = _img.attr('data-srcset');
s.loadImage(_img[0], (src || background), srcset, false, function () { s.loadImage(_img[0], (src || background), srcset, false, function () {
if (background) { if (background) {
_img.css('background-image', 'url(' + background + ')'); _img.css('background-image', 'url("' + background + '")');
_img.removeAttr('data-background'); _img.removeAttr('data-background');
} }
else { else {
@ -2734,6 +2792,9 @@
if (!s.params.scrollbar) return; if (!s.params.scrollbar) return;
var sb = s.scrollbar; var sb = s.scrollbar;
sb.track = $(s.params.scrollbar); sb.track = $(s.params.scrollbar);
if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
sb.track = s.container.find(s.params.scrollbar);
}
sb.drag = sb.track.find('.swiper-scrollbar-drag'); sb.drag = sb.track.find('.swiper-scrollbar-drag');
if (sb.drag.length === 0) { if (sb.drag.length === 0) {
sb.drag = $('<div class="swiper-scrollbar-drag"></div>'); sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
@ -3056,8 +3117,14 @@
try { try {
new window.WheelEvent('wheel'); new window.WheelEvent('wheel');
s.mousewheel.event = 'wheel'; s.mousewheel.event = 'wheel';
} catch (e) {} } catch (e) {
if (window.WheelEvent || (s.container[0] && 'wheel' in s.container[0])) {
s.mousewheel.event = 'wheel';
}
}
if (!s.mousewheel.event && window.WheelEvent) {
}
if (!s.mousewheel.event && document.onmousewheel !== undefined) { if (!s.mousewheel.event && document.onmousewheel !== undefined) {
s.mousewheel.event = 'mousewheel'; s.mousewheel.event = 'mousewheel';
} }
@ -3070,10 +3137,9 @@
var we = s.mousewheel.event; var we = s.mousewheel.event;
var delta = 0; var delta = 0;
var rtlFactor = s.rtl ? -1 : 1; var rtlFactor = s.rtl ? -1 : 1;
//Opera & IE
if (e.detail) delta = -e.detail;
//WebKits //WebKits
else if (we === 'mousewheel') { if (we === 'mousewheel') {
if (s.params.mousewheelForceToAxis) { if (s.params.mousewheelForceToAxis) {
if (s.isHorizontal()) { if (s.isHorizontal()) {
if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor; if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor;
@ -3383,17 +3449,15 @@
}, },
init: function () { init: function () {
// Setup accessibility // Setup accessibility
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
var nextButton = $(s.params.nextButton); s.a11y.makeFocusable(s.nextButton);
s.a11y.makeFocusable(nextButton); s.a11y.addRole(s.nextButton, 'button');
s.a11y.addRole(nextButton, 'button'); s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
s.a11y.addLabel(nextButton, s.params.nextSlideMessage);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
var prevButton = $(s.params.prevButton); s.a11y.makeFocusable(s.prevButton);
s.a11y.makeFocusable(prevButton); s.a11y.addRole(s.prevButton, 'button');
s.a11y.addRole(prevButton, 'button'); s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
s.a11y.addLabel(prevButton, s.params.prevSlideMessage);
} }
$(s.container).append(s.a11y.liveRegion); $(s.container).append(s.a11y.liveRegion);
@ -3710,4 +3774,5 @@ else if (typeof define === 'function' && define.amd) {
'use strict'; 'use strict';
return window.Swiper; return window.Swiper;
}); });
} }
//# sourceMappingURL=maps/swiper.jquery.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/** /**
* Swiper 3.3.0 * Swiper 3.3.1
* Most modern mobile touch slider and framework with hardware accelerated transitions * Most modern mobile touch slider and framework with hardware accelerated transitions
* *
* http://www.idangero.us/swiper/ * http://www.idangero.us/swiper/
@ -10,7 +10,7 @@
* *
* Licensed under MIT * Licensed under MIT
* *
* Released on: January 10, 2016 * Released on: February 7, 2016
*/ */
(function (root, factory) { (function (root, factory) {
'use strict'; 'use strict';
@ -125,6 +125,8 @@
onlyExternal: false, onlyExternal: false,
threshold: 0, threshold: 0,
touchMoveStopPropagation: true, touchMoveStopPropagation: true,
// Unique Navigation Elements
uniqueNavElements: true,
// Pagination // Pagination
pagination: null, pagination: null,
paginationElement: 'span', paginationElement: 'span',
@ -313,10 +315,14 @@
var breakpoint = s.getActiveBreakpoint(); var breakpoint = s.getActiveBreakpoint();
if (breakpoint && s.currentBreakpoint !== breakpoint) { if (breakpoint && s.currentBreakpoint !== breakpoint) {
var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams; var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
for ( var param in breakPointsParams ) { for ( var param in breakPointsParams ) {
s.params[param] = breakPointsParams[param]; s.params[param] = breakPointsParams[param];
} }
s.currentBreakpoint = breakpoint; s.currentBreakpoint = breakpoint;
if(needsReLoop && s.destroyLoop) {
s.reLoop(true);
}
} }
}; };
// Set breakpoint on load // Set breakpoint on load
@ -330,10 +336,12 @@
s.container = $(container); s.container = $(container);
if (s.container.length === 0) return; if (s.container.length === 0) return;
if (s.container.length > 1) { if (s.container.length > 1) {
var swipers = [];
s.container.each(function () { s.container.each(function () {
new Swiper(this, params); var container = this;
swipers.push(new Swiper(this, params));
}); });
return; return swipers;
} }
// Save instance in container HTML Element and in data // Save instance in container HTML Element and in data
@ -402,6 +410,10 @@
// Pagination // Pagination
if (s.params.pagination) { if (s.params.pagination) {
s.paginationContainer = $(s.params.pagination); s.paginationContainer = $(s.params.pagination);
if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
s.paginationContainer = s.container.find(s.params.pagination);
}
if (s.params.paginationType === 'bullets' && s.params.paginationClickable) { if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
s.paginationContainer.addClass('swiper-pagination-clickable'); s.paginationContainer.addClass('swiper-pagination-clickable');
} }
@ -410,6 +422,21 @@
} }
s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType); s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType);
} }
// Next/Prev Buttons
if (s.params.nextButton || s.params.prevButton) {
if (s.params.nextButton) {
s.nextButton = $(s.params.nextButton);
if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
s.nextButton = s.container.find(s.params.nextButton);
}
}
if (s.params.prevButton) {
s.prevButton = $(s.params.prevButton);
if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
s.prevButton = s.container.find(s.params.prevButton);
}
}
}
// Is Horizontal // Is Horizontal
s.isHorizontal = function () { s.isHorizontal = function () {
@ -657,6 +684,7 @@
i, i,
prevSlideSize = 0, prevSlideSize = 0,
index = 0; index = 0;
if (typeof s.size === 'undefined') return;
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size; spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
} }
@ -795,7 +823,7 @@
} }
} }
s.snapGrid = newSlidesGrid; s.snapGrid = newSlidesGrid;
if (Math.floor(s.virtualSize - s.size) > Math.floor(s.snapGrid[s.snapGrid.length - 1])) { if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
s.snapGrid.push(s.virtualSize - s.size); s.snapGrid.push(s.virtualSize - s.size);
} }
} }
@ -917,8 +945,16 @@
var activeSlide = s.slides.eq(s.activeIndex); var activeSlide = s.slides.eq(s.activeIndex);
// Active classes // Active classes
activeSlide.addClass(s.params.slideActiveClass); activeSlide.addClass(s.params.slideActiveClass);
activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass); // Next Slide
activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass); var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
if (s.params.loop && nextSlide.length === 0) {
s.slides.eq(0).addClass(s.params.slideNextClass);
}
// Prev Slide
var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
if (s.params.loop && prevSlide.length === 0) {
s.slides.eq(-1).addClass(s.params.slidePrevClass);
}
// Pagination // Pagination
if (s.paginationContainer && s.paginationContainer.length > 0) { if (s.paginationContainer && s.paginationContainer.length > 0) {
@ -926,7 +962,7 @@
var current, var current,
total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length; total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
if (s.params.loop) { if (s.params.loop) {
current = Math.ceil(s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup; current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
if (current > s.slides.length - 1 - s.loopedSlides * 2) { if (current > s.slides.length - 1 - s.loopedSlides * 2) {
current = current - (s.slides.length - s.loopedSlides * 2); current = current - (s.slides.length - s.loopedSlides * 2);
} }
@ -969,29 +1005,30 @@
} }
if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) { if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total)); s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
} }
} }
// Next/active buttons // Next/active buttons
if (!s.params.loop) { if (!s.params.loop) {
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
if (s.isBeginning) { if (s.isBeginning) {
$(s.params.prevButton).addClass(s.params.buttonDisabledClass); s.prevButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
} }
else { else {
$(s.params.prevButton).removeClass(s.params.buttonDisabledClass); s.prevButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
} }
} }
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
if (s.isEnd) { if (s.isEnd) {
$(s.params.nextButton).addClass(s.params.buttonDisabledClass); s.nextButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
} }
else { else {
$(s.params.nextButton).removeClass(s.params.buttonDisabledClass); s.nextButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
} }
} }
} }
@ -1041,6 +1078,9 @@
} }
s.paginationContainer.html(paginationHTML); s.paginationContainer.html(paginationHTML);
} }
if (s.params.paginationType !== 'custom') {
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
}
} }
}; };
/*========================= /*=========================
@ -1112,6 +1152,7 @@
if (s.controller && s.controller.spline) { if (s.controller && s.controller.spline) {
s.controller.spline = undefined; s.controller.spline = undefined;
} }
var slideChangedBySlideTo = false;
if (s.params.freeMode) { if (s.params.freeMode) {
var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate()); var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
s.setWrapperTranslate(newTranslate); s.setWrapperTranslate(newTranslate);
@ -1125,12 +1166,15 @@
else { else {
s.updateClasses(); s.updateClasses();
if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) { if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
s.slideTo(s.slides.length - 1, 0, false, true); slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
} }
else { else {
s.slideTo(s.activeIndex, 0, false, true); slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
} }
} }
if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
s.lazy.load();
}
// Return locks after resize // Return locks after resize
s.params.allowSwipeToPrev = allowSwipeToPrev; s.params.allowSwipeToPrev = allowSwipeToPrev;
s.params.allowSwipeToNext = allowSwipeToNext; s.params.allowSwipeToNext = allowSwipeToNext;
@ -1186,23 +1230,23 @@
window[action]('resize', s.onResize); window[action]('resize', s.onResize);
// Next, Prev, Index // Next, Prev, Index
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
$(s.params.nextButton)[actionDom]('click', s.onClickNext); s.nextButton[actionDom]('click', s.onClickNext);
if (s.params.a11y && s.a11y) $(s.params.nextButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
$(s.params.prevButton)[actionDom]('click', s.onClickPrev); s.prevButton[actionDom]('click', s.onClickPrev);
if (s.params.a11y && s.a11y) $(s.params.prevButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.pagination && s.params.paginationClickable) { if (s.params.pagination && s.params.paginationClickable) {
$(s.paginationContainer)[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex); s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
if (s.params.a11y && s.a11y) $(s.paginationContainer)[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
} }
// Prevent Links Clicks // Prevent Links Clicks
if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true); if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
}; };
s.attachEvents = function (detach) { s.attachEvents = function () {
s.initEvents(); s.initEvents();
}; };
s.detachEvents = function () { s.detachEvents = function () {
@ -1398,7 +1442,11 @@
s.onTouchMove = function (e) { s.onTouchMove = function (e) {
if (e.originalEvent) e = e.originalEvent; if (e.originalEvent) e = e.originalEvent;
if (isTouchEvent && e.type === 'mousemove') return; if (isTouchEvent && e.type === 'mousemove') return;
if (e.preventedByNestedSwiper) return; if (e.preventedByNestedSwiper) {
s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
return;
}
if (s.params.onlyExternal) { if (s.params.onlyExternal) {
// isMoved = true; // isMoved = true;
s.allowClick = false; s.allowClick = false;
@ -2163,6 +2211,16 @@
s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
s.slides.removeAttr('data-swiper-slide-index'); s.slides.removeAttr('data-swiper-slide-index');
}; };
s.reLoop = function (updatePosition) {
var oldIndex = s.activeIndex - s.loopedSlides;
s.destroyLoop();
s.createLoop();
s.updateSlidesSize();
if (updatePosition) {
s.slideTo(oldIndex + s.loopedSlides, 0, false);
}
};
s.fixLoop = function () { s.fixLoop = function () {
var newIndex; var newIndex;
//Fix For Negative Oversliding //Fix For Negative Oversliding
@ -2570,7 +2628,7 @@
srcset = _img.attr('data-srcset'); srcset = _img.attr('data-srcset');
s.loadImage(_img[0], (src || background), srcset, false, function () { s.loadImage(_img[0], (src || background), srcset, false, function () {
if (background) { if (background) {
_img.css('background-image', 'url(' + background + ')'); _img.css('background-image', 'url("' + background + '")');
_img.removeAttr('data-background'); _img.removeAttr('data-background');
} }
else { else {
@ -2749,6 +2807,9 @@
if (!s.params.scrollbar) return; if (!s.params.scrollbar) return;
var sb = s.scrollbar; var sb = s.scrollbar;
sb.track = $(s.params.scrollbar); sb.track = $(s.params.scrollbar);
if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
sb.track = s.container.find(s.params.scrollbar);
}
sb.drag = sb.track.find('.swiper-scrollbar-drag'); sb.drag = sb.track.find('.swiper-scrollbar-drag');
if (sb.drag.length === 0) { if (sb.drag.length === 0) {
sb.drag = $('<div class="swiper-scrollbar-drag"></div>'); sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
@ -3071,8 +3132,14 @@
try { try {
new window.WheelEvent('wheel'); new window.WheelEvent('wheel');
s.mousewheel.event = 'wheel'; s.mousewheel.event = 'wheel';
} catch (e) {} } catch (e) {
if (window.WheelEvent || (s.container[0] && 'wheel' in s.container[0])) {
s.mousewheel.event = 'wheel';
}
}
if (!s.mousewheel.event && window.WheelEvent) {
}
if (!s.mousewheel.event && document.onmousewheel !== undefined) { if (!s.mousewheel.event && document.onmousewheel !== undefined) {
s.mousewheel.event = 'mousewheel'; s.mousewheel.event = 'mousewheel';
} }
@ -3085,10 +3152,9 @@
var we = s.mousewheel.event; var we = s.mousewheel.event;
var delta = 0; var delta = 0;
var rtlFactor = s.rtl ? -1 : 1; var rtlFactor = s.rtl ? -1 : 1;
//Opera & IE
if (e.detail) delta = -e.detail;
//WebKits //WebKits
else if (we === 'mousewheel') { if (we === 'mousewheel') {
if (s.params.mousewheelForceToAxis) { if (s.params.mousewheelForceToAxis) {
if (s.isHorizontal()) { if (s.isHorizontal()) {
if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor; if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor;
@ -3398,17 +3464,15 @@
}, },
init: function () { init: function () {
// Setup accessibility // Setup accessibility
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
var nextButton = $(s.params.nextButton); s.a11y.makeFocusable(s.nextButton);
s.a11y.makeFocusable(nextButton); s.a11y.addRole(s.nextButton, 'button');
s.a11y.addRole(nextButton, 'button'); s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
s.a11y.addLabel(nextButton, s.params.nextSlideMessage);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
var prevButton = $(s.params.prevButton); s.a11y.makeFocusable(s.prevButton);
s.a11y.makeFocusable(prevButton); s.a11y.addRole(s.prevButton, 'button');
s.a11y.addRole(prevButton, 'button'); s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
s.a11y.addLabel(prevButton, s.params.prevSlideMessage);
} }
$(s.container).append(s.a11y.liveRegion); $(s.container).append(s.a11y.liveRegion);
@ -3702,4 +3766,5 @@
} }
return Swiper; return Swiper;
})); }));
//# sourceMappingURL=maps/swiper.jquery.umd.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/** /**
* Swiper 3.3.0 * Swiper 3.3.1
* Most modern mobile touch slider and framework with hardware accelerated transitions * Most modern mobile touch slider and framework with hardware accelerated transitions
* *
* http://www.idangero.us/swiper/ * http://www.idangero.us/swiper/
@ -10,7 +10,7 @@
* *
* Licensed under MIT * Licensed under MIT
* *
* Released on: January 10, 2016 * Released on: February 7, 2016
*/ */
(function () { (function () {
'use strict'; 'use strict';
@ -110,6 +110,8 @@
onlyExternal: false, onlyExternal: false,
threshold: 0, threshold: 0,
touchMoveStopPropagation: true, touchMoveStopPropagation: true,
// Unique Navigation Elements
uniqueNavElements: true,
// Pagination // Pagination
pagination: null, pagination: null,
paginationElement: 'span', paginationElement: 'span',
@ -298,10 +300,14 @@
var breakpoint = s.getActiveBreakpoint(); var breakpoint = s.getActiveBreakpoint();
if (breakpoint && s.currentBreakpoint !== breakpoint) { if (breakpoint && s.currentBreakpoint !== breakpoint) {
var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams; var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
for ( var param in breakPointsParams ) { for ( var param in breakPointsParams ) {
s.params[param] = breakPointsParams[param]; s.params[param] = breakPointsParams[param];
} }
s.currentBreakpoint = breakpoint; s.currentBreakpoint = breakpoint;
if(needsReLoop && s.destroyLoop) {
s.reLoop(true);
}
} }
}; };
// Set breakpoint on load // Set breakpoint on load
@ -315,10 +321,12 @@
s.container = $(container); s.container = $(container);
if (s.container.length === 0) return; if (s.container.length === 0) return;
if (s.container.length > 1) { if (s.container.length > 1) {
var swipers = [];
s.container.each(function () { s.container.each(function () {
new Swiper(this, params); var container = this;
swipers.push(new Swiper(this, params));
}); });
return; return swipers;
} }
// Save instance in container HTML Element and in data // Save instance in container HTML Element and in data
@ -387,6 +395,10 @@
// Pagination // Pagination
if (s.params.pagination) { if (s.params.pagination) {
s.paginationContainer = $(s.params.pagination); s.paginationContainer = $(s.params.pagination);
if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
s.paginationContainer = s.container.find(s.params.pagination);
}
if (s.params.paginationType === 'bullets' && s.params.paginationClickable) { if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
s.paginationContainer.addClass('swiper-pagination-clickable'); s.paginationContainer.addClass('swiper-pagination-clickable');
} }
@ -395,6 +407,21 @@
} }
s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType); s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType);
} }
// Next/Prev Buttons
if (s.params.nextButton || s.params.prevButton) {
if (s.params.nextButton) {
s.nextButton = $(s.params.nextButton);
if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
s.nextButton = s.container.find(s.params.nextButton);
}
}
if (s.params.prevButton) {
s.prevButton = $(s.params.prevButton);
if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
s.prevButton = s.container.find(s.params.prevButton);
}
}
}
// Is Horizontal // Is Horizontal
s.isHorizontal = function () { s.isHorizontal = function () {
@ -642,6 +669,7 @@
i, i,
prevSlideSize = 0, prevSlideSize = 0,
index = 0; index = 0;
if (typeof s.size === 'undefined') return;
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size; spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
} }
@ -780,7 +808,7 @@
} }
} }
s.snapGrid = newSlidesGrid; s.snapGrid = newSlidesGrid;
if (Math.floor(s.virtualSize - s.size) > Math.floor(s.snapGrid[s.snapGrid.length - 1])) { if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
s.snapGrid.push(s.virtualSize - s.size); s.snapGrid.push(s.virtualSize - s.size);
} }
} }
@ -902,8 +930,16 @@
var activeSlide = s.slides.eq(s.activeIndex); var activeSlide = s.slides.eq(s.activeIndex);
// Active classes // Active classes
activeSlide.addClass(s.params.slideActiveClass); activeSlide.addClass(s.params.slideActiveClass);
activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass); // Next Slide
activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass); var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
if (s.params.loop && nextSlide.length === 0) {
s.slides.eq(0).addClass(s.params.slideNextClass);
}
// Prev Slide
var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
if (s.params.loop && prevSlide.length === 0) {
s.slides.eq(-1).addClass(s.params.slidePrevClass);
}
// Pagination // Pagination
if (s.paginationContainer && s.paginationContainer.length > 0) { if (s.paginationContainer && s.paginationContainer.length > 0) {
@ -911,7 +947,7 @@
var current, var current,
total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length; total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
if (s.params.loop) { if (s.params.loop) {
current = Math.ceil(s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup; current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
if (current > s.slides.length - 1 - s.loopedSlides * 2) { if (current > s.slides.length - 1 - s.loopedSlides * 2) {
current = current - (s.slides.length - s.loopedSlides * 2); current = current - (s.slides.length - s.loopedSlides * 2);
} }
@ -954,29 +990,30 @@
} }
if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) { if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total)); s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
} }
} }
// Next/active buttons // Next/active buttons
if (!s.params.loop) { if (!s.params.loop) {
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
if (s.isBeginning) { if (s.isBeginning) {
$(s.params.prevButton).addClass(s.params.buttonDisabledClass); s.prevButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
} }
else { else {
$(s.params.prevButton).removeClass(s.params.buttonDisabledClass); s.prevButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
} }
} }
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
if (s.isEnd) { if (s.isEnd) {
$(s.params.nextButton).addClass(s.params.buttonDisabledClass); s.nextButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
} }
else { else {
$(s.params.nextButton).removeClass(s.params.buttonDisabledClass); s.nextButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
} }
} }
} }
@ -1026,6 +1063,9 @@
} }
s.paginationContainer.html(paginationHTML); s.paginationContainer.html(paginationHTML);
} }
if (s.params.paginationType !== 'custom') {
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
}
} }
}; };
/*========================= /*=========================
@ -1097,6 +1137,7 @@
if (s.controller && s.controller.spline) { if (s.controller && s.controller.spline) {
s.controller.spline = undefined; s.controller.spline = undefined;
} }
var slideChangedBySlideTo = false;
if (s.params.freeMode) { if (s.params.freeMode) {
var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate()); var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
s.setWrapperTranslate(newTranslate); s.setWrapperTranslate(newTranslate);
@ -1110,12 +1151,15 @@
else { else {
s.updateClasses(); s.updateClasses();
if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) { if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
s.slideTo(s.slides.length - 1, 0, false, true); slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
} }
else { else {
s.slideTo(s.activeIndex, 0, false, true); slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
} }
} }
if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
s.lazy.load();
}
// Return locks after resize // Return locks after resize
s.params.allowSwipeToPrev = allowSwipeToPrev; s.params.allowSwipeToPrev = allowSwipeToPrev;
s.params.allowSwipeToNext = allowSwipeToNext; s.params.allowSwipeToNext = allowSwipeToNext;
@ -1171,23 +1215,23 @@
window[action]('resize', s.onResize); window[action]('resize', s.onResize);
// Next, Prev, Index // Next, Prev, Index
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
$(s.params.nextButton)[actionDom]('click', s.onClickNext); s.nextButton[actionDom]('click', s.onClickNext);
if (s.params.a11y && s.a11y) $(s.params.nextButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
$(s.params.prevButton)[actionDom]('click', s.onClickPrev); s.prevButton[actionDom]('click', s.onClickPrev);
if (s.params.a11y && s.a11y) $(s.params.prevButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.pagination && s.params.paginationClickable) { if (s.params.pagination && s.params.paginationClickable) {
$(s.paginationContainer)[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex); s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
if (s.params.a11y && s.a11y) $(s.paginationContainer)[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
} }
// Prevent Links Clicks // Prevent Links Clicks
if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true); if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
}; };
s.attachEvents = function (detach) { s.attachEvents = function () {
s.initEvents(); s.initEvents();
}; };
s.detachEvents = function () { s.detachEvents = function () {
@ -1383,7 +1427,11 @@
s.onTouchMove = function (e) { s.onTouchMove = function (e) {
if (e.originalEvent) e = e.originalEvent; if (e.originalEvent) e = e.originalEvent;
if (isTouchEvent && e.type === 'mousemove') return; if (isTouchEvent && e.type === 'mousemove') return;
if (e.preventedByNestedSwiper) return; if (e.preventedByNestedSwiper) {
s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
return;
}
if (s.params.onlyExternal) { if (s.params.onlyExternal) {
// isMoved = true; // isMoved = true;
s.allowClick = false; s.allowClick = false;
@ -2148,6 +2196,16 @@
s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
s.slides.removeAttr('data-swiper-slide-index'); s.slides.removeAttr('data-swiper-slide-index');
}; };
s.reLoop = function (updatePosition) {
var oldIndex = s.activeIndex - s.loopedSlides;
s.destroyLoop();
s.createLoop();
s.updateSlidesSize();
if (updatePosition) {
s.slideTo(oldIndex + s.loopedSlides, 0, false);
}
};
s.fixLoop = function () { s.fixLoop = function () {
var newIndex; var newIndex;
//Fix For Negative Oversliding //Fix For Negative Oversliding
@ -2555,7 +2613,7 @@
srcset = _img.attr('data-srcset'); srcset = _img.attr('data-srcset');
s.loadImage(_img[0], (src || background), srcset, false, function () { s.loadImage(_img[0], (src || background), srcset, false, function () {
if (background) { if (background) {
_img.css('background-image', 'url(' + background + ')'); _img.css('background-image', 'url("' + background + '")');
_img.removeAttr('data-background'); _img.removeAttr('data-background');
} }
else { else {
@ -2734,6 +2792,9 @@
if (!s.params.scrollbar) return; if (!s.params.scrollbar) return;
var sb = s.scrollbar; var sb = s.scrollbar;
sb.track = $(s.params.scrollbar); sb.track = $(s.params.scrollbar);
if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
sb.track = s.container.find(s.params.scrollbar);
}
sb.drag = sb.track.find('.swiper-scrollbar-drag'); sb.drag = sb.track.find('.swiper-scrollbar-drag');
if (sb.drag.length === 0) { if (sb.drag.length === 0) {
sb.drag = $('<div class="swiper-scrollbar-drag"></div>'); sb.drag = $('<div class="swiper-scrollbar-drag"></div>');
@ -3056,8 +3117,14 @@
try { try {
new window.WheelEvent('wheel'); new window.WheelEvent('wheel');
s.mousewheel.event = 'wheel'; s.mousewheel.event = 'wheel';
} catch (e) {} } catch (e) {
if (window.WheelEvent || (s.container[0] && 'wheel' in s.container[0])) {
s.mousewheel.event = 'wheel';
}
}
if (!s.mousewheel.event && window.WheelEvent) {
}
if (!s.mousewheel.event && document.onmousewheel !== undefined) { if (!s.mousewheel.event && document.onmousewheel !== undefined) {
s.mousewheel.event = 'mousewheel'; s.mousewheel.event = 'mousewheel';
} }
@ -3070,10 +3137,9 @@
var we = s.mousewheel.event; var we = s.mousewheel.event;
var delta = 0; var delta = 0;
var rtlFactor = s.rtl ? -1 : 1; var rtlFactor = s.rtl ? -1 : 1;
//Opera & IE
if (e.detail) delta = -e.detail;
//WebKits //WebKits
else if (we === 'mousewheel') { if (we === 'mousewheel') {
if (s.params.mousewheelForceToAxis) { if (s.params.mousewheelForceToAxis) {
if (s.isHorizontal()) { if (s.isHorizontal()) {
if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor; if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor;
@ -3383,17 +3449,15 @@
}, },
init: function () { init: function () {
// Setup accessibility // Setup accessibility
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
var nextButton = $(s.params.nextButton); s.a11y.makeFocusable(s.nextButton);
s.a11y.makeFocusable(nextButton); s.a11y.addRole(s.nextButton, 'button');
s.a11y.addRole(nextButton, 'button'); s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
s.a11y.addLabel(nextButton, s.params.nextSlideMessage);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
var prevButton = $(s.params.prevButton); s.a11y.makeFocusable(s.prevButton);
s.a11y.makeFocusable(prevButton); s.a11y.addRole(s.prevButton, 'button');
s.a11y.addRole(prevButton, 'button'); s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
s.a11y.addLabel(prevButton, s.params.prevSlideMessage);
} }
$(s.container).append(s.a11y.liveRegion); $(s.container).append(s.a11y.liveRegion);
@ -4376,4 +4440,5 @@ else if (typeof define === 'function' && define.amd) {
'use strict'; 'use strict';
return window.Swiper; return window.Swiper;
}); });
} }
//# sourceMappingURL=maps/swiper.js.map

File diff suppressed because one or more lines are too long

View file

@ -170,32 +170,41 @@
.pipe(tap(function (file, t){ .pipe(tap(function (file, t){
addJSIndent (file, t); addJSIndent (file, t);
})) }))
.pipe(sourcemaps.init())
.pipe(concat(swiper.filename + '.js')) .pipe(concat(swiper.filename + '.js'))
.pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } )) .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
.pipe(gulp.dest(paths.build.scripts))
.pipe(jshint()) .pipe(jshint())
.pipe(jshint.reporter(stylish)); .pipe(jshint.reporter(stylish))
.pipe(sourcemaps.write('./maps/'))
.pipe(gulp.dest(paths.build.scripts));
gulp.src(swiper.jQueryFiles) gulp.src(swiper.jQueryFiles)
.pipe(tap(function (file, t){ .pipe(tap(function (file, t){
addJSIndent (file, t); addJSIndent (file, t);
})) }))
.pipe(sourcemaps.init())
.pipe(concat(swiper.filename + '.jquery.js')) .pipe(concat(swiper.filename + '.jquery.js'))
.pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } )) .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
.pipe(sourcemaps.write('./maps/'))
.pipe(gulp.dest(paths.build.scripts)); .pipe(gulp.dest(paths.build.scripts));
gulp.src(swiper.jQueryUMDFiles) gulp.src(swiper.jQueryUMDFiles)
.pipe(tap(function (file, t){ .pipe(tap(function (file, t){
addJSIndent (file, t); addJSIndent (file, t);
})) }))
.pipe(sourcemaps.init())
.pipe(concat(swiper.filename + '.jquery.umd.js')) .pipe(concat(swiper.filename + '.jquery.umd.js'))
.pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } )) .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
.pipe(sourcemaps.write('./maps/'))
.pipe(gulp.dest(paths.build.scripts)); .pipe(gulp.dest(paths.build.scripts));
gulp.src(swiper.Framework7Files) gulp.src(swiper.Framework7Files)
.pipe(tap(function (file, t){ .pipe(tap(function (file, t){
addJSIndent (file, t, true); addJSIndent (file, t, true);
})) }))
.pipe(sourcemaps.init())
.pipe(concat(swiper.filename + '.framework7.js')) .pipe(concat(swiper.filename + '.framework7.js'))
.pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } )) .pipe(header(swiper.banner, { pkg : swiper.pkg, date: swiper.date } ))
.pipe(sourcemaps.write('./maps/'))
.pipe(gulp.dest(paths.build.scripts)) .pipe(gulp.dest(paths.build.scripts))
.pipe(connect.reload()); .pipe(connect.reload());
cb(); cb();

View file

@ -1,4 +1,4 @@
var version = '3.3.0'; var version = '3.3.1';
Package.describe({ Package.describe({
name: 'nolimits4web:swiper', name: 'nolimits4web:swiper',

View file

@ -59,17 +59,15 @@ s.a11y = {
}, },
init: function () { init: function () {
// Setup accessibility // Setup accessibility
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
var nextButton = $(s.params.nextButton); s.a11y.makeFocusable(s.nextButton);
s.a11y.makeFocusable(nextButton); s.a11y.addRole(s.nextButton, 'button');
s.a11y.addRole(nextButton, 'button'); s.a11y.addLabel(s.nextButton, s.params.nextSlideMessage);
s.a11y.addLabel(nextButton, s.params.nextSlideMessage);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
var prevButton = $(s.params.prevButton); s.a11y.makeFocusable(s.prevButton);
s.a11y.makeFocusable(prevButton); s.a11y.addRole(s.prevButton, 'button');
s.a11y.addRole(prevButton, 'button'); s.a11y.addLabel(s.prevButton, s.params.prevSlideMessage);
s.a11y.addLabel(prevButton, s.params.prevSlideMessage);
} }
$(s.container).append(s.a11y.liveRegion); $(s.container).append(s.a11y.liveRegion);

View file

@ -87,6 +87,8 @@ var defaults = {
onlyExternal: false, onlyExternal: false,
threshold: 0, threshold: 0,
touchMoveStopPropagation: true, touchMoveStopPropagation: true,
// Unique Navigation Elements
uniqueNavElements: true,
// Pagination // Pagination
pagination: null, pagination: null,
paginationElement: 'span', paginationElement: 'span',
@ -275,10 +277,14 @@ s.setBreakpoint = function () {
var breakpoint = s.getActiveBreakpoint(); var breakpoint = s.getActiveBreakpoint();
if (breakpoint && s.currentBreakpoint !== breakpoint) { if (breakpoint && s.currentBreakpoint !== breakpoint) {
var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams; var breakPointsParams = breakpoint in s.params.breakpoints ? s.params.breakpoints[breakpoint] : s.originalParams;
var needsReLoop = s.params.loop && (breakPointsParams.slidesPerView !== s.params.slidesPerView);
for ( var param in breakPointsParams ) { for ( var param in breakPointsParams ) {
s.params[param] = breakPointsParams[param]; s.params[param] = breakPointsParams[param];
} }
s.currentBreakpoint = breakpoint; s.currentBreakpoint = breakpoint;
if(needsReLoop && s.destroyLoop) {
s.reLoop(true);
}
} }
}; };
// Set breakpoint on load // Set breakpoint on load
@ -292,10 +298,12 @@ if (s.params.breakpoints) {
s.container = $(container); s.container = $(container);
if (s.container.length === 0) return; if (s.container.length === 0) return;
if (s.container.length > 1) { if (s.container.length > 1) {
var swipers = [];
s.container.each(function () { s.container.each(function () {
new Swiper(this, params); var container = this;
swipers.push(new Swiper(this, params));
}); });
return; return swipers;
} }
// Save instance in container HTML Element and in data // Save instance in container HTML Element and in data
@ -364,6 +372,10 @@ s.wrapper = s.container.children('.' + s.params.wrapperClass);
// Pagination // Pagination
if (s.params.pagination) { if (s.params.pagination) {
s.paginationContainer = $(s.params.pagination); s.paginationContainer = $(s.params.pagination);
if (s.params.uniqueNavElements && typeof s.params.pagination === 'string' && s.paginationContainer.length > 1 && s.container.find(s.params.pagination).length === 1) {
s.paginationContainer = s.container.find(s.params.pagination);
}
if (s.params.paginationType === 'bullets' && s.params.paginationClickable) { if (s.params.paginationType === 'bullets' && s.params.paginationClickable) {
s.paginationContainer.addClass('swiper-pagination-clickable'); s.paginationContainer.addClass('swiper-pagination-clickable');
} }
@ -372,6 +384,21 @@ if (s.params.pagination) {
} }
s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType); s.paginationContainer.addClass('swiper-pagination-' + s.params.paginationType);
} }
// Next/Prev Buttons
if (s.params.nextButton || s.params.prevButton) {
if (s.params.nextButton) {
s.nextButton = $(s.params.nextButton);
if (s.params.uniqueNavElements && typeof s.params.nextButton === 'string' && s.nextButton.length > 1 && s.container.find(s.params.nextButton).length === 1) {
s.nextButton = s.container.find(s.params.nextButton);
}
}
if (s.params.prevButton) {
s.prevButton = $(s.params.prevButton);
if (s.params.uniqueNavElements && typeof s.params.prevButton === 'string' && s.prevButton.length > 1 && s.container.find(s.params.prevButton).length === 1) {
s.prevButton = s.container.find(s.params.prevButton);
}
}
}
// Is Horizontal // Is Horizontal
s.isHorizontal = function () { s.isHorizontal = function () {
@ -619,6 +646,7 @@ s.updateSlidesSize = function () {
i, i,
prevSlideSize = 0, prevSlideSize = 0,
index = 0; index = 0;
if (typeof s.size === 'undefined') return;
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size; spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s.size;
} }
@ -757,7 +785,7 @@ s.updateSlidesSize = function () {
} }
} }
s.snapGrid = newSlidesGrid; s.snapGrid = newSlidesGrid;
if (Math.floor(s.virtualSize - s.size) > Math.floor(s.snapGrid[s.snapGrid.length - 1])) { if (Math.floor(s.virtualSize - s.size) - Math.floor(s.snapGrid[s.snapGrid.length - 1]) > 1) {
s.snapGrid.push(s.virtualSize - s.size); s.snapGrid.push(s.virtualSize - s.size);
} }
} }
@ -879,8 +907,16 @@ s.updateClasses = function () {
var activeSlide = s.slides.eq(s.activeIndex); var activeSlide = s.slides.eq(s.activeIndex);
// Active classes // Active classes
activeSlide.addClass(s.params.slideActiveClass); activeSlide.addClass(s.params.slideActiveClass);
activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass); // Next Slide
activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass); var nextSlide = activeSlide.next('.' + s.params.slideClass).addClass(s.params.slideNextClass);
if (s.params.loop && nextSlide.length === 0) {
s.slides.eq(0).addClass(s.params.slideNextClass);
}
// Prev Slide
var prevSlide = activeSlide.prev('.' + s.params.slideClass).addClass(s.params.slidePrevClass);
if (s.params.loop && prevSlide.length === 0) {
s.slides.eq(-1).addClass(s.params.slidePrevClass);
}
// Pagination // Pagination
if (s.paginationContainer && s.paginationContainer.length > 0) { if (s.paginationContainer && s.paginationContainer.length > 0) {
@ -888,7 +924,7 @@ s.updateClasses = function () {
var current, var current,
total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length; total = s.params.loop ? Math.ceil((s.slides.length - s.loopedSlides * 2) / s.params.slidesPerGroup) : s.snapGrid.length;
if (s.params.loop) { if (s.params.loop) {
current = Math.ceil(s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup; current = Math.ceil((s.activeIndex - s.loopedSlides)/s.params.slidesPerGroup);
if (current > s.slides.length - 1 - s.loopedSlides * 2) { if (current > s.slides.length - 1 - s.loopedSlides * 2) {
current = current - (s.slides.length - s.loopedSlides * 2); current = current - (s.slides.length - s.loopedSlides * 2);
} }
@ -931,29 +967,30 @@ s.updateClasses = function () {
} }
if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) { if (s.params.paginationType === 'custom' && s.params.paginationCustomRender) {
s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total)); s.paginationContainer.html(s.params.paginationCustomRender(s, current + 1, total));
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
} }
} }
// Next/active buttons // Next/active buttons
if (!s.params.loop) { if (!s.params.loop) {
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
if (s.isBeginning) { if (s.isBeginning) {
$(s.params.prevButton).addClass(s.params.buttonDisabledClass); s.prevButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.prevButton);
} }
else { else {
$(s.params.prevButton).removeClass(s.params.buttonDisabledClass); s.prevButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.prevButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.prevButton);
} }
} }
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
if (s.isEnd) { if (s.isEnd) {
$(s.params.nextButton).addClass(s.params.buttonDisabledClass); s.nextButton.addClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.disable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.disable(s.nextButton);
} }
else { else {
$(s.params.nextButton).removeClass(s.params.buttonDisabledClass); s.nextButton.removeClass(s.params.buttonDisabledClass);
if (s.params.a11y && s.a11y) s.a11y.enable($(s.params.nextButton)); if (s.params.a11y && s.a11y) s.a11y.enable(s.nextButton);
} }
} }
} }
@ -1003,6 +1040,9 @@ s.updatePagination = function () {
} }
s.paginationContainer.html(paginationHTML); s.paginationContainer.html(paginationHTML);
} }
if (s.params.paginationType !== 'custom') {
s.emit('onPaginationRendered', s, s.paginationContainer[0]);
}
} }
}; };
/*========================= /*=========================
@ -1074,6 +1114,7 @@ s.onResize = function (forceUpdatePagination) {
if (s.controller && s.controller.spline) { if (s.controller && s.controller.spline) {
s.controller.spline = undefined; s.controller.spline = undefined;
} }
var slideChangedBySlideTo = false;
if (s.params.freeMode) { if (s.params.freeMode) {
var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate()); var newTranslate = Math.min(Math.max(s.translate, s.maxTranslate()), s.minTranslate());
s.setWrapperTranslate(newTranslate); s.setWrapperTranslate(newTranslate);
@ -1087,12 +1128,15 @@ s.onResize = function (forceUpdatePagination) {
else { else {
s.updateClasses(); s.updateClasses();
if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) { if ((s.params.slidesPerView === 'auto' || s.params.slidesPerView > 1) && s.isEnd && !s.params.centeredSlides) {
s.slideTo(s.slides.length - 1, 0, false, true); slideChangedBySlideTo = s.slideTo(s.slides.length - 1, 0, false, true);
} }
else { else {
s.slideTo(s.activeIndex, 0, false, true); slideChangedBySlideTo = s.slideTo(s.activeIndex, 0, false, true);
} }
} }
if (s.params.lazyLoading && !slideChangedBySlideTo && s.lazy) {
s.lazy.load();
}
// Return locks after resize // Return locks after resize
s.params.allowSwipeToPrev = allowSwipeToPrev; s.params.allowSwipeToPrev = allowSwipeToPrev;
s.params.allowSwipeToNext = allowSwipeToNext; s.params.allowSwipeToNext = allowSwipeToNext;
@ -1148,23 +1192,23 @@ s.initEvents = function (detach) {
window[action]('resize', s.onResize); window[action]('resize', s.onResize);
// Next, Prev, Index // Next, Prev, Index
if (s.params.nextButton) { if (s.params.nextButton && s.nextButton && s.nextButton.length > 0) {
$(s.params.nextButton)[actionDom]('click', s.onClickNext); s.nextButton[actionDom]('click', s.onClickNext);
if (s.params.a11y && s.a11y) $(s.params.nextButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.nextButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.prevButton) { if (s.params.prevButton && s.prevButton && s.prevButton.length > 0) {
$(s.params.prevButton)[actionDom]('click', s.onClickPrev); s.prevButton[actionDom]('click', s.onClickPrev);
if (s.params.a11y && s.a11y) $(s.params.prevButton)[actionDom]('keydown', s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.prevButton[actionDom]('keydown', s.a11y.onEnterKey);
} }
if (s.params.pagination && s.params.paginationClickable) { if (s.params.pagination && s.params.paginationClickable) {
$(s.paginationContainer)[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex); s.paginationContainer[actionDom]('click', '.' + s.params.bulletClass, s.onClickIndex);
if (s.params.a11y && s.a11y) $(s.paginationContainer)[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey); if (s.params.a11y && s.a11y) s.paginationContainer[actionDom]('keydown', '.' + s.params.bulletClass, s.a11y.onEnterKey);
} }
// Prevent Links Clicks // Prevent Links Clicks
if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true); if (s.params.preventClicks || s.params.preventClicksPropagation) touchEventsTarget[action]('click', s.preventClicks, true);
}; };
s.attachEvents = function (detach) { s.attachEvents = function () {
s.initEvents(); s.initEvents();
}; };
s.detachEvents = function () { s.detachEvents = function () {
@ -1360,7 +1404,11 @@ s.onTouchStart = function (e) {
s.onTouchMove = function (e) { s.onTouchMove = function (e) {
if (e.originalEvent) e = e.originalEvent; if (e.originalEvent) e = e.originalEvent;
if (isTouchEvent && e.type === 'mousemove') return; if (isTouchEvent && e.type === 'mousemove') return;
if (e.preventedByNestedSwiper) return; if (e.preventedByNestedSwiper) {
s.touches.startX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
s.touches.startY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
return;
}
if (s.params.onlyExternal) { if (s.params.onlyExternal) {
// isMoved = true; // isMoved = true;
s.allowClick = false; s.allowClick = false;
@ -2125,6 +2173,16 @@ s.destroyLoop = function () {
s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove(); s.wrapper.children('.' + s.params.slideClass + '.' + s.params.slideDuplicateClass).remove();
s.slides.removeAttr('data-swiper-slide-index'); s.slides.removeAttr('data-swiper-slide-index');
}; };
s.reLoop = function (updatePosition) {
var oldIndex = s.activeIndex - s.loopedSlides;
s.destroyLoop();
s.createLoop();
s.updateSlidesSize();
if (updatePosition) {
s.slideTo(oldIndex + s.loopedSlides, 0, false);
}
};
s.fixLoop = function () { s.fixLoop = function () {
var newIndex; var newIndex;
//Fix For Negative Oversliding //Fix For Negative Oversliding

View file

@ -23,7 +23,7 @@ s.lazy = {
srcset = _img.attr('data-srcset'); srcset = _img.attr('data-srcset');
s.loadImage(_img[0], (src || background), srcset, false, function () { s.loadImage(_img[0], (src || background), srcset, false, function () {
if (background) { if (background) {
_img.css('background-image', 'url(' + background + ')'); _img.css('background-image', 'url("' + background + '")');
_img.removeAttr('data-background'); _img.removeAttr('data-background');
} }
else { else {

View file

@ -9,8 +9,14 @@ if (s.params.mousewheelControl) {
try { try {
new window.WheelEvent('wheel'); new window.WheelEvent('wheel');
s.mousewheel.event = 'wheel'; s.mousewheel.event = 'wheel';
} catch (e) {} } catch (e) {
if (window.WheelEvent || (s.container[0] && 'wheel' in s.container[0])) {
s.mousewheel.event = 'wheel';
}
}
if (!s.mousewheel.event && window.WheelEvent) {
}
if (!s.mousewheel.event && document.onmousewheel !== undefined) { if (!s.mousewheel.event && document.onmousewheel !== undefined) {
s.mousewheel.event = 'mousewheel'; s.mousewheel.event = 'mousewheel';
} }
@ -23,10 +29,9 @@ function handleMousewheel(e) {
var we = s.mousewheel.event; var we = s.mousewheel.event;
var delta = 0; var delta = 0;
var rtlFactor = s.rtl ? -1 : 1; var rtlFactor = s.rtl ? -1 : 1;
//Opera & IE
if (e.detail) delta = -e.detail;
//WebKits //WebKits
else if (we === 'mousewheel') { if (we === 'mousewheel') {
if (s.params.mousewheelForceToAxis) { if (s.params.mousewheelForceToAxis) {
if (s.isHorizontal()) { if (s.isHorizontal()) {
if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor; if (Math.abs(e.wheelDeltaX) > Math.abs(e.wheelDeltaY)) delta = e.wheelDeltaX * rtlFactor;

View file

@ -86,6 +86,9 @@ s.scrollbar = {
if (!s.params.scrollbar) return; if (!s.params.scrollbar) return;
var sb = s.scrollbar; var sb = s.scrollbar;
sb.track = $(s.params.scrollbar); sb.track = $(s.params.scrollbar);
if (s.params.uniqueNavElements && typeof s.params.scrollbar === 'string' && sb.track.length > 1 && s.container.find(s.params.scrollbar).length === 1) {
sb.track = s.container.find(s.params.scrollbar);
}
sb.drag = sb.track.find('.swiper-scrollbar-drag'); sb.drag = sb.track.find('.swiper-scrollbar-drag');
if (sb.drag.length === 0) { if (sb.drag.length === 0) {
sb.drag = $('<div class="swiper-scrollbar-drag"></div>'); sb.drag = $('<div class="swiper-scrollbar-drag"></div>');

View file

@ -32,14 +32,14 @@
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0" "iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
}, },
"ignore": [], "ignore": [],
"homepage": "https://github.com/polymerelements/paper-ripple", "homepage": "https://github.com/PolymerElements/paper-ripple",
"_release": "1.0.5", "_release": "1.0.5",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.5", "tag": "v1.0.5",
"commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5" "commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5"
}, },
"_source": "git://github.com/polymerelements/paper-ripple.git", "_source": "git://github.com/PolymerElements/paper-ripple.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "polymerelements/paper-ripple" "_originalSource": "PolymerElements/paper-ripple"
} }