活动按钮状态流转
This commit is contained in:
39
uni_modules/zebra-swiper/libs/check-overflow/index.js
Normal file
39
uni_modules/zebra-swiper/libs/check-overflow/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
function checkOverflow() {
|
||||
const swiper = this;
|
||||
const {
|
||||
isLocked: wasLocked,
|
||||
params
|
||||
} = swiper;
|
||||
const {
|
||||
slidesOffsetBefore
|
||||
} = params;
|
||||
|
||||
if (slidesOffsetBefore) {
|
||||
const lastSlideIndex = swiper.slides.length - 1;
|
||||
const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] +
|
||||
slidesOffsetBefore * 2;
|
||||
swiper.isLocked = swiper.size > lastSlideRightEdge;
|
||||
} else {
|
||||
swiper.isLocked = swiper.snapGrid.length === 1;
|
||||
}
|
||||
|
||||
if (params.allowSlideNext === true) {
|
||||
swiper.allowSlideNext = !swiper.isLocked;
|
||||
}
|
||||
|
||||
if (params.allowSlidePrev === true) {
|
||||
swiper.allowSlidePrev = !swiper.isLocked;
|
||||
}
|
||||
|
||||
if (wasLocked && wasLocked !== swiper.isLocked) {
|
||||
swiper.isEnd = false;
|
||||
}
|
||||
|
||||
if (wasLocked !== swiper.isLocked) {
|
||||
swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
checkOverflow
|
||||
};
|
||||
52
uni_modules/zebra-swiper/libs/classes/addClasses.js
Normal file
52
uni_modules/zebra-swiper/libs/classes/addClasses.js
Normal file
@@ -0,0 +1,52 @@
|
||||
function prepareClasses(entries, prefix) {
|
||||
const resultClasses = [];
|
||||
entries.forEach(item => {
|
||||
if (typeof item === 'object') {
|
||||
Object.keys(item).forEach(classNames => {
|
||||
if (item[classNames]) {
|
||||
resultClasses.push(prefix + classNames);
|
||||
}
|
||||
});
|
||||
} else if (typeof item === 'string') {
|
||||
resultClasses.push(prefix + item);
|
||||
}
|
||||
});
|
||||
return resultClasses;
|
||||
}
|
||||
|
||||
export default function addClasses() {
|
||||
const swiper = this;
|
||||
const {
|
||||
classNames,
|
||||
params,
|
||||
rtl,
|
||||
$el,
|
||||
device,
|
||||
support
|
||||
} = swiper; // prettier-ignore
|
||||
|
||||
const suffixes = prepareClasses(['initialized', params.direction, {
|
||||
'pointer-events': !support.touch
|
||||
}, {
|
||||
'free-mode': swiper.params.freeMode && params.freeMode.enabled
|
||||
}, {
|
||||
'autoheight': params.autoHeight
|
||||
}, {
|
||||
'rtl': rtl
|
||||
}, {
|
||||
'grid': params.grid && params.grid.rows > 1
|
||||
}, {
|
||||
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
|
||||
}, {
|
||||
'android': device.android
|
||||
}, {
|
||||
'ios': device.ios
|
||||
}, {
|
||||
'css-mode': params.cssMode
|
||||
}, {
|
||||
'centered': params.cssMode && params.centeredSlides
|
||||
}], params.containerModifierClass);
|
||||
classNames.push(...suffixes);
|
||||
$el.addClass([...classNames].join(' '));
|
||||
swiper.emitContainerClasses();
|
||||
}
|
||||
6
uni_modules/zebra-swiper/libs/classes/index.js
Normal file
6
uni_modules/zebra-swiper/libs/classes/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import addClasses from './addClasses.js';
|
||||
import removeClasses from './removeClasses.js';
|
||||
export default {
|
||||
addClasses,
|
||||
removeClasses
|
||||
};
|
||||
9
uni_modules/zebra-swiper/libs/classes/removeClasses.js
Normal file
9
uni_modules/zebra-swiper/libs/classes/removeClasses.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export default function removeClasses() {
|
||||
const swiper = this;
|
||||
const {
|
||||
$el,
|
||||
classNames
|
||||
} = swiper;
|
||||
$el.removeClass(classNames.join(' '));
|
||||
swiper.emitContainerClasses();
|
||||
}
|
||||
565
uni_modules/zebra-swiper/libs/core.js
Normal file
565
uni_modules/zebra-swiper/libs/core.js
Normal file
@@ -0,0 +1,565 @@
|
||||
import {
|
||||
extend,
|
||||
now,
|
||||
deleteProps
|
||||
} from '../shared/utils.js';
|
||||
import {
|
||||
getSupport
|
||||
} from '../shared/get-support.js';
|
||||
import {
|
||||
getDevice
|
||||
} from '../shared/get-device.js';
|
||||
import {
|
||||
getBrowser
|
||||
} from '../shared/get-browser.js';
|
||||
import moduleExtendParams from './moduleExtendParams.js';
|
||||
import eventsEmitter from './events-emitter.js';
|
||||
import update from './update/index.js';
|
||||
import translate from './translate/index.js';
|
||||
import transition from './transition/index.js';
|
||||
import defaults from './defaults.js';
|
||||
import classes from './classes/index.js';
|
||||
import checkOverflow from './check-overflow/index.js';
|
||||
import slide from './slide/index.js';
|
||||
import loop from './loop/index.js';
|
||||
import grabCursor from './grab-cursor/index.js';
|
||||
import events from './events/index.js';
|
||||
import {
|
||||
getRect
|
||||
} from './utils/utils.js';
|
||||
const prototypes = {
|
||||
eventsEmitter,
|
||||
update,
|
||||
checkOverflow,
|
||||
slide,
|
||||
loop,
|
||||
translate,
|
||||
transition,
|
||||
grabCursor,
|
||||
events,
|
||||
classes
|
||||
};
|
||||
const extendedDefaults = {};
|
||||
class Swiper {
|
||||
constructor(...args) {
|
||||
const swiper = this;
|
||||
let params;
|
||||
let el;
|
||||
let native;
|
||||
if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) ===
|
||||
'Object') {
|
||||
params = args[0];
|
||||
} else if (args.length === 2 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -
|
||||
1) ===
|
||||
'Object') {
|
||||
params = args[0];
|
||||
native = args[1];
|
||||
} else {
|
||||
[el, params, native] = args;
|
||||
}
|
||||
if (!params) params = {};
|
||||
params = extend({}, params);
|
||||
if (el && !params.el) params.el = el;
|
||||
|
||||
// Swiper Instance
|
||||
swiper.__swiper__ = true;
|
||||
swiper.support = getSupport();
|
||||
swiper.device = getDevice({
|
||||
userAgent: params.userAgent
|
||||
});
|
||||
swiper.browser = getBrowser();
|
||||
|
||||
swiper.eventsListeners = {};
|
||||
swiper.eventsAnyListeners = [];
|
||||
swiper.modules = [...swiper.__modules__];
|
||||
swiper.native = native;
|
||||
if (params.modules && Array.isArray(params.modules)) {
|
||||
swiper.modules.push(...params.modules);
|
||||
}
|
||||
const allModulesParams = {};
|
||||
swiper.modules.forEach(mod => {
|
||||
mod({
|
||||
swiper,
|
||||
extendParams: moduleExtendParams(params, allModulesParams),
|
||||
on: swiper.on.bind(swiper),
|
||||
once: swiper.once.bind(swiper),
|
||||
off: swiper.off.bind(swiper),
|
||||
emit: swiper.emit.bind(swiper)
|
||||
});
|
||||
}); // Extend defaults with modules params
|
||||
const swiperParams = extend({}, defaults, allModulesParams); // Extend defaults with passed params
|
||||
swiper.params = extend({}, swiperParams, extendedDefaults, params);
|
||||
swiper.originalParams = extend({}, swiper.params);
|
||||
swiper.passedParams = extend({}, params); // add event listeners
|
||||
|
||||
if (swiper.params && swiper.params.on) {
|
||||
Object.keys(swiper.params.on).forEach(eventName => {
|
||||
swiper.on(eventName, swiper.params.on[eventName]);
|
||||
});
|
||||
}
|
||||
|
||||
if (swiper.params && swiper.params.onAny) {
|
||||
swiper.onAny(swiper.params.onAny);
|
||||
} // Save Dom lib
|
||||
|
||||
Object.assign(swiper, {
|
||||
enabled: swiper.params.enabled,
|
||||
el,
|
||||
// Classes
|
||||
classNames: [],
|
||||
// Slides
|
||||
slides: [],
|
||||
slidesGrid: [],
|
||||
snapGrid: [],
|
||||
slidesSizesGrid: [],
|
||||
|
||||
// isDirection
|
||||
isHorizontal() {
|
||||
return swiper.params.direction === 'horizontal';
|
||||
},
|
||||
|
||||
isVertical() {
|
||||
return swiper.params.direction === 'vertical';
|
||||
},
|
||||
|
||||
// Indexes
|
||||
activeIndex: 0,
|
||||
realIndex: 0,
|
||||
//
|
||||
isBeginning: true,
|
||||
isEnd: false,
|
||||
// Props
|
||||
translate: 0,
|
||||
previousTranslate: 0,
|
||||
progress: 0,
|
||||
velocity: 0,
|
||||
animating: false,
|
||||
// Locks
|
||||
allowSlideNext: swiper.params.allowSlideNext,
|
||||
allowSlidePrev: swiper.params.allowSlidePrev,
|
||||
// Touch Events
|
||||
touchEvents: function touchEvents() {
|
||||
const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
|
||||
const desktop = ['pointerdown', 'pointermove', 'pointerup'];
|
||||
swiper.touchEventsTouch = {
|
||||
start: touch[0],
|
||||
move: touch[1],
|
||||
end: touch[2],
|
||||
cancel: touch[3]
|
||||
};
|
||||
swiper.touchEventsDesktop = {
|
||||
start: desktop[0],
|
||||
move: desktop[1],
|
||||
end: desktop[2]
|
||||
};
|
||||
return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch :
|
||||
swiper.touchEventsDesktop;
|
||||
}(),
|
||||
touchEventsData: {
|
||||
isTouched: undefined,
|
||||
isMoved: undefined,
|
||||
allowTouchCallbacks: undefined,
|
||||
touchStartTime: undefined,
|
||||
isScrolling: undefined,
|
||||
currentTranslate: undefined,
|
||||
startTranslate: undefined,
|
||||
allowThresholdMove: undefined,
|
||||
// Form elements to match
|
||||
focusableElements: swiper.params.focusableElements,
|
||||
// Last click time
|
||||
lastClickTime: now(),
|
||||
clickTimeout: undefined,
|
||||
// Velocities
|
||||
velocities: [],
|
||||
allowMomentumBounce: undefined,
|
||||
isTouchEvent: undefined,
|
||||
startMoving: undefined
|
||||
},
|
||||
// Clicks
|
||||
allowClick: true,
|
||||
// Touches
|
||||
allowTouchMove: swiper.params.allowTouchMove,
|
||||
touches: {
|
||||
startX: 0,
|
||||
startY: 0,
|
||||
currentX: 0,
|
||||
currentY: 0,
|
||||
diff: 0
|
||||
},
|
||||
// Images
|
||||
imagesToLoad: [],
|
||||
imagesLoaded: 0,
|
||||
virtualList: [],
|
||||
virtualIndexList: [],
|
||||
});
|
||||
swiper.emit('_swiper'); // Init
|
||||
|
||||
if (swiper.params.init) {
|
||||
swiper.init();
|
||||
} // Return app instance
|
||||
return swiper;
|
||||
|
||||
|
||||
}
|
||||
|
||||
enable() {
|
||||
const swiper = this;
|
||||
if (swiper.enabled) return;
|
||||
swiper.enabled = true;
|
||||
if (swiper.params.grabCursor) {
|
||||
swiper.setGrabCursor();
|
||||
}
|
||||
swiper.emit('enable');
|
||||
}
|
||||
|
||||
disable() {
|
||||
const swiper = this;
|
||||
if (!swiper.enabled) return;
|
||||
swiper.enabled = false;
|
||||
if (swiper.params.grabCursor) {
|
||||
swiper.unsetGrabCursor();
|
||||
}
|
||||
swiper.emit('disable');
|
||||
}
|
||||
|
||||
setProgress(progress, speed) {
|
||||
const swiper = this;
|
||||
progress = Math.min(Math.max(progress, 0), 1);
|
||||
const min = swiper.minTranslate();
|
||||
const max = swiper.maxTranslate();
|
||||
const current = (max - min) * progress + min;
|
||||
swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
|
||||
swiper.updateActiveIndex();
|
||||
swiper.updateSlidesClasses();
|
||||
}
|
||||
|
||||
emitContainerClasses() {
|
||||
const swiper = this;
|
||||
if (!swiper.params._emitClasses || !swiper.el) return;
|
||||
const cls = swiper.native.contentClass.split(' ').filter(className => {
|
||||
return className.indexOf('swiper') === 0 || className.indexOf(swiper.params
|
||||
.containerModifierClass) === 0;
|
||||
});
|
||||
swiper.emit('_containerClasses', cls.join(' '));
|
||||
}
|
||||
|
||||
getSlideClasses(slideEl) {
|
||||
const swiper = this;
|
||||
return slideEl.slideClass.split(' ').filter(className => {
|
||||
return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params
|
||||
.slideClass) === 0;
|
||||
}).join(' ');
|
||||
}
|
||||
|
||||
emitSlidesClasses() {
|
||||
const swiper = this;
|
||||
if (!swiper.params._emitClasses || !swiper.el) return;
|
||||
const updates = [];
|
||||
swiper.slides.forEach(slideEl => {
|
||||
const classNames = swiper.getSlideClasses(slideEl);
|
||||
updates.push({
|
||||
slideEl,
|
||||
classNames
|
||||
});
|
||||
swiper.emit('_slideClass', slideEl, classNames);
|
||||
});
|
||||
swiper.emit('_slideClasses', updates);
|
||||
}
|
||||
|
||||
slidesPerViewDynamic(view = 'current', exact = false) {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
slides,
|
||||
slidesGrid,
|
||||
slidesSizesGrid,
|
||||
size: swiperSize,
|
||||
activeIndex
|
||||
} = swiper;
|
||||
let spv = 1;
|
||||
if (params.centeredSlides) {
|
||||
let slideSize = slides[activeIndex].swiperSlideSize;
|
||||
let breakLoop;
|
||||
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
||||
if (slides[i] && !breakLoop) {
|
||||
slideSize += slides[i].swiperSlideSize;
|
||||
spv += 1;
|
||||
if (slideSize > swiperSize) breakLoop = true;
|
||||
}
|
||||
}
|
||||
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
||||
if (slides[i] && !breakLoop) {
|
||||
slideSize += slides[i].swiperSlideSize;
|
||||
spv += 1;
|
||||
if (slideSize > swiperSize) breakLoop = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// eslint-disable-next-line
|
||||
if (view === 'current') {
|
||||
for (let i = activeIndex + 1; i < slides.length; i += 1) {
|
||||
const slideInView = exact ?
|
||||
slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize :
|
||||
slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
|
||||
if (slideInView) {
|
||||
spv += 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// previous
|
||||
for (let i = activeIndex - 1; i >= 0; i -= 1) {
|
||||
const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
|
||||
if (slideInView) {
|
||||
spv += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return spv;
|
||||
}
|
||||
|
||||
changeDirection(newDirection, needUpdate) {
|
||||
if (needUpdate === void 0) {
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
const swiper = this;
|
||||
const currentDirection = swiper.params.direction;
|
||||
|
||||
if (!newDirection) {
|
||||
// eslint-disable-next-line
|
||||
newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
||||
}
|
||||
|
||||
if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
||||
return swiper;
|
||||
}
|
||||
|
||||
swiper.$wrapperEl.removeClass(`${swiper.params.containerModifierClass}${currentDirection}`)
|
||||
swiper.$wrapperEl.addClass(
|
||||
`${swiper.params.containerModifierClass}${newDirection}`);
|
||||
swiper.emitContainerClasses();
|
||||
swiper.params.direction = newDirection;
|
||||
swiper.slides.forEach(slideEl => {
|
||||
if (newDirection === 'vertical') {
|
||||
slideEl.css({
|
||||
width: ''
|
||||
})
|
||||
} else {
|
||||
slideEl.css({
|
||||
height: ''
|
||||
})
|
||||
}
|
||||
});
|
||||
swiper.emit('changeDirection');
|
||||
if (needUpdate) swiper.update();
|
||||
return swiper;
|
||||
}
|
||||
|
||||
async update(el) {
|
||||
const swiper = this;
|
||||
if (!swiper || swiper.destroyed) return;
|
||||
const {
|
||||
snapGrid,
|
||||
params
|
||||
} = swiper; // Breakpoints
|
||||
|
||||
|
||||
el = await swiper.native.getRect();
|
||||
if (!el) {
|
||||
return false;
|
||||
}
|
||||
Object.assign(swiper, {
|
||||
el,
|
||||
$el: swiper.native,
|
||||
});
|
||||
swiper.emit('beforeUpdate');
|
||||
if (params.breakpoints) {
|
||||
swiper.setBreakpoint();
|
||||
}
|
||||
swiper.updateSize();
|
||||
swiper.updateSlides();
|
||||
swiper.updateProgress();
|
||||
swiper.updateSlidesClasses();
|
||||
|
||||
function setTranslate() {
|
||||
const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
|
||||
const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
|
||||
swiper.setTranslate(newTranslate);
|
||||
swiper.updateActiveIndex();
|
||||
swiper.updateSlidesClasses();
|
||||
}
|
||||
|
||||
let translated;
|
||||
|
||||
if (swiper.params.freeMode && swiper.params.freeMode.enabled) {
|
||||
setTranslate();
|
||||
|
||||
if (swiper.params.autoHeight) {
|
||||
swiper.updateAutoHeight();
|
||||
}
|
||||
} else {
|
||||
if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !
|
||||
swiper.params.centeredSlides) {
|
||||
translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
||||
} else {
|
||||
translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
||||
}
|
||||
|
||||
if (!translated) {
|
||||
setTranslate();
|
||||
}
|
||||
}
|
||||
|
||||
if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
||||
swiper.checkOverflow();
|
||||
}
|
||||
swiper.emit('update');
|
||||
}
|
||||
async mount(el) {
|
||||
const swiper = this;
|
||||
if (swiper.mounted) return true; // Find el
|
||||
el = await swiper.native.getRect();
|
||||
if (!el) {
|
||||
return false;
|
||||
}
|
||||
swiper.emit('beforeMount'); // Set breakpoint
|
||||
// let $wrapperEl = new DomSimulation(swiper.native);
|
||||
// let $el = new DomSimulation(swiper.native);
|
||||
// if (swiper.native && swiper.native.children && swiper.native.children.length) {
|
||||
// swiper.native.children.forEach((item) => {
|
||||
// item.$itemEl = new ChildDomSimulation(item);
|
||||
// })
|
||||
// }
|
||||
Object.assign(swiper, {
|
||||
$el: swiper.native,
|
||||
el,
|
||||
$wrapperEl: swiper.native,
|
||||
wrapperEl: swiper.native,
|
||||
mounted: true,
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
async init(el) {
|
||||
const swiper = this;
|
||||
if (swiper.initialized) return swiper;
|
||||
const mounted = await swiper.mount(el);
|
||||
if (mounted === false) return swiper;
|
||||
swiper.emit('beforeInit'); // Set breakpoint
|
||||
|
||||
swiper.addClasses(); // Create loop
|
||||
|
||||
if (swiper.params.loop) {
|
||||
swiper.loopCreate();
|
||||
} // Update size
|
||||
|
||||
swiper.updateSize(); // Update slides
|
||||
|
||||
swiper.updateSlides();
|
||||
|
||||
if (swiper.params.watchOverflow) {
|
||||
swiper.checkOverflow();
|
||||
} // Set Grab Cursor
|
||||
|
||||
|
||||
if (swiper.params.grabCursor && swiper.enabled) {
|
||||
swiper.setGrabCursor();
|
||||
}
|
||||
|
||||
// if (swiper.params.loop) {
|
||||
// swiper.on("update", () => {
|
||||
// swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params
|
||||
// .runCallbacksOnInit,
|
||||
// false, true);
|
||||
// })
|
||||
// } else {
|
||||
// swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
||||
// } // Attach events
|
||||
// Slide To Initial Slide
|
||||
if (swiper.params.loop) {
|
||||
swiper.slideTo(
|
||||
swiper.params.initialSlide + swiper.loopedSlides,
|
||||
0,
|
||||
swiper.params.runCallbacksOnInit,
|
||||
false,
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
|
||||
}
|
||||
swiper.attachEvents(); // Init Flag
|
||||
swiper.initialized = true; // Emit
|
||||
swiper.emit('init');
|
||||
swiper.emit('afterInit');
|
||||
return swiper;
|
||||
}
|
||||
destroy(deleteInstance = true, cleanStyles = true) {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
$el,
|
||||
$wrapperEl,
|
||||
slides
|
||||
} = swiper;
|
||||
|
||||
if (typeof swiper.params === 'undefined' || swiper.destroyed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
swiper.emit('beforeDestroy'); // Init Flag
|
||||
|
||||
swiper.initialized = false; // Detach events
|
||||
|
||||
swiper.detachEvents(); // Destroy loop
|
||||
|
||||
if (params.loop) {
|
||||
swiper.loopDestroy();
|
||||
} // Cleanup styles
|
||||
|
||||
swiper.emit('destroy'); // Detach emitter events
|
||||
|
||||
Object.keys(swiper.eventsListeners).forEach(eventName => {
|
||||
swiper.off(eventName);
|
||||
});
|
||||
|
||||
if (deleteInstance !== false) {
|
||||
deleteProps(swiper);
|
||||
}
|
||||
|
||||
swiper.destroyed = true;
|
||||
return null;
|
||||
}
|
||||
static extendDefaults(newDefaults) {
|
||||
extend(extendedDefaults, newDefaults);
|
||||
}
|
||||
static get extendedDefaults() {
|
||||
return extendedDefaults;
|
||||
}
|
||||
static get defaults() {
|
||||
return defaults;
|
||||
}
|
||||
static installModule(mod) {
|
||||
if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
|
||||
const modules = Swiper.prototype.__modules__;
|
||||
|
||||
if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
|
||||
modules.push(mod);
|
||||
}
|
||||
}
|
||||
static use(module) {
|
||||
if (Array.isArray(module)) {
|
||||
module.forEach(m => Swiper.installModule(m));
|
||||
return Swiper;
|
||||
}
|
||||
|
||||
Swiper.installModule(module);
|
||||
return Swiper;
|
||||
}
|
||||
}
|
||||
Object.keys(prototypes).forEach(prototypeGroup => {
|
||||
Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
|
||||
Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
|
||||
});
|
||||
});
|
||||
export default Swiper;
|
||||
182
uni_modules/zebra-swiper/libs/core.scss
Normal file
182
uni_modules/zebra-swiper/libs/core.scss
Normal file
@@ -0,0 +1,182 @@
|
||||
$themeColor: #007aff !default;
|
||||
|
||||
:root {
|
||||
--swiper-theme-color: #{$themeColor};
|
||||
}
|
||||
.swiper {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
/* Fix of Webkit flickering */
|
||||
z-index: 1;
|
||||
}
|
||||
.swiper-vertical > .swiper-wrapper {
|
||||
flex-direction: column;
|
||||
}
|
||||
.swiper-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
transition-property: transform;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.swiper-android .swiper-slide,
|
||||
.swiper-wrapper {
|
||||
transform: translate3d(0px, 0, 0);
|
||||
}
|
||||
.swiper-pointer-events {
|
||||
touch-action: pan-y;
|
||||
&.swiper-vertical {
|
||||
touch-action: pan-x;
|
||||
}
|
||||
}
|
||||
.swiper-slide {
|
||||
flex-shrink: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
transition-property: transform;
|
||||
}
|
||||
.swiper-slide-invisible-blank {
|
||||
visibility: hidden;
|
||||
}
|
||||
/* Auto Height */
|
||||
.swiper-autoheight {
|
||||
&,
|
||||
.swiper-slide {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.swiper-wrapper {
|
||||
align-items: flex-start;
|
||||
transition-property: transform, height;
|
||||
}
|
||||
}
|
||||
.swiper-slide-3d{
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
/* 3D Effects */
|
||||
.swiper-3d {
|
||||
&,
|
||||
&.swiper-css-mode .swiper-wrapper {
|
||||
perspective: 1200px;
|
||||
}
|
||||
.swiper-wrapper,
|
||||
.swiper-slide,
|
||||
.swiper-slide-shadow,
|
||||
.swiper-slide-shadow-left,
|
||||
.swiper-slide-shadow-right,
|
||||
.swiper-slide-shadow-top,
|
||||
.swiper-slide-shadow-bottom,
|
||||
.swiper-cube-shadow {
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
.swiper-slide-shadow,
|
||||
.swiper-slide-shadow-left,
|
||||
.swiper-slide-shadow-right,
|
||||
.swiper-slide-shadow-top,
|
||||
.swiper-slide-shadow-bottom {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
}
|
||||
.swiper-slide-shadow {
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.swiper-slide-shadow-left {
|
||||
background-image: linear-gradient(to left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
}
|
||||
.swiper-slide-shadow-right {
|
||||
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
}
|
||||
.swiper-slide-shadow-top {
|
||||
background-image: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
}
|
||||
.swiper-slide-shadow-bottom {
|
||||
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/* CSS Mode */
|
||||
.swiper-css-mode {
|
||||
> .swiper-wrapper {
|
||||
overflow: auto;
|
||||
scrollbar-width: none; /* For Firefox */
|
||||
-ms-overflow-style: none; /* For Internet Explorer and Edge */
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
> .swiper-wrapper > .swiper-slide {
|
||||
scroll-snap-align: start start;
|
||||
}
|
||||
}
|
||||
.swiper-horizontal.swiper-css-mode {
|
||||
> .swiper-wrapper {
|
||||
scroll-snap-type: x mandatory;
|
||||
}
|
||||
}
|
||||
.swiper-vertical.swiper-css-mode {
|
||||
> .swiper-wrapper {
|
||||
scroll-snap-type: y mandatory;
|
||||
}
|
||||
}
|
||||
|
||||
.swiper-horizontal {
|
||||
touch-action: pan-y;
|
||||
}
|
||||
.swiper-vertical {
|
||||
touch-action: pan-x;
|
||||
}
|
||||
|
||||
.swiper-centered {
|
||||
> .swiper-wrapper::before {
|
||||
content: '';
|
||||
flex-shrink: 0;
|
||||
order: 9999;
|
||||
}
|
||||
&.swiper-horizontal {
|
||||
> .swiper-wrapper > .swiper-slide:first-child {
|
||||
margin-inline-start: var(--swiper-centered-offset-before);
|
||||
}
|
||||
> .swiper-wrapper::before {
|
||||
height: 100%;
|
||||
width: var(--swiper-centered-offset-after);
|
||||
}
|
||||
}
|
||||
&.swiper-vertical {
|
||||
> .swiper-wrapper > .swiper-slide:first-child {
|
||||
margin-block-start: var(--swiper-centered-offset-before);
|
||||
}
|
||||
> .swiper-wrapper::before {
|
||||
width: 100%;
|
||||
height: var(--swiper-centered-offset-after);
|
||||
}
|
||||
}
|
||||
|
||||
> .swiper-wrapper > .swiper-slide {
|
||||
scroll-snap-align: center center;
|
||||
}
|
||||
}
|
||||
|
||||
@import "../modules/effect-fade/effect-fade.scss";
|
||||
@import "../modules/effect-cube/effect-cube.scss";
|
||||
@import "../modules/effect-coverflow/effect-coverflow.scss";
|
||||
@import "../modules/effect-flip/effect-flip.scss";
|
||||
@import "../modules/effect-cards/effect-cards.scss";
|
||||
@import "../modules/effect-creative/effect-creative.scss";
|
||||
@import "../modules/effect-panorama/effect-panorama.scss";
|
||||
@import "../modules/effect-carousel/effect-carousel.scss";
|
||||
@import "../modules/navigation/navigation.scss";
|
||||
@import "../modules/pagination/pagination.scss";
|
||||
@import "../modules/thumbs/thumbs.scss";
|
||||
@import "../modules/scrollbar/scrollbar.scss";
|
||||
126
uni_modules/zebra-swiper/libs/defaults.js
Normal file
126
uni_modules/zebra-swiper/libs/defaults.js
Normal file
@@ -0,0 +1,126 @@
|
||||
export default {
|
||||
init: true,
|
||||
direction: 'horizontal',
|
||||
touchEventsTarget: 'wrapper',
|
||||
initialSlide: 0,
|
||||
speed: 300,
|
||||
cssMode: false,
|
||||
updateOnWindowResize: true,
|
||||
resizeObserver: true,
|
||||
nested: false,
|
||||
createElements: false,
|
||||
enabled: true,
|
||||
focusableElements: 'input, select, option, textarea, button, video, label',
|
||||
// Overrides
|
||||
width: null,
|
||||
height: null,
|
||||
//
|
||||
preventInteractionOnTransition: false,
|
||||
// ssr
|
||||
userAgent: null,
|
||||
url: null,
|
||||
// To support iOS's swipe-to-go-back gesture (when being used in-app).
|
||||
edgeSwipeDetection: false,
|
||||
edgeSwipeThreshold: 20,
|
||||
// Autoheight
|
||||
autoHeight: false,
|
||||
// Set wrapper width
|
||||
setWrapperSize: false,
|
||||
// Virtual Translate
|
||||
virtualTranslate: false,
|
||||
virtualList: [],
|
||||
virtualIndexList: [],
|
||||
// Effects
|
||||
effect: 'slide',
|
||||
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
|
||||
// Breakpoints
|
||||
breakpoints: undefined,
|
||||
breakpointsBase: 'window',
|
||||
// Slides grid
|
||||
spaceBetween: 0,
|
||||
slidesPerView: 1,
|
||||
slidesPerGroup: 1,
|
||||
slidesPerGroupSkip: 0,
|
||||
slidesPerGroupAuto: false,
|
||||
centeredSlides: false,
|
||||
centeredSlidesBounds: false,
|
||||
slidesOffsetBefore: 0,
|
||||
// in px
|
||||
slidesOffsetAfter: 0,
|
||||
// in px
|
||||
normalizeSlideIndex: true,
|
||||
centerInsufficientSlides: false,
|
||||
// Disable swiper and hide navigation when container not overflow
|
||||
watchOverflow: true,
|
||||
// Round length
|
||||
roundLengths: false,
|
||||
// Touches
|
||||
touchRatio: 1,
|
||||
touchAngle: 45,
|
||||
simulateTouch: true,
|
||||
shortSwipes: true,
|
||||
longSwipes: true,
|
||||
longSwipesRatio: 0.5,
|
||||
longSwipesMs: 300,
|
||||
followFinger: true,
|
||||
allowTouchMove: true,
|
||||
threshold: 0,
|
||||
touchMoveStopPropagation: false,
|
||||
touchStartPreventDefault: true,
|
||||
touchStartForcePreventDefault: false,
|
||||
touchReleaseOnEdges: false,
|
||||
// Unique Navigation Elements
|
||||
uniqueNavElements: true,
|
||||
// Resistance
|
||||
resistance: true,
|
||||
resistanceRatio: 0.85,
|
||||
// Progress
|
||||
watchSlidesProgress: false,
|
||||
// Cursor
|
||||
grabCursor: false,
|
||||
// Clicks
|
||||
preventClicks: true,
|
||||
preventClicksPropagation: true,
|
||||
slideToClickedSlide: false,
|
||||
// Images
|
||||
preloadImages: true,
|
||||
updateOnImagesReady: true,
|
||||
// loop
|
||||
loop: false,
|
||||
loopAdditionalSlides: 0,
|
||||
loopedSlides: null,
|
||||
loopFillGroupWithBlank: false,
|
||||
loopPreventsSlide: true,
|
||||
// rewind
|
||||
rewind: false,
|
||||
// Swiping/no swiping
|
||||
allowSlidePrev: true,
|
||||
allowSlideNext: true,
|
||||
swipeHandler: null,
|
||||
// '.swipe-handler',
|
||||
noSwiping: false,
|
||||
noSwipingClass: 'swiper-no-swiping',
|
||||
noSwipingSelector: null,
|
||||
// Passive Listeners
|
||||
passiveListeners: true,
|
||||
// NS
|
||||
containerModifierClass: 'swiper-',
|
||||
// NEW
|
||||
slideClass: 'swiper-slide',
|
||||
slideBlankClass: 'swiper-slide-invisible-blank',
|
||||
slideActiveClass: 'swiper-slide-active',
|
||||
slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
|
||||
slideVisibleClass: 'swiper-slide-visible',
|
||||
slideDuplicateClass: 'swiper-slide-duplicate',
|
||||
slideNextClass: 'swiper-slide-next',
|
||||
slideDuplicateNextClass: 'swiper-slide-duplicate-next',
|
||||
slidePrevClass: 'swiper-slide-prev',
|
||||
slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
|
||||
wrapperClass: 'swiper-wrapper',
|
||||
slideThumbsClass: 'swiper-slide-thumb',
|
||||
// Callbacks
|
||||
runCallbacksOnInit: true,
|
||||
// Internals
|
||||
_emitClasses: false,
|
||||
willChange: false
|
||||
};
|
||||
115
uni_modules/zebra-swiper/libs/events-emitter.js
Normal file
115
uni_modules/zebra-swiper/libs/events-emitter.js
Normal file
@@ -0,0 +1,115 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
export default {
|
||||
on(events, handler, priority) {
|
||||
const self = this;
|
||||
|
||||
if (typeof handler !== 'function') return self;
|
||||
const method = priority ? 'unshift' : 'push';
|
||||
events.split(' ').forEach(event => {
|
||||
if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
|
||||
self.eventsListeners[event][method](handler);
|
||||
});
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
once(events, handler, priority) {
|
||||
const self = this;
|
||||
if (typeof handler !== 'function') return self;
|
||||
|
||||
function onceHandler(...args) {
|
||||
self.off(events, onceHandler);
|
||||
|
||||
if (onceHandler.__emitterProxy) {
|
||||
delete onceHandler.__emitterProxy;
|
||||
}
|
||||
|
||||
handler.apply(self, args);
|
||||
}
|
||||
|
||||
onceHandler.__emitterProxy = handler;
|
||||
return self.on(events, onceHandler, priority);
|
||||
},
|
||||
|
||||
onAny(handler, priority) {
|
||||
const self = this;
|
||||
if (typeof handler !== 'function') return self;
|
||||
const method = priority ? 'unshift' : 'push';
|
||||
|
||||
if (self.eventsAnyListeners.indexOf(handler) < 0) {
|
||||
self.eventsAnyListeners[method](handler);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
offAny(handler) {
|
||||
const self = this;
|
||||
if (!self.eventsAnyListeners) return self;
|
||||
const index = self.eventsAnyListeners.indexOf(handler);
|
||||
|
||||
if (index >= 0) {
|
||||
self.eventsAnyListeners.splice(index, 1);
|
||||
}
|
||||
|
||||
return self;
|
||||
},
|
||||
|
||||
off(events, handler) {
|
||||
const self = this;
|
||||
if (!self.eventsListeners) return self;
|
||||
events.split(' ').forEach(event => {
|
||||
// self.native.off(event, handler);
|
||||
if (typeof handler === 'undefined') {
|
||||
self.eventsListeners[event] = [];
|
||||
} else if (self.eventsListeners[event]) {
|
||||
self.eventsListeners[event].forEach((eventHandler, index) => {
|
||||
if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler
|
||||
.__emitterProxy === handler) {
|
||||
self.eventsListeners[event].splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return self;
|
||||
},
|
||||
|
||||
emit(...args) {
|
||||
const self = this;
|
||||
if (!self.eventsListeners) return self;
|
||||
let events;
|
||||
let data;
|
||||
let context;
|
||||
|
||||
if (typeof args[0] === 'string' || Array.isArray(args[0])) {
|
||||
events = args[0];
|
||||
data = args.slice(1, args.length);
|
||||
context = self;
|
||||
} else {
|
||||
events = args[0].events;
|
||||
data = args[0].data;
|
||||
context = args[0].context || self;
|
||||
}
|
||||
|
||||
data.unshift(context);
|
||||
|
||||
const eventsArray = Array.isArray(events) ? events : events.split(' ');
|
||||
|
||||
eventsArray.forEach(event => {
|
||||
// console.log(event)
|
||||
if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
|
||||
self.eventsAnyListeners.forEach(eventHandler => {
|
||||
eventHandler.apply(context, [event, ...data]);
|
||||
});
|
||||
}
|
||||
if (self.eventsListeners && self.eventsListeners[event]) {
|
||||
self.eventsListeners[event].forEach(eventHandler => {
|
||||
eventHandler.apply(context, data);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
};
|
||||
80
uni_modules/zebra-swiper/libs/events/index.js
Normal file
80
uni_modules/zebra-swiper/libs/events/index.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import onTouchStart from './onTouchStart.js';
|
||||
import onTouchMove from './onTouchMove.js';
|
||||
import onTouchEnd from './onTouchEnd.js';
|
||||
import onResize from './onResize.js';
|
||||
import onClick from './onClick.js';
|
||||
import onScroll from './onScroll.js';
|
||||
let dummyEventAttached = false;
|
||||
|
||||
function dummyEventListener() {}
|
||||
|
||||
const events = (swiper, method) => {
|
||||
const {
|
||||
params,
|
||||
touchEvents,
|
||||
wrapperEl,
|
||||
device,
|
||||
support
|
||||
} = swiper;
|
||||
let el = swiper.native;
|
||||
const capture = !!params.nested;
|
||||
const domMethod = method === 'on' ? 'on' : 'off';
|
||||
const swiperMethod = method;
|
||||
if (!support.touch) {
|
||||
let desktopMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
|
||||
if (document.querySelector(`#${swiper.$el.swiperElId}`)) {
|
||||
document.querySelector(`#${swiper.$el.swiperElId}`)[desktopMethod](touchEvents.start, swiper
|
||||
.onTouchStart,
|
||||
false);
|
||||
}
|
||||
document[desktopMethod](touchEvents.move, swiper.onTouchMove, capture);
|
||||
document[desktopMethod](touchEvents.end, swiper.onTouchEnd, false);
|
||||
} else {
|
||||
const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params
|
||||
.passiveListeners ? {
|
||||
passive: true,
|
||||
capture: false
|
||||
} : false;
|
||||
}
|
||||
|
||||
// Resize handler
|
||||
if (params.updateOnWindowResize) {
|
||||
swiper[swiperMethod](
|
||||
device.ios || device.android ?
|
||||
'resize orientationchange observerUpdate' :
|
||||
'resize observerUpdate',
|
||||
onResize,
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
swiper[swiperMethod]('observerUpdate', onResize, true);
|
||||
}
|
||||
};
|
||||
|
||||
function attachEvents() {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
support
|
||||
} = swiper;
|
||||
swiper.onTouchStart = onTouchStart.bind(swiper);
|
||||
swiper.onTouchMove = onTouchMove.bind(swiper);
|
||||
swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
||||
if (params.cssMode) {
|
||||
swiper.onScroll = onScroll.bind(swiper);
|
||||
}
|
||||
|
||||
swiper.onClick = onClick.bind(swiper);
|
||||
|
||||
events(swiper, 'on');
|
||||
}
|
||||
|
||||
function detachEvents() {
|
||||
const swiper = this;
|
||||
events(swiper, 'off');
|
||||
}
|
||||
|
||||
export default {
|
||||
attachEvents,
|
||||
detachEvents
|
||||
};
|
||||
13
uni_modules/zebra-swiper/libs/events/onClick.js
Normal file
13
uni_modules/zebra-swiper/libs/events/onClick.js
Normal file
@@ -0,0 +1,13 @@
|
||||
export default function onClick(e) {
|
||||
const swiper = this;
|
||||
if (!swiper.enabled) return;
|
||||
|
||||
if (!swiper.allowClick) {
|
||||
if (swiper.params.preventClicks) e.preventDefault();
|
||||
|
||||
if (swiper.params.preventClicksPropagation && swiper.animating) {
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
43
uni_modules/zebra-swiper/libs/events/onResize.js
Normal file
43
uni_modules/zebra-swiper/libs/events/onResize.js
Normal file
@@ -0,0 +1,43 @@
|
||||
export default function onResize() {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
el
|
||||
} = swiper;
|
||||
if (el && el.offsetWidth === 0) return;
|
||||
|
||||
if (params.breakpoints) {
|
||||
swiper.setBreakpoint();
|
||||
}
|
||||
|
||||
|
||||
const {
|
||||
allowSlideNext,
|
||||
allowSlidePrev,
|
||||
snapGrid
|
||||
} = swiper;
|
||||
|
||||
swiper.allowSlideNext = true;
|
||||
swiper.allowSlidePrev = true;
|
||||
swiper.updateSize();
|
||||
swiper.updateSlides();
|
||||
swiper.updateSlidesClasses();
|
||||
|
||||
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
||||
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
||||
} else {
|
||||
swiper.slideTo(swiper.activeIndex, 0, false, true);
|
||||
}
|
||||
|
||||
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
||||
swiper.autoplay.run();
|
||||
}
|
||||
|
||||
|
||||
swiper.allowSlidePrev = allowSlidePrev;
|
||||
swiper.allowSlideNext = allowSlideNext;
|
||||
|
||||
if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
||||
swiper.checkOverflow();
|
||||
}
|
||||
}
|
||||
35
uni_modules/zebra-swiper/libs/events/onScroll.js
Normal file
35
uni_modules/zebra-swiper/libs/events/onScroll.js
Normal file
@@ -0,0 +1,35 @@
|
||||
export default function onScroll() {
|
||||
const swiper = this;
|
||||
const {
|
||||
wrapperEl,
|
||||
rtlTranslate,
|
||||
enabled
|
||||
} = swiper;
|
||||
if (!enabled) return;
|
||||
swiper.previousTranslate = swiper.translate;
|
||||
|
||||
if (swiper.isHorizontal()) {
|
||||
swiper.translate = -wrapperEl.scrollLeft;
|
||||
} else {
|
||||
swiper.translate = -wrapperEl.scrollTop;
|
||||
} // eslint-disable-next-line
|
||||
|
||||
|
||||
if (swiper.translate === -0) swiper.translate = 0;
|
||||
swiper.updateActiveIndex();
|
||||
swiper.updateSlidesClasses();
|
||||
let newProgress;
|
||||
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
||||
|
||||
if (translatesDiff === 0) {
|
||||
newProgress = 0;
|
||||
} else {
|
||||
newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
|
||||
}
|
||||
|
||||
if (newProgress !== swiper.progress) {
|
||||
swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
|
||||
}
|
||||
|
||||
swiper.emit('setTranslate', swiper.translate, false);
|
||||
}
|
||||
147
uni_modules/zebra-swiper/libs/events/onTouchEnd.js
Normal file
147
uni_modules/zebra-swiper/libs/events/onTouchEnd.js
Normal file
@@ -0,0 +1,147 @@
|
||||
import {
|
||||
now,
|
||||
nextTick
|
||||
} from '../../shared/utils.js';
|
||||
export default function onTouchEnd(event) {
|
||||
const swiper = this;
|
||||
const data = swiper.touchEventsData;
|
||||
const {
|
||||
params,
|
||||
touches,
|
||||
rtlTranslate: rtl,
|
||||
slidesGrid,
|
||||
enabled
|
||||
} = swiper;
|
||||
if (!enabled) return;
|
||||
let e = event;
|
||||
if (e.originalEvent) e = e.originalEvent;
|
||||
|
||||
if (data.allowTouchCallbacks) {
|
||||
swiper.emit('touch-end', e);
|
||||
}
|
||||
|
||||
data.allowTouchCallbacks = false;
|
||||
|
||||
if (!data.isTouched) {
|
||||
if (data.isMoved && params.grabCursor) {
|
||||
swiper.setGrabCursor(false);
|
||||
}
|
||||
|
||||
data.isMoved = false;
|
||||
data.startMoving = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper
|
||||
.allowSlidePrev === true)) {
|
||||
swiper.setGrabCursor(false);
|
||||
}
|
||||
|
||||
|
||||
const touchEndTime = now();
|
||||
const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click
|
||||
|
||||
if (swiper.allowClick) {
|
||||
const pathTree = e.path || e.composedPath && e.composedPath();
|
||||
// swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
|
||||
swiper.emit('tap click', e);
|
||||
|
||||
if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
|
||||
swiper.emit('doubleTap doubleClick', e);
|
||||
}
|
||||
}
|
||||
|
||||
data.lastClickTime = now();
|
||||
nextTick(() => {
|
||||
if (!swiper.destroyed) swiper.allowClick = true;
|
||||
});
|
||||
|
||||
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate ===
|
||||
data.startTranslate) {
|
||||
data.isTouched = false;
|
||||
data.isMoved = false;
|
||||
data.startMoving = false;
|
||||
return;
|
||||
}
|
||||
|
||||
data.isTouched = false;
|
||||
data.isMoved = false;
|
||||
data.startMoving = false;
|
||||
let currentPos;
|
||||
|
||||
if (params.followFinger) {
|
||||
currentPos = rtl ? swiper.translate : -swiper.translate;
|
||||
} else {
|
||||
currentPos = -data.currentTranslate;
|
||||
}
|
||||
|
||||
if (params.cssMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (swiper.params.freeMode && params.freeMode.enabled) {
|
||||
swiper.freeMode.onTouchEnd({
|
||||
currentPos
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let stopIndex = 0;
|
||||
let groupSize = swiper.slidesSizesGrid[0];
|
||||
|
||||
for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
|
||||
const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
||||
if (typeof slidesGrid[i + increment] !== 'undefined') {
|
||||
if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
|
||||
stopIndex = i;
|
||||
groupSize = slidesGrid[i + increment] - slidesGrid[i];
|
||||
}
|
||||
} else if (currentPos >= slidesGrid[i]) {
|
||||
stopIndex = i;
|
||||
groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
||||
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
||||
if (timeDiff > params.longSwipesMs) {
|
||||
if (!params.longSwipes) {
|
||||
swiper.slideTo(swiper.activeIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (swiper.swipeDirection === 'next') {
|
||||
if (ratio >= params.longSwipesRatio) swiper.slideTo(stopIndex + increment);
|
||||
else swiper.slideTo(stopIndex);
|
||||
}
|
||||
|
||||
if (swiper.swipeDirection === 'prev') {
|
||||
if (ratio > 1 - params.longSwipesRatio) swiper.slideTo(stopIndex + increment);
|
||||
else swiper.slideTo(stopIndex);
|
||||
}
|
||||
} else {
|
||||
if (!params.shortSwipes) {
|
||||
swiper.slideTo(swiper.activeIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper
|
||||
.navigation.prevEl);
|
||||
|
||||
if (!isNavButtonTarget) {
|
||||
if (swiper.swipeDirection === 'next') {
|
||||
swiper.slideTo(stopIndex + increment);
|
||||
}
|
||||
|
||||
if (swiper.swipeDirection === 'prev') {
|
||||
swiper.slideTo(stopIndex);
|
||||
}
|
||||
} else if (e.target === swiper.navigation.nextEl) {
|
||||
swiper.slideTo(stopIndex + increment);
|
||||
} else {
|
||||
swiper.slideTo(stopIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
228
uni_modules/zebra-swiper/libs/events/onTouchMove.js
Normal file
228
uni_modules/zebra-swiper/libs/events/onTouchMove.js
Normal file
@@ -0,0 +1,228 @@
|
||||
import {
|
||||
now
|
||||
} from '../../shared/utils.js';
|
||||
export default function onTouchMove(event) {
|
||||
const swiper = this;
|
||||
const data = swiper.touchEventsData;
|
||||
const {
|
||||
params,
|
||||
touches,
|
||||
rtlTranslate: rtl,
|
||||
enabled
|
||||
} = swiper;
|
||||
if (!enabled) return;
|
||||
let e = event;
|
||||
if (e.originalEvent) e = e.originalEvent;
|
||||
|
||||
if (!data.isTouched) {
|
||||
if (data.startMoving && data.isScrolling) {
|
||||
swiper.emit('touchMoveOpposite', e);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.isTouchEvent && e.type !== 'touchmove' && e.type !== 'touchMove' && e.type !== 'onTouchmove') return;
|
||||
const targetTouch = (e.type === 'touchmove' || e.type === 'touchMove' || e.type === 'onTouchmove') && e.touches && (
|
||||
e.touches[0] || e
|
||||
.changedTouches[0]);
|
||||
const pageX = (e.type === 'touchmove' || e.type === 'touchMove' || e.type === 'onTouchmove') ? targetTouch.pageX : e
|
||||
.pageX;
|
||||
const pageY = (e.type === 'touchmove' || e.type === 'touchMove' || e.type === 'onTouchmove') ? targetTouch.pageY : e
|
||||
.pageY;
|
||||
|
||||
if (e.preventedByNestedSwiper) {
|
||||
touches.startX = pageX;
|
||||
touches.startY = pageY;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!swiper.allowTouchMove) {
|
||||
swiper.allowClick = false;
|
||||
|
||||
if (data.isTouched) {
|
||||
Object.assign(touches, {
|
||||
startX: pageX,
|
||||
startY: pageY,
|
||||
currentX: pageX,
|
||||
currentY: pageY
|
||||
});
|
||||
data.touchStartTime = now();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
|
||||
if (swiper.isVertical()) {
|
||||
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper
|
||||
.translate >= swiper.minTranslate()) {
|
||||
data.isTouched = false;
|
||||
data.isMoved = false;
|
||||
return;
|
||||
}
|
||||
} else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX &&
|
||||
swiper.translate >= swiper.minTranslate()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if (data.isTouchEvent && document.activeElement) {
|
||||
// if (e.target === document.activeElement && $(e.target).is(data.focusableElements)) {
|
||||
// data.isMoved = true;
|
||||
// swiper.allowClick = false;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (data.allowTouchCallbacks) {
|
||||
swiper.emit('touch-move', e);
|
||||
}
|
||||
|
||||
if (e.touches && e.touches.length > 1) return;
|
||||
touches.currentX = pageX;
|
||||
touches.currentY = pageY;
|
||||
const diffX = touches.currentX - touches.startX;
|
||||
const diffY = touches.currentY - touches.startY;
|
||||
if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
|
||||
|
||||
if (typeof data.isScrolling === 'undefined') {
|
||||
let touchAngle;
|
||||
|
||||
if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX ===
|
||||
touches.startX) {
|
||||
data.isScrolling = false;
|
||||
} else {
|
||||
if (diffX * diffX + diffY * diffY >= 25) {
|
||||
touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
|
||||
data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params
|
||||
.touchAngle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isScrolling) {
|
||||
swiper.emit('touchMoveOpposite', e);
|
||||
}
|
||||
|
||||
if (typeof data.startMoving === 'undefined') {
|
||||
if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
|
||||
data.startMoving = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isScrolling) {
|
||||
data.isTouched = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.startMoving) {
|
||||
return;
|
||||
}
|
||||
|
||||
swiper.allowClick = false;
|
||||
|
||||
if (!params.cssMode && e.cancelable) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
if (params.touchMoveStopPropagation && !params.nested) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
if (!data.isMoved) {
|
||||
if (params.loop && !params.cssMode) {
|
||||
swiper.loopFix();
|
||||
}
|
||||
|
||||
data.startTranslate = swiper.getTranslate();
|
||||
swiper.setTransition(0);
|
||||
|
||||
if (swiper.animating) {
|
||||
swiper.$wrapperEl.emit('transitionend', [swiper]);
|
||||
}
|
||||
|
||||
data.allowMomentumBounce = false;
|
||||
|
||||
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
||||
swiper.setGrabCursor(true);
|
||||
}
|
||||
|
||||
swiper.emit('sliderFirstMove', e);
|
||||
}
|
||||
|
||||
swiper.emit('sliderMove', e);
|
||||
data.isMoved = true;
|
||||
let diff = swiper.isHorizontal() ? diffX : diffY;
|
||||
touches.diff = diff;
|
||||
diff *= params.touchRatio;
|
||||
if (rtl) diff = -diff;
|
||||
swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
|
||||
data.currentTranslate = diff + data.startTranslate;
|
||||
let disableParentSwiper = true;
|
||||
let resistanceRatio = params.resistanceRatio;
|
||||
|
||||
if (params.touchReleaseOnEdges) {
|
||||
resistanceRatio = 0;
|
||||
}
|
||||
|
||||
if (diff > 0 && data.currentTranslate > swiper.minTranslate()) {
|
||||
disableParentSwiper = false;
|
||||
if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data
|
||||
.startTranslate + diff) ** resistanceRatio;
|
||||
} else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
|
||||
disableParentSwiper = false;
|
||||
if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data
|
||||
.startTranslate - diff) ** resistanceRatio;
|
||||
}
|
||||
|
||||
if (disableParentSwiper) {
|
||||
e.preventedByNestedSwiper = true;
|
||||
}
|
||||
|
||||
|
||||
if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
|
||||
data.currentTranslate = data.startTranslate;
|
||||
}
|
||||
|
||||
if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
|
||||
data.currentTranslate = data.startTranslate;
|
||||
}
|
||||
|
||||
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
||||
data.currentTranslate = data.startTranslate;
|
||||
}
|
||||
|
||||
|
||||
if (params.threshold > 0) {
|
||||
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
||||
if (!data.allowThresholdMove) {
|
||||
data.allowThresholdMove = true;
|
||||
touches.startX = touches.currentX;
|
||||
touches.startY = touches.currentY;
|
||||
data.currentTranslate = data.startTranslate;
|
||||
touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches
|
||||
.startY;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
data.currentTranslate = data.startTranslate;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!params.followFinger || params.cssMode) return;
|
||||
|
||||
if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
|
||||
swiper.updateActiveIndex();
|
||||
swiper.updateSlidesClasses();
|
||||
}
|
||||
|
||||
if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) {
|
||||
swiper.freeMode.onTouchMove();
|
||||
}
|
||||
|
||||
swiper.updateProgress(data.currentTranslate);
|
||||
|
||||
swiper.setTranslate(data.currentTranslate);
|
||||
}
|
||||
85
uni_modules/zebra-swiper/libs/events/onTouchStart.js
Normal file
85
uni_modules/zebra-swiper/libs/events/onTouchStart.js
Normal file
@@ -0,0 +1,85 @@
|
||||
import {
|
||||
now
|
||||
} from '../../shared/utils.js';
|
||||
|
||||
export default function onTouchStart(event) {
|
||||
const swiper = this;
|
||||
const data = swiper.touchEventsData;
|
||||
const {
|
||||
params,
|
||||
touches,
|
||||
enabled
|
||||
} = swiper;
|
||||
if (!enabled) return;
|
||||
|
||||
if (swiper.animating && params.preventInteractionOnTransition) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!swiper.animating && params.cssMode && params.loop) {
|
||||
swiper.loopFix();
|
||||
}
|
||||
|
||||
let e = event;
|
||||
if (e.originalEvent) e = e.originalEvent;
|
||||
|
||||
data.isTouchEvent = e.type === 'touchstart' || e.type === 'touchStart' || e.type === 'onTouchstart';
|
||||
if (!data.isTouchEvent && 'which' in e && e.which === 3) return;
|
||||
if (!data.isTouchEvent && 'button' in e && e.button > 0) return;
|
||||
if (data.isTouched && data.isMoved) return; // change target el for shadow root component
|
||||
|
||||
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
||||
|
||||
|
||||
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
|
||||
const isTargetShadow = !!(e.target && e.target
|
||||
.shadowRoot
|
||||
);
|
||||
|
||||
if (params.noSwiping) {
|
||||
swiper.allowClick = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.swipeHandler) {
|
||||
if (!$targetEl.closest(params.swipeHandler)[0]) return;
|
||||
}
|
||||
|
||||
touches.currentX = (e.type === 'touchstart' || e.type === 'touchStart' || e.type === 'onTouchstart') ? e.touches[0]
|
||||
.pageX : e.pageX;
|
||||
touches.currentY = (e.type === 'touchstart' || e.type === 'touchStart' || e.type === 'onTouchstart') ? e.touches[0]
|
||||
.pageY : e.pageY;
|
||||
const startX = touches.currentX;
|
||||
const startY = touches
|
||||
.currentY;
|
||||
|
||||
const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
|
||||
const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
|
||||
|
||||
Object.assign(data, {
|
||||
isTouched: true,
|
||||
isMoved: false,
|
||||
allowTouchCallbacks: true,
|
||||
isScrolling: undefined,
|
||||
startMoving: undefined
|
||||
});
|
||||
touches.startX = startX;
|
||||
touches.startY = startY;
|
||||
data.touchStartTime = now();
|
||||
swiper.allowClick = true;
|
||||
swiper.updateSize();
|
||||
swiper.swipeDirection = undefined;
|
||||
if (params.threshold > 0) data.allowThresholdMove = false;
|
||||
// if (e.type !== 'touchstart' && e.type !== 'touchStart') {
|
||||
// let preventDefault = true;
|
||||
// if ($targetEl.is(data.focusableElements)) preventDefault = false;
|
||||
|
||||
// const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
|
||||
|
||||
// if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) {
|
||||
// e.preventDefault();
|
||||
// }
|
||||
// }
|
||||
|
||||
swiper.emit('touch-start', e);
|
||||
}
|
||||
6
uni_modules/zebra-swiper/libs/grab-cursor/index.js
Normal file
6
uni_modules/zebra-swiper/libs/grab-cursor/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import setGrabCursor from './setGrabCursor.js';
|
||||
import unsetGrabCursor from './unsetGrabCursor.js';
|
||||
export default {
|
||||
setGrabCursor,
|
||||
unsetGrabCursor
|
||||
};
|
||||
12
uni_modules/zebra-swiper/libs/grab-cursor/setGrabCursor.js
Normal file
12
uni_modules/zebra-swiper/libs/grab-cursor/setGrabCursor.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export default function setGrabCursor(moving) {
|
||||
const swiper = this;
|
||||
if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper
|
||||
.params.cssMode) return;
|
||||
const el = swiper.params.touchEventsTarget === 'container' ? swiper.$el : swiper.$wrapperEl;
|
||||
el.setCss({
|
||||
cursor: 'move',
|
||||
cursor: moving ? '-webkit-grabbing' : '-webkit-grab',
|
||||
cursor: moving ? '-moz-grabbin' : '-moz-grab',
|
||||
cursor: moving ? 'grabbing' : 'grab',
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export default function unsetGrabCursor() {
|
||||
const swiper = this;
|
||||
if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
|
||||
return;
|
||||
}
|
||||
swiper[swiper.params.touchEventsTarget === 'container' ? '$el' : '$wrapperEl'].setCss({
|
||||
cursor: ''
|
||||
});
|
||||
}
|
||||
8
uni_modules/zebra-swiper/libs/loop/index.js
Normal file
8
uni_modules/zebra-swiper/libs/loop/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import loopCreate from './loopCreate.js';
|
||||
import loopFix from './loopFix.js';
|
||||
import loopDestroy from './loopDestroy.js';
|
||||
export default {
|
||||
loopCreate,
|
||||
loopFix,
|
||||
loopDestroy
|
||||
};
|
||||
51
uni_modules/zebra-swiper/libs/loop/loopCreate.js
Normal file
51
uni_modules/zebra-swiper/libs/loop/loopCreate.js
Normal file
@@ -0,0 +1,51 @@
|
||||
export default function loopCreate() {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
$wrapperEl,
|
||||
native
|
||||
} = swiper; // Remove duplicated slides
|
||||
const $selector = $wrapperEl;
|
||||
let slides = native.children;
|
||||
|
||||
if (params.loopFillGroupWithBlank) {
|
||||
const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup;
|
||||
|
||||
if (blankSlidesNum !== params.slidesPerGroup) {
|
||||
native.loopBlankShow = true;
|
||||
native.loopBlankNumber = blankSlidesNum;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length;
|
||||
swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10));
|
||||
swiper.loopedSlides += params.loopAdditionalSlides;
|
||||
|
||||
if (swiper.loopedSlides > slides.length) {
|
||||
swiper.loopedSlides = slides.length;
|
||||
}
|
||||
const prependSlides = [];
|
||||
const appendSlides = [];
|
||||
slides.forEach((el, index) => {
|
||||
const slide = el;
|
||||
if (index < slides.length && index >= slides.length - swiper.loopedSlides) {
|
||||
prependSlides.push(el);
|
||||
}
|
||||
|
||||
if (index < swiper.loopedSlides) {
|
||||
appendSlides.push(el);
|
||||
}
|
||||
});
|
||||
let list = [...swiper.native.value];
|
||||
let newList = [...list];
|
||||
swiper.originalDataList = [...swiper.native.value];
|
||||
for (let i = 0; i < appendSlides.length; i += 1) {
|
||||
newList.push(list[appendSlides[i].index]);
|
||||
}
|
||||
|
||||
for (let i = prependSlides.length - 1; i >= 0; i -= 1) {
|
||||
newList.unshift(list[prependSlides[i].index]);
|
||||
}
|
||||
swiper.native.$emit("input", newList)
|
||||
return true;
|
||||
}
|
||||
8
uni_modules/zebra-swiper/libs/loop/loopDestroy.js
Normal file
8
uni_modules/zebra-swiper/libs/loop/loopDestroy.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function loopDestroy() {
|
||||
const swiper = this;
|
||||
const {
|
||||
$wrapperEl,
|
||||
params,
|
||||
slides
|
||||
} = swiper;
|
||||
}
|
||||
40
uni_modules/zebra-swiper/libs/loop/loopFix.js
Normal file
40
uni_modules/zebra-swiper/libs/loop/loopFix.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export default function loopFix() {
|
||||
const swiper = this;
|
||||
swiper.emit('beforeLoopFix');
|
||||
const {
|
||||
activeIndex,
|
||||
slides,
|
||||
loopedSlides,
|
||||
allowSlidePrev,
|
||||
allowSlideNext,
|
||||
snapGrid,
|
||||
rtlTranslate: rtl
|
||||
} = swiper;
|
||||
let newIndex;
|
||||
swiper.allowSlidePrev = true;
|
||||
swiper.allowSlideNext = true;
|
||||
const snapTranslate = -snapGrid[activeIndex];
|
||||
const diff = snapTranslate - swiper.getTranslate();
|
||||
|
||||
if (activeIndex < loopedSlides) {
|
||||
newIndex = slides.length - loopedSlides * 3 + activeIndex;
|
||||
newIndex += loopedSlides;
|
||||
const slideChanged = swiper.slideTo(newIndex, 0, false, true);
|
||||
|
||||
if (slideChanged && diff !== 0) {
|
||||
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
|
||||
}
|
||||
} else if (activeIndex >= slides.length - loopedSlides) {
|
||||
newIndex = -slides.length + activeIndex + loopedSlides;
|
||||
newIndex += loopedSlides;
|
||||
const slideChanged = swiper.slideTo(newIndex, 0, false, true);
|
||||
|
||||
if (slideChanged && diff !== 0) {
|
||||
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
|
||||
}
|
||||
}
|
||||
|
||||
swiper.allowSlidePrev = allowSlidePrev;
|
||||
swiper.allowSlideNext = allowSlideNext;
|
||||
swiper.emit('loopFix');
|
||||
}
|
||||
68
uni_modules/zebra-swiper/libs/mixins/relation.js
Normal file
68
uni_modules/zebra-swiper/libs/mixins/relation.js
Normal file
@@ -0,0 +1,68 @@
|
||||
export function ChildrenMixin(parent, options = {}) {
|
||||
const indexKey = options.indexKey || 'index';
|
||||
return {
|
||||
inject: {
|
||||
[parent]: {
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.parent = this[parent];
|
||||
this.bindRelation();
|
||||
},
|
||||
// #ifdef VUE2
|
||||
beforeDestroy() {
|
||||
if (this.parent) {
|
||||
this.parent.children = this.parent.children.filter(
|
||||
(item) => item !== this
|
||||
);
|
||||
uni.$emit("childrenReady" + this.parent._uid, this);
|
||||
}
|
||||
},
|
||||
// #endif
|
||||
// #ifdef VUE3
|
||||
beforeUnmount() {
|
||||
if (this.parent) {
|
||||
this.parent.children = this.parent.children.filter(
|
||||
(item) => item !== this
|
||||
);
|
||||
uni.$emit("childrenReady" + this.parent._uid, this);
|
||||
}
|
||||
},
|
||||
// #endif
|
||||
methods: {
|
||||
bindRelation() {
|
||||
if (!this.parent || this.parent.children.indexOf(this) !== -1) {
|
||||
return;
|
||||
}
|
||||
const children = [...this.parent.children, this];
|
||||
this.parent.children = children;
|
||||
this.index = this.parent.children.indexOf(this);
|
||||
uni.$emit("childrenReady" + this.parent._uid, this);
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function ParentMixin(parent) {
|
||||
return {
|
||||
provide() {
|
||||
return {
|
||||
[parent]: this,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.children = [];
|
||||
},
|
||||
// #ifdef VUE2
|
||||
beforeDestroy() {
|
||||
uni.$off("childrenReady" + this._uid)
|
||||
},
|
||||
// #endif
|
||||
// #ifdef VUE3
|
||||
beforeUnmount() {
|
||||
uni.$off("childrenReady" + this._uid)
|
||||
},
|
||||
// #endif
|
||||
};
|
||||
}
|
||||
41
uni_modules/zebra-swiper/libs/moduleExtendParams.js
Normal file
41
uni_modules/zebra-swiper/libs/moduleExtendParams.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
extend
|
||||
} from '../shared/utils.js';
|
||||
export default function moduleExtendParams(params, allModulesParams) {
|
||||
return function extendParams(obj = {}) {
|
||||
const moduleParamName = Object.keys(obj)[0];
|
||||
const moduleParams = obj[moduleParamName];
|
||||
|
||||
if (typeof moduleParams !== 'object' || moduleParams === null) {
|
||||
extend(allModulesParams, obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] ===
|
||||
true) {
|
||||
params[moduleParamName] = {
|
||||
auto: true
|
||||
};
|
||||
}
|
||||
|
||||
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
|
||||
extend(allModulesParams, obj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (params[moduleParamName] === true) {
|
||||
params[moduleParamName] = {
|
||||
enabled: true
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
|
||||
params[moduleParamName].enabled = true;
|
||||
}
|
||||
|
||||
if (!params[moduleParamName]) params[moduleParamName] = {
|
||||
enabled: false
|
||||
};
|
||||
extend(allModulesParams, obj);
|
||||
};
|
||||
}
|
||||
16
uni_modules/zebra-swiper/libs/slide/index.js
Normal file
16
uni_modules/zebra-swiper/libs/slide/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import slideTo from './slideTo.js';
|
||||
import slideToLoop from './slideToLoop.js';
|
||||
import slideNext from './slideNext.js';
|
||||
import slidePrev from './slidePrev.js';
|
||||
import slideReset from './slideReset.js';
|
||||
import slideToClosest from './slideToClosest.js';
|
||||
import slideToClickedSlide from './slideToClickedSlide.js';
|
||||
export default {
|
||||
slideTo,
|
||||
slideToLoop,
|
||||
slideNext,
|
||||
slidePrev,
|
||||
slideReset,
|
||||
slideToClosest,
|
||||
slideToClickedSlide
|
||||
};
|
||||
29
uni_modules/zebra-swiper/libs/slide/slideNext.js
Normal file
29
uni_modules/zebra-swiper/libs/slide/slideNext.js
Normal file
@@ -0,0 +1,29 @@
|
||||
export default function slideNext(speed = this.params.speed, runCallbacks = true, internal) {
|
||||
const swiper = this;
|
||||
const {
|
||||
animating,
|
||||
enabled,
|
||||
params
|
||||
} = swiper;
|
||||
if (!enabled) return swiper;
|
||||
let perGroup = params.slidesPerGroup;
|
||||
|
||||
if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
||||
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
|
||||
}
|
||||
|
||||
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
|
||||
|
||||
if (params.loop) {
|
||||
if (animating && params.loopPreventsSlide) return false;
|
||||
swiper.loopFix();
|
||||
}
|
||||
|
||||
if (params.rewind && swiper.isEnd) {
|
||||
return swiper.slideTo(0, speed, runCallbacks, internal);
|
||||
}
|
||||
setTimeout(() => {
|
||||
swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal)
|
||||
}, 0)
|
||||
return true;
|
||||
}
|
||||
63
uni_modules/zebra-swiper/libs/slide/slidePrev.js
Normal file
63
uni_modules/zebra-swiper/libs/slide/slidePrev.js
Normal file
@@ -0,0 +1,63 @@
|
||||
export default function slidePrev(speed = this.params.speed, runCallbacks = true, internal) {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
animating,
|
||||
snapGrid,
|
||||
slidesGrid,
|
||||
rtlTranslate,
|
||||
enabled
|
||||
} = swiper;
|
||||
if (!enabled) return swiper;
|
||||
|
||||
if (params.loop) {
|
||||
if (animating && params.loopPreventsSlide) return false;
|
||||
swiper.loopFix();
|
||||
|
||||
}
|
||||
|
||||
const translate = rtlTranslate ? swiper.translate : -swiper.translate;
|
||||
|
||||
function normalize(val) {
|
||||
if (val < 0) return -Math.floor(Math.abs(val));
|
||||
return Math.floor(val);
|
||||
}
|
||||
|
||||
const normalizedTranslate = normalize(translate);
|
||||
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
|
||||
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
||||
|
||||
if (typeof prevSnap === 'undefined' && params.cssMode) {
|
||||
let prevSnapIndex;
|
||||
snapGrid.forEach((snap, snapIndex) => {
|
||||
if (normalizedTranslate >= snap) {
|
||||
prevSnapIndex = snapIndex;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof prevSnapIndex !== 'undefined') {
|
||||
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
|
||||
}
|
||||
}
|
||||
|
||||
let prevIndex = 0;
|
||||
|
||||
if (typeof prevSnap !== 'undefined') {
|
||||
prevIndex = slidesGrid.indexOf(prevSnap);
|
||||
if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
|
||||
|
||||
if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
|
||||
prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
|
||||
prevIndex = Math.max(prevIndex, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.rewind && swiper.isBeginning) {
|
||||
return swiper.slideTo(swiper.slides.length - 1, speed, runCallbacks, internal);
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
swiper.slideTo(prevIndex, speed, runCallbacks, internal)
|
||||
}, 30)
|
||||
return true;
|
||||
}
|
||||
4
uni_modules/zebra-swiper/libs/slide/slideReset.js
Normal file
4
uni_modules/zebra-swiper/libs/slide/slideReset.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default function slideReset(speed = this.params.speed, runCallbacks = true, internal) {
|
||||
const swiper = this;
|
||||
return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
|
||||
}
|
||||
188
uni_modules/zebra-swiper/libs/slide/slideTo.js
Normal file
188
uni_modules/zebra-swiper/libs/slide/slideTo.js
Normal file
@@ -0,0 +1,188 @@
|
||||
import {
|
||||
animateCSSModeScroll
|
||||
} from '../../shared/utils.js';
|
||||
export default function slideTo(index = 0, speed = this.params.speed, runCallbacks = true, internal, initial) {
|
||||
if (typeof index !== 'number' && typeof index !== 'string') {
|
||||
throw new Error(
|
||||
`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`);
|
||||
}
|
||||
|
||||
if (typeof index === 'string') {
|
||||
/**
|
||||
* The `index` argument converted from `string` to `number`.
|
||||
* @type {number}
|
||||
*/
|
||||
const indexAsNumber = parseInt(index, 10);
|
||||
/**
|
||||
* Determines whether the `index` argument is a valid `number`
|
||||
* after being converted from the `string` type.
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
||||
const isValidNumber = isFinite(indexAsNumber);
|
||||
|
||||
if (!isValidNumber) {
|
||||
throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
|
||||
} // Knowing that the converted `index` is a valid number,
|
||||
// we can update the original argument's value.
|
||||
|
||||
|
||||
index = indexAsNumber;
|
||||
}
|
||||
|
||||
const swiper = this;
|
||||
let slideIndex = index;
|
||||
let timer;
|
||||
if (slideIndex < 0) slideIndex = 0;
|
||||
const {
|
||||
params,
|
||||
snapGrid,
|
||||
slidesGrid,
|
||||
previousIndex,
|
||||
activeIndex,
|
||||
rtlTranslate: rtl,
|
||||
wrapperEl,
|
||||
enabled
|
||||
} = swiper;
|
||||
|
||||
if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
|
||||
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
||||
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
||||
|
||||
if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) {
|
||||
swiper.emit('beforeSlideChangeStart');
|
||||
}
|
||||
const translate = -snapGrid[snapIndex]; // Update progress
|
||||
|
||||
swiper.updateProgress(translate); // Normalize slideIndex
|
||||
|
||||
if (params.normalizeSlideIndex) {
|
||||
for (let i = 0; i < slidesGrid.length; i += 1) {
|
||||
const normalizedTranslate = -Math.floor(translate * 100);
|
||||
const normalizedGrid = Math.floor(slidesGrid[i] * 100);
|
||||
const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
|
||||
if (typeof slidesGrid[i + 1] !== 'undefined') {
|
||||
if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (
|
||||
normalizedGridNext - normalizedGrid) / 2) {
|
||||
slideIndex = i;
|
||||
} else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
|
||||
slideIndex = i + 1;
|
||||
}
|
||||
} else if (normalizedTranslate >= normalizedGrid) {
|
||||
slideIndex = i;
|
||||
}
|
||||
|
||||
}
|
||||
} // Directions locks
|
||||
|
||||
|
||||
if (swiper.initialized && slideIndex !== activeIndex) {
|
||||
if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
||||
if ((activeIndex || 0) !== slideIndex) return false;
|
||||
}
|
||||
}
|
||||
|
||||
let direction;
|
||||
if (slideIndex > activeIndex) direction = 'next';
|
||||
else if (slideIndex < activeIndex) direction = 'prev';
|
||||
else direction = 'reset'; // Update Index
|
||||
|
||||
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
||||
swiper.updateActiveIndex(slideIndex); // Update Height
|
||||
|
||||
if (params.autoHeight) {
|
||||
setTimeout(() => {
|
||||
swiper.updateAutoHeight();
|
||||
}, 0)
|
||||
}
|
||||
|
||||
swiper.updateSlidesClasses();
|
||||
|
||||
if (params.effect !== 'slide') {
|
||||
swiper.setTranslate(translate);
|
||||
}
|
||||
|
||||
if (direction !== 'reset') {
|
||||
swiper.transitionStart(runCallbacks, direction);
|
||||
swiper.transitionEnd(runCallbacks, direction);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params.cssMode) {
|
||||
const isH = swiper.isHorizontal();
|
||||
const t = rtl ? translate : -translate;
|
||||
|
||||
if (speed === 0) {
|
||||
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
||||
|
||||
if (isVirtual) {
|
||||
swiper.wrapperEl.style.scrollSnapType = 'none';
|
||||
swiper._immediateVirtual = true;
|
||||
}
|
||||
|
||||
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
||||
|
||||
if (isVirtual) {
|
||||
requestAnimationFrame(() => {
|
||||
swiper.wrapperEl.style.scrollSnapType = '';
|
||||
swiper._swiperImmediateVirtual = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!swiper.support.smoothScroll) {
|
||||
animateCSSModeScroll({
|
||||
swiper,
|
||||
targetPosition: t,
|
||||
side: isH ? 'left' : 'top'
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
wrapperEl.scrollTo({
|
||||
[isH ? 'left' : 'top']: t,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
swiper.setTransition(speed);
|
||||
swiper.setTranslate(translate);
|
||||
swiper.updateActiveIndex(slideIndex);
|
||||
swiper.updateSlidesClasses();
|
||||
swiper.emit('beforeTransitionStart', speed, internal);
|
||||
swiper.transitionStart(runCallbacks, direction);
|
||||
|
||||
if (speed === 0) {
|
||||
swiper.transitionEnd(runCallbacks, direction);
|
||||
} else if (!swiper.animating) {
|
||||
swiper.animating = true;
|
||||
|
||||
if (!swiper.onSlideToWrapperTransitionEnd) {
|
||||
swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
|
||||
if (!swiper || swiper.destroyed) return;
|
||||
clearTimeout(timer)
|
||||
swiper.onSlideToWrapperTransitionEnd = null;
|
||||
delete swiper.onSlideToWrapperTransitionEnd;
|
||||
swiper.transitionEnd(runCallbacks, direction);
|
||||
};
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
if (swiper.onSlideToWrapperTransitionEnd) {
|
||||
swiper.onSlideToWrapperTransitionEnd();
|
||||
}
|
||||
}, speed)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
46
uni_modules/zebra-swiper/libs/slide/slideToClickedSlide.js
Normal file
46
uni_modules/zebra-swiper/libs/slide/slideToClickedSlide.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
nextTick
|
||||
} from '../../shared/utils.js';
|
||||
export default function slideToClickedSlide() {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
$wrapperEl
|
||||
} = swiper;
|
||||
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
||||
let slideToIndex = swiper.clickedIndex;
|
||||
let realIndex;
|
||||
|
||||
if (params.loop) {
|
||||
if (swiper.animating) return;
|
||||
// realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
|
||||
realIndex = parseInt(swiper.activeIndex, 10);
|
||||
|
||||
if (params.centeredSlides) {
|
||||
if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper
|
||||
.loopedSlides + slidesPerView / 2) {
|
||||
swiper.loopFix();
|
||||
slideToIndex = $wrapperEl.children(
|
||||
`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`
|
||||
).eq(0).index();
|
||||
nextTick(() => {
|
||||
swiper.slideTo(slideToIndex);
|
||||
});
|
||||
} else {
|
||||
swiper.slideTo(slideToIndex);
|
||||
}
|
||||
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
||||
swiper.loopFix();
|
||||
slideToIndex = $wrapperEl.children(
|
||||
`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`)
|
||||
.eq(0).index();
|
||||
nextTick(() => {
|
||||
swiper.slideTo(slideToIndex);
|
||||
});
|
||||
} else {
|
||||
swiper.slideTo(slideToIndex);
|
||||
}
|
||||
} else {
|
||||
swiper.slideTo(slideToIndex);
|
||||
}
|
||||
}
|
||||
28
uni_modules/zebra-swiper/libs/slide/slideToClosest.js
Normal file
28
uni_modules/zebra-swiper/libs/slide/slideToClosest.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/* eslint no-unused-vars: "off" */
|
||||
export default function slideToClosest(speed = this.params.speed, runCallbacks = true, internal, threshold = 0.5) {
|
||||
const swiper = this;
|
||||
let index = swiper.activeIndex;
|
||||
const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
|
||||
const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
|
||||
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
||||
|
||||
if (translate >= swiper.snapGrid[snapIndex]) {
|
||||
const currentSnap = swiper.snapGrid[snapIndex];
|
||||
const nextSnap = swiper.snapGrid[snapIndex + 1];
|
||||
|
||||
if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
|
||||
index += swiper.params.slidesPerGroup;
|
||||
}
|
||||
} else {
|
||||
const prevSnap = swiper.snapGrid[snapIndex - 1];
|
||||
const currentSnap = swiper.snapGrid[snapIndex];
|
||||
|
||||
if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
|
||||
index -= swiper.params.slidesPerGroup;
|
||||
}
|
||||
}
|
||||
|
||||
index = Math.max(index, 0);
|
||||
index = Math.min(index, swiper.slidesGrid.length - 1);
|
||||
return swiper.slideTo(index, speed, runCallbacks, internal);
|
||||
}
|
||||
10
uni_modules/zebra-swiper/libs/slide/slideToLoop.js
Normal file
10
uni_modules/zebra-swiper/libs/slide/slideToLoop.js
Normal file
@@ -0,0 +1,10 @@
|
||||
export default function slideToLoop(index = 0, speed = this.params.speed, runCallbacks = true, internal) {
|
||||
const swiper = this;
|
||||
let newIndex = index;
|
||||
|
||||
if (swiper.params.loop) {
|
||||
newIndex += swiper.loopedSlides;
|
||||
}
|
||||
|
||||
return swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
||||
}
|
||||
8
uni_modules/zebra-swiper/libs/transition/index.js
Normal file
8
uni_modules/zebra-swiper/libs/transition/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import setTransition from './setTransition.js';
|
||||
import transitionStart from './transitionStart.js';
|
||||
import transitionEnd from './transitionEnd.js';
|
||||
export default {
|
||||
setTransition,
|
||||
transitionStart,
|
||||
transitionEnd
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
export default function setTransition(duration, byController) {
|
||||
const swiper = this;
|
||||
if (!swiper.$wrapperEl) return
|
||||
if (!swiper.params.cssMode) {
|
||||
swiper.$wrapperEl.transition(duration);
|
||||
}
|
||||
|
||||
swiper.emit('setTransition', duration, byController);
|
||||
}
|
||||
35
uni_modules/zebra-swiper/libs/transition/transitionEmit.js
Normal file
35
uni_modules/zebra-swiper/libs/transition/transitionEmit.js
Normal file
@@ -0,0 +1,35 @@
|
||||
export default function transitionEmit({
|
||||
swiper,
|
||||
runCallbacks,
|
||||
direction,
|
||||
step
|
||||
}) {
|
||||
const {
|
||||
activeIndex,
|
||||
previousIndex
|
||||
} = swiper;
|
||||
let dir = direction;
|
||||
|
||||
if (!dir) {
|
||||
if (activeIndex > previousIndex) dir = 'next';
|
||||
else if (activeIndex < previousIndex) dir = 'prev';
|
||||
else dir = 'reset';
|
||||
}
|
||||
|
||||
swiper.emit(`transition${step}`);
|
||||
|
||||
if (runCallbacks && activeIndex !== previousIndex) {
|
||||
if (dir === 'reset') {
|
||||
swiper.emit(`slideResetTransition${step}`);
|
||||
return;
|
||||
}
|
||||
|
||||
swiper.emit(`slideChangeTransition${step}`);
|
||||
|
||||
if (dir === 'next') {
|
||||
swiper.emit(`slideNextTransition${step}`);
|
||||
} else {
|
||||
swiper.emit(`slidePrevTransition${step}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
uni_modules/zebra-swiper/libs/transition/transitionEnd.js
Normal file
16
uni_modules/zebra-swiper/libs/transition/transitionEnd.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import transitionEmit from './transitionEmit.js';
|
||||
export default function transitionEnd(runCallbacks = true, direction) {
|
||||
const swiper = this;
|
||||
const {
|
||||
params
|
||||
} = swiper;
|
||||
swiper.animating = false;
|
||||
if (params.cssMode) return;
|
||||
swiper.setTransition(0);
|
||||
transitionEmit({
|
||||
swiper,
|
||||
runCallbacks,
|
||||
direction,
|
||||
step: 'End'
|
||||
});
|
||||
}
|
||||
19
uni_modules/zebra-swiper/libs/transition/transitionStart.js
Normal file
19
uni_modules/zebra-swiper/libs/transition/transitionStart.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import transitionEmit from './transitionEmit.js';
|
||||
export default function transitionStart(runCallbacks = true, direction) {
|
||||
const swiper = this;
|
||||
const {
|
||||
params
|
||||
} = swiper;
|
||||
if (params.cssMode) return;
|
||||
|
||||
if (params.autoHeight) {
|
||||
swiper.updateAutoHeight();
|
||||
}
|
||||
|
||||
transitionEmit({
|
||||
swiper,
|
||||
runCallbacks,
|
||||
direction,
|
||||
step: 'Start'
|
||||
});
|
||||
}
|
||||
23
uni_modules/zebra-swiper/libs/translate/getTranslate.js
Normal file
23
uni_modules/zebra-swiper/libs/translate/getTranslate.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
getTranslate
|
||||
} from '../../shared/utils.js';
|
||||
export default function getSwiperTranslate(axis = this.isHorizontal() ? 'x' : 'y') {
|
||||
const swiper = this;
|
||||
const {
|
||||
params,
|
||||
rtlTranslate: rtl,
|
||||
translate,
|
||||
$wrapperEl
|
||||
} = swiper;
|
||||
|
||||
if (params.virtualTranslate) {
|
||||
return rtl ? -translate : translate;
|
||||
}
|
||||
|
||||
if (params.cssMode) {
|
||||
return translate;
|
||||
}
|
||||
let currentTranslate = getTranslate(swiper, axis);
|
||||
if (rtl) currentTranslate = -currentTranslate;
|
||||
return currentTranslate || 0;
|
||||
}
|
||||
12
uni_modules/zebra-swiper/libs/translate/index.js
Normal file
12
uni_modules/zebra-swiper/libs/translate/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import getTranslate from './getTranslate.js';
|
||||
import setTranslate from './setTranslate.js';
|
||||
import minTranslate from './minTranslate.js';
|
||||
import maxTranslate from './maxTranslate.js';
|
||||
import translateTo from './translateTo.js';
|
||||
export default {
|
||||
getTranslate,
|
||||
setTranslate,
|
||||
minTranslate,
|
||||
maxTranslate,
|
||||
translateTo
|
||||
};
|
||||
3
uni_modules/zebra-swiper/libs/translate/maxTranslate.js
Normal file
3
uni_modules/zebra-swiper/libs/translate/maxTranslate.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function maxTranslate() {
|
||||
return -this.snapGrid[this.snapGrid.length - 1];
|
||||
}
|
||||
3
uni_modules/zebra-swiper/libs/translate/minTranslate.js
Normal file
3
uni_modules/zebra-swiper/libs/translate/minTranslate.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function minTranslate() {
|
||||
return -this.snapGrid[0];
|
||||
}
|
||||
51
uni_modules/zebra-swiper/libs/translate/setTranslate.js
Normal file
51
uni_modules/zebra-swiper/libs/translate/setTranslate.js
Normal file
@@ -0,0 +1,51 @@
|
||||
export default function setTranslate(translate, byController) {
|
||||
const swiper = this;
|
||||
const {
|
||||
rtlTranslate: rtl,
|
||||
params,
|
||||
$wrapperEl,
|
||||
wrapperEl,
|
||||
progress
|
||||
} = swiper;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
const z = 0;
|
||||
if (isNaN(translate)) {
|
||||
return
|
||||
}
|
||||
if (!$wrapperEl) return
|
||||
if (swiper.isHorizontal()) {
|
||||
x = rtl ? -translate : translate;
|
||||
} else {
|
||||
y = translate;
|
||||
}
|
||||
|
||||
if (params.roundLengths) {
|
||||
x = Math.floor(x);
|
||||
y = Math.floor(y);
|
||||
}
|
||||
|
||||
if (params.cssMode) {
|
||||
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
||||
} else if (!params.virtualTranslate) {
|
||||
$wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`);
|
||||
}
|
||||
|
||||
swiper.previousTranslate = swiper.translate;
|
||||
swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress
|
||||
|
||||
let newProgress;
|
||||
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
||||
|
||||
if (translatesDiff === 0) {
|
||||
newProgress = 0;
|
||||
} else {
|
||||
newProgress = (translate - swiper.minTranslate()) / translatesDiff;
|
||||
}
|
||||
|
||||
if (newProgress !== progress) {
|
||||
swiper.updateProgress(translate);
|
||||
}
|
||||
|
||||
swiper.emit('setTranslate', swiper.translate, byController);
|
||||
}
|
||||
90
uni_modules/zebra-swiper/libs/translate/translateTo.js
Normal file
90
uni_modules/zebra-swiper/libs/translate/translateTo.js
Normal file
@@ -0,0 +1,90 @@
|
||||
import {
|
||||
animateCSSModeScroll
|
||||
} from '../../shared/utils.js';
|
||||
export default function translateTo(translate = 0, speed = this.params.speed, runCallbacks = true, translateBounds =
|
||||
true, internal) {
|
||||
const swiper = this;
|
||||
let timer;
|
||||
const {
|
||||
params,
|
||||
wrapperEl
|
||||
} = swiper;
|
||||
|
||||
if (swiper.animating && params.preventInteractionOnTransition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const minTranslate = swiper.minTranslate();
|
||||
const maxTranslate = swiper.maxTranslate();
|
||||
let newTranslate;
|
||||
if (translateBounds && translate > minTranslate) newTranslate = minTranslate;
|
||||
else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;
|
||||
else newTranslate = translate; // Update progress
|
||||
|
||||
swiper.updateProgress(newTranslate);
|
||||
|
||||
if (params.cssMode) {
|
||||
const isH = swiper.isHorizontal();
|
||||
|
||||
if (speed === 0) {
|
||||
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
|
||||
} else {
|
||||
if (!swiper.support.smoothScroll) {
|
||||
animateCSSModeScroll({
|
||||
swiper,
|
||||
targetPosition: -newTranslate,
|
||||
side: isH ? 'left' : 'top'
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
wrapperEl.scrollTo({
|
||||
[isH ? 'left' : 'top']: -newTranslate,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (speed === 0) {
|
||||
swiper.setTransition(0);
|
||||
swiper.setTranslate(newTranslate);
|
||||
|
||||
if (runCallbacks) {
|
||||
swiper.emit('beforeTransitionStart', speed, internal);
|
||||
swiper.emit('transitionEnd');
|
||||
}
|
||||
} else {
|
||||
swiper.setTransition(speed);
|
||||
swiper.setTranslate(newTranslate);
|
||||
|
||||
if (runCallbacks) {
|
||||
swiper.emit('beforeTransitionStart', speed, internal);
|
||||
swiper.emit('transitionStart');
|
||||
}
|
||||
|
||||
if (!swiper.animating) {
|
||||
swiper.animating = true;
|
||||
|
||||
if (!swiper.onTranslateToWrapperTransitionEnd) {
|
||||
swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
|
||||
if (!swiper || swiper.destroyed) return;
|
||||
if (e.target !== this) return;
|
||||
clearTimeout(timer)
|
||||
swiper.onTranslateToWrapperTransitionEnd = null;
|
||||
delete swiper.onTranslateToWrapperTransitionEnd;
|
||||
|
||||
if (runCallbacks) {
|
||||
swiper.emit('transitionEnd');
|
||||
}
|
||||
};
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
swiper.onTranslateToWrapperTransitionEnd();
|
||||
}, speed)
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
20
uni_modules/zebra-swiper/libs/update/index.js
Normal file
20
uni_modules/zebra-swiper/libs/update/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import updateSize from './updateSize.js';
|
||||
import updateSlides from './updateSlides.js';
|
||||
import updateAutoHeight from './updateAutoHeight.js';
|
||||
import updateSlidesOffset from './updateSlidesOffset.js';
|
||||
import updateSlidesProgress from './updateSlidesProgress.js';
|
||||
import updateProgress from './updateProgress.js';
|
||||
import updateSlidesClasses from './updateSlidesClasses.js';
|
||||
import updateActiveIndex from './updateActiveIndex.js';
|
||||
import updateClickedSlide from './updateClickedSlide.js';
|
||||
export default {
|
||||
updateSize,
|
||||
updateSlides,
|
||||
updateAutoHeight,
|
||||
updateSlidesOffset,
|
||||
updateSlidesProgress,
|
||||
updateProgress,
|
||||
updateSlidesClasses,
|
||||
updateActiveIndex,
|
||||
updateClickedSlide
|
||||
};
|
||||
102
uni_modules/zebra-swiper/libs/update/updateActiveIndex.js
Normal file
102
uni_modules/zebra-swiper/libs/update/updateActiveIndex.js
Normal file
@@ -0,0 +1,102 @@
|
||||
export default function updateActiveIndex(newActiveIndex) {
|
||||
const swiper = this;
|
||||
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
||||
const {
|
||||
slidesGrid,
|
||||
snapGrid,
|
||||
params,
|
||||
activeIndex: previousIndex,
|
||||
realIndex: previousRealIndex,
|
||||
snapIndex: previousSnapIndex
|
||||
} = swiper;
|
||||
let activeIndex = newActiveIndex;
|
||||
let snapIndex;
|
||||
|
||||
if (typeof activeIndex === 'undefined') {
|
||||
for (let i = 0; i < slidesGrid.length; i += 1) {
|
||||
if (typeof slidesGrid[i + 1] !== 'undefined') {
|
||||
if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) /
|
||||
2) {
|
||||
activeIndex = i;
|
||||
} else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
|
||||
activeIndex = i + 1;
|
||||
}
|
||||
} else if (translate >= slidesGrid[i]) {
|
||||
activeIndex = i;
|
||||
}
|
||||
} // Normalize slideIndex
|
||||
|
||||
|
||||
if (params.normalizeSlideIndex) {
|
||||
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (snapGrid.indexOf(translate) >= 0) {
|
||||
snapIndex = snapGrid.indexOf(translate);
|
||||
} else {
|
||||
const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
|
||||
snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
||||
}
|
||||
|
||||
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
||||
|
||||
|
||||
|
||||
if (swiper.loopedSlides) {
|
||||
swiper.slides.filter((item) => item.index >= swiper.loopedSlides && item.index < swiper.slides.length - swiper
|
||||
.loopedSlides).forEach((item, index) => {
|
||||
item.dataSwiperSlideIndex = item.index - swiper.loopedSlides;
|
||||
})
|
||||
swiper.slides.filter((item) => item.index < swiper.loopedSlides).forEach((item, index) => {
|
||||
if (swiper.slides[swiper.slides.length - swiper.loopedSlides * 3 + index]) {
|
||||
item.dataSwiperSlideIndex = swiper.slides[swiper.slides.length - swiper.loopedSlides * 3 +
|
||||
index]
|
||||
.index;
|
||||
}
|
||||
})
|
||||
swiper.slides.filter((item) => item.index >= swiper.slides.length - swiper
|
||||
.loopedSlides).forEach((item, index) => {
|
||||
item.dataSwiperSlideIndex = swiper.slides[index].index;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if (activeIndex === previousIndex) {
|
||||
if (snapIndex !== previousSnapIndex) {
|
||||
swiper.snapIndex = snapIndex;
|
||||
swiper.emit('snapIndexChange');
|
||||
}
|
||||
|
||||
return;
|
||||
} // Get real index
|
||||
|
||||
let realIndex;
|
||||
if (swiper.virtual && params.virtual.enabled) {
|
||||
realIndex = activeIndex;
|
||||
} else {
|
||||
if (swiper.slides[activeIndex].dataSwiperSlideIndex == undefined || swiper.slides[activeIndex]
|
||||
.dataSwiperSlideIndex == null) {
|
||||
realIndex = activeIndex;
|
||||
} else {
|
||||
realIndex = swiper.slides[activeIndex].dataSwiperSlideIndex;
|
||||
}
|
||||
}
|
||||
Object.assign(swiper, {
|
||||
snapIndex,
|
||||
realIndex,
|
||||
previousIndex,
|
||||
activeIndex
|
||||
});
|
||||
swiper.emit('activeIndexChange');
|
||||
swiper.emit('snapIndexChange');
|
||||
|
||||
if (previousRealIndex !== realIndex) {
|
||||
swiper.emit('realIndexChange');
|
||||
}
|
||||
|
||||
if (swiper.initialized || swiper.params.runCallbacksOnInit) {
|
||||
swiper.emit('slideChange', activeIndex);
|
||||
}
|
||||
}
|
||||
53
uni_modules/zebra-swiper/libs/update/updateAutoHeight.js
Normal file
53
uni_modules/zebra-swiper/libs/update/updateAutoHeight.js
Normal file
@@ -0,0 +1,53 @@
|
||||
export default async function updateAutoHeight(speed) {
|
||||
const swiper = this;
|
||||
const activeSlides = [];
|
||||
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
||||
let newHeight = 0;
|
||||
let i;
|
||||
|
||||
if (typeof speed === 'number') {
|
||||
swiper.setTransition(speed);
|
||||
} else if (speed === true) {
|
||||
swiper.setTransition(swiper.params.speed);
|
||||
}
|
||||
|
||||
const getSlideByIndex = index => {
|
||||
if (isVirtual) {
|
||||
return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) ===
|
||||
index)[
|
||||
0];
|
||||
}
|
||||
|
||||
return swiper.slides[index];
|
||||
}; // Find slides currently in view
|
||||
|
||||
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
||||
if (swiper.params.centeredSlides) {
|
||||
swiper.visibleSlides.each(slide => {
|
||||
activeSlides.push(slide);
|
||||
});
|
||||
} else {
|
||||
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
||||
const index = swiper.activeIndex + i;
|
||||
if (index > swiper.slides.length && !isVirtual) break;
|
||||
activeSlides.push(getSlideByIndex(index));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
activeSlides.push(getSlideByIndex(swiper.activeIndex));
|
||||
} // Find new height from highest slide in view
|
||||
|
||||
|
||||
for (i = 0; i < activeSlides.length; i += 1) {
|
||||
if (typeof activeSlides[i] !== 'undefined') {
|
||||
const size = await activeSlides[i].getSize();
|
||||
const height = size.height;
|
||||
newHeight = height > newHeight ? height : newHeight;
|
||||
}
|
||||
} // Update Height
|
||||
|
||||
|
||||
if (newHeight || newHeight === 0) swiper.$wrapperEl.css({
|
||||
height: `${newHeight?newHeight:''}px`
|
||||
});
|
||||
}
|
||||
35
uni_modules/zebra-swiper/libs/update/updateClickedSlide.js
Normal file
35
uni_modules/zebra-swiper/libs/update/updateClickedSlide.js
Normal file
@@ -0,0 +1,35 @@
|
||||
export default function updateClickedSlide(e) {
|
||||
const swiper = this;
|
||||
const params = swiper.params;
|
||||
const slide = swiper.slides[e];
|
||||
let slideFound = false;
|
||||
let slideIndex;
|
||||
|
||||
if (slide) {
|
||||
for (let i = 0; i < swiper.slides.length; i += 1) {
|
||||
if (swiper.slides[i] === slide) {
|
||||
slideFound = true;
|
||||
slideIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slide && slideFound) {
|
||||
swiper.clickedSlide = slide;
|
||||
|
||||
if (swiper.virtual && swiper.params.virtual.enabled) {
|
||||
swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10);
|
||||
} else {
|
||||
swiper.clickedIndex = slideIndex;
|
||||
}
|
||||
} else {
|
||||
swiper.clickedSlide = undefined;
|
||||
swiper.clickedIndex = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
|
||||
swiper.slideToClickedSlide();
|
||||
}
|
||||
}
|
||||
50
uni_modules/zebra-swiper/libs/update/updateProgress.js
Normal file
50
uni_modules/zebra-swiper/libs/update/updateProgress.js
Normal file
@@ -0,0 +1,50 @@
|
||||
export default function updateProgress(translate) {
|
||||
const swiper = this;
|
||||
|
||||
if (typeof translate === 'undefined') {
|
||||
const multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line
|
||||
|
||||
translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
|
||||
}
|
||||
|
||||
const params = swiper.params;
|
||||
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
||||
let {
|
||||
progress,
|
||||
isBeginning,
|
||||
isEnd
|
||||
} = swiper;
|
||||
const wasBeginning = isBeginning;
|
||||
const wasEnd = isEnd;
|
||||
|
||||
if (translatesDiff === 0) {
|
||||
progress = 0;
|
||||
isBeginning = true;
|
||||
isEnd = true;
|
||||
} else {
|
||||
progress = (translate - swiper.minTranslate()) / translatesDiff;
|
||||
isBeginning = progress <= 0;
|
||||
isEnd = progress >= 1;
|
||||
}
|
||||
|
||||
Object.assign(swiper, {
|
||||
progress,
|
||||
isBeginning,
|
||||
isEnd
|
||||
});
|
||||
if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
|
||||
|
||||
if (isBeginning && !wasBeginning) {
|
||||
swiper.emit('reachBeginning toEdge');
|
||||
}
|
||||
|
||||
if (isEnd && !wasEnd) {
|
||||
swiper.emit('reachEnd toEdge');
|
||||
}
|
||||
|
||||
if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
|
||||
swiper.emit('fromEdge');
|
||||
}
|
||||
|
||||
swiper.emit('progress', progress);
|
||||
}
|
||||
28
uni_modules/zebra-swiper/libs/update/updateSize.js
Normal file
28
uni_modules/zebra-swiper/libs/update/updateSize.js
Normal file
@@ -0,0 +1,28 @@
|
||||
export default function updateSize() {
|
||||
const swiper = this;
|
||||
let width;
|
||||
let height;
|
||||
const el = swiper.el;
|
||||
if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
|
||||
width = swiper.params.width;
|
||||
} else {
|
||||
width = el.width;
|
||||
}
|
||||
|
||||
if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
|
||||
height = swiper.params.height;
|
||||
} else {
|
||||
height = el.height;
|
||||
}
|
||||
|
||||
if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
|
||||
return;
|
||||
} // Subtract paddings
|
||||
if (Number.isNaN(width)) width = 0;
|
||||
if (Number.isNaN(height)) height = 0;
|
||||
Object.assign(swiper, {
|
||||
width,
|
||||
height,
|
||||
size: swiper.isHorizontal() ? width : height
|
||||
});
|
||||
}
|
||||
311
uni_modules/zebra-swiper/libs/update/updateSlides.js
Normal file
311
uni_modules/zebra-swiper/libs/update/updateSlides.js
Normal file
@@ -0,0 +1,311 @@
|
||||
import {
|
||||
setCSSProperty
|
||||
} from '../../shared/utils.js';
|
||||
export default function updateSlides() {
|
||||
const swiper = this;
|
||||
|
||||
function getDirectionLabel(property) {
|
||||
if (swiper.isHorizontal()) {
|
||||
return property;
|
||||
} // prettier-ignore
|
||||
|
||||
|
||||
return {
|
||||
'width': 'height',
|
||||
'margin-top': 'margin-left',
|
||||
'margin-bottom ': 'margin-right',
|
||||
'margin-left': 'margin-top',
|
||||
'margin-right': 'margin-bottom',
|
||||
'padding-left': 'padding-top',
|
||||
'padding-right': 'padding-bottom',
|
||||
'marginRight': 'marginBottom'
|
||||
} [property];
|
||||
}
|
||||
|
||||
function getDirectionPropertyValue(node, label) {
|
||||
return parseFloat(node[getDirectionLabel(label)] || 0);
|
||||
}
|
||||
|
||||
function getComputedStyle(native) {
|
||||
return native.itemStyle;
|
||||
}
|
||||
const params = swiper.params;
|
||||
const {
|
||||
$wrapperEl,
|
||||
size: swiperSize,
|
||||
rtlTranslate: rtl,
|
||||
wrongRTL
|
||||
} = swiper;
|
||||
const isVirtual = swiper.virtual && params.virtual.enabled;
|
||||
const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
||||
// const slides = $wrapperEl.children(`.${swiper.params.slideClass}`);
|
||||
const slides = swiper.slides;
|
||||
const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
|
||||
let snapGrid = [];
|
||||
const slidesGrid = [];
|
||||
const slidesSizesGrid = [];
|
||||
let offsetBefore = params.slidesOffsetBefore;
|
||||
|
||||
if (typeof offsetBefore === 'function') {
|
||||
offsetBefore = params.slidesOffsetBefore.call(swiper);
|
||||
}
|
||||
|
||||
let offsetAfter = params.slidesOffsetAfter;
|
||||
|
||||
if (typeof offsetAfter === 'function') {
|
||||
offsetAfter = params.slidesOffsetAfter.call(swiper);
|
||||
}
|
||||
|
||||
const previousSnapGridLength = swiper.snapGrid.length;
|
||||
const previousSlidesGridLength = swiper.slidesGrid.length;
|
||||
let spaceBetween = params.spaceBetween;
|
||||
let slidePosition = -offsetBefore;
|
||||
let prevSlideSize = 0;
|
||||
let index = 0;
|
||||
|
||||
if (typeof swiperSize === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
||||
spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
||||
}
|
||||
|
||||
swiper.virtualSize = -spaceBetween; // reset margins
|
||||
|
||||
if (params.centeredSlides && params.cssMode) {
|
||||
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', '');
|
||||
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', '');
|
||||
}
|
||||
|
||||
const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
|
||||
|
||||
if (gridEnabled) {
|
||||
swiper.grid.initSlides(slidesLength);
|
||||
}
|
||||
|
||||
|
||||
let slideSize;
|
||||
const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params
|
||||
.breakpoints).filter(key => {
|
||||
return typeof params.breakpoints[key].slidesPerView !== 'undefined';
|
||||
}).length > 0;
|
||||
Array(...Array(slidesLength)).forEach(async (item, i) => {
|
||||
slideSize = 0;
|
||||
const slide = slides[i];
|
||||
|
||||
if (gridEnabled) {
|
||||
swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel);
|
||||
}
|
||||
if (params.slidesPerView === 'auto') {
|
||||
if (shouldResetSlideSize) {
|
||||
slides[i].style[getDirectionLabel('width')] = ``;
|
||||
}
|
||||
|
||||
const slideStyles = getComputedStyle(slide);
|
||||
const currentTransform = slide.itemStyle.transform;
|
||||
const currentWebKitTransform = slide.itemStyle.webkitTransform;
|
||||
|
||||
if (currentTransform) {
|
||||
slide.itemStyle.transform = 'none';
|
||||
}
|
||||
|
||||
if (currentWebKitTransform) {
|
||||
slide.itemStyle.webkitTransform = 'none';
|
||||
}
|
||||
|
||||
if (params.roundLengths) {
|
||||
slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
|
||||
} else {
|
||||
const width = swiper.isHorizontal() ? slide.width : slide.height;
|
||||
const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
||||
const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
||||
const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
||||
const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
||||
const boxSizing = slideStyles['box-sizing'];
|
||||
|
||||
if (boxSizing && boxSizing === 'border-box') {
|
||||
slideSize = width + marginLeft + marginRight;
|
||||
} else {
|
||||
// slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight;
|
||||
slideSize = width;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentTransform) {
|
||||
slide.itemStyle.transform = currentTransform;
|
||||
}
|
||||
|
||||
if (currentWebKitTransform) {
|
||||
slide.itemStyle.webkitTransform = currentWebKitTransform;
|
||||
}
|
||||
|
||||
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
||||
} else {
|
||||
slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
||||
if (params.roundLengths) slideSize = Math.floor(slideSize);
|
||||
slides[i] && slides[i].css({
|
||||
[getDirectionLabel('width')]: `${slideSize}px`
|
||||
})
|
||||
}
|
||||
|
||||
if (slides[i]) {
|
||||
slides[i].swiperSlideSize = slideSize;
|
||||
}
|
||||
|
||||
if (params.autoHeight) {
|
||||
slides[i] && slides[i].css({
|
||||
height: 'auto'
|
||||
})
|
||||
}
|
||||
|
||||
slidesSizesGrid.push(slideSize);
|
||||
|
||||
if (params.centeredSlides) {
|
||||
slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
||||
if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 -
|
||||
spaceBetween;
|
||||
if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
||||
if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
||||
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
||||
if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
||||
slidesGrid.push(slidePosition);
|
||||
} else {
|
||||
if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
||||
if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params
|
||||
.slidesPerGroup === 0)
|
||||
snapGrid.push(slidePosition);
|
||||
slidesGrid.push(slidePosition);
|
||||
slidePosition = slidePosition + slideSize + spaceBetween;
|
||||
}
|
||||
swiper.virtualSize += slideSize + spaceBetween;
|
||||
prevSlideSize = slideSize;
|
||||
index += 1;
|
||||
})
|
||||
swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
|
||||
|
||||
if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
|
||||
$wrapperEl.css({
|
||||
width: `${swiper.virtualSize + params.spaceBetween}px`
|
||||
});
|
||||
}
|
||||
|
||||
if (params.setWrapperSize) {
|
||||
$wrapperEl.css({
|
||||
[getDirectionLabel('width')]: `${swiper.virtualSize + params.spaceBetween}px`
|
||||
});
|
||||
}
|
||||
|
||||
if (gridEnabled) {
|
||||
swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
|
||||
} // Remove last grid elements depending on width
|
||||
|
||||
|
||||
if (!params.centeredSlides) {
|
||||
const newSlidesGrid = [];
|
||||
|
||||
for (let i = 0; i < snapGrid.length; i += 1) {
|
||||
let slidesGridItem = snapGrid[i];
|
||||
if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
||||
|
||||
if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
|
||||
newSlidesGrid.push(slidesGridItem);
|
||||
}
|
||||
}
|
||||
snapGrid = newSlidesGrid;
|
||||
|
||||
if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
||||
snapGrid.push(swiper.virtualSize - swiperSize);
|
||||
}
|
||||
}
|
||||
|
||||
if (snapGrid.length === 0) snapGrid = [0];
|
||||
|
||||
if (params.spaceBetween !== 0) {
|
||||
// #ifdef MP-BAIDU
|
||||
const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
|
||||
// #endif
|
||||
// #ifndef MP-BAIDU
|
||||
const key = swiper.isHorizontal() && rtl ? 'margin-left' : getDirectionLabel('margin-right');
|
||||
// #endif
|
||||
slides.filter((_, slideIndex) => {
|
||||
if (!params.cssMode) return true;
|
||||
|
||||
if (slideIndex === slides.length - 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}).forEach((item) => {
|
||||
item.css({
|
||||
[key]: `${spaceBetween}px`
|
||||
})
|
||||
});
|
||||
}
|
||||
if (params.centeredSlides && params.centeredSlidesBounds) {
|
||||
let allSlidesSize = 0;
|
||||
slidesSizesGrid.forEach(slideSizeValue => {
|
||||
allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
|
||||
});
|
||||
allSlidesSize -= params.spaceBetween;
|
||||
const maxSnap = allSlidesSize - swiperSize;
|
||||
snapGrid = snapGrid.map(snap => {
|
||||
if (snap < 0) return -offsetBefore;
|
||||
if (snap > maxSnap) return maxSnap + offsetAfter;
|
||||
return snap;
|
||||
});
|
||||
}
|
||||
|
||||
if (params.centerInsufficientSlides) {
|
||||
let allSlidesSize = 0;
|
||||
slidesSizesGrid.forEach(slideSizeValue => {
|
||||
allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
|
||||
});
|
||||
allSlidesSize -= params.spaceBetween;
|
||||
|
||||
if (allSlidesSize < swiperSize) {
|
||||
const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
|
||||
snapGrid.forEach((snap, snapIndex) => {
|
||||
snapGrid[snapIndex] = snap - allSlidesOffset;
|
||||
});
|
||||
slidesGrid.forEach((snap, snapIndex) => {
|
||||
slidesGrid[snapIndex] = snap + allSlidesOffset;
|
||||
});
|
||||
}
|
||||
}
|
||||
Object.assign(swiper, {
|
||||
slides,
|
||||
snapGrid,
|
||||
slidesGrid,
|
||||
slidesSizesGrid
|
||||
});
|
||||
|
||||
if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
|
||||
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
|
||||
setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after',
|
||||
`${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
|
||||
const addToSnapGrid = -swiper.snapGrid[0];
|
||||
const addToSlidesGrid = -swiper.slidesGrid[0];
|
||||
swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
|
||||
swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
|
||||
}
|
||||
|
||||
if (slidesLength !== previousSlidesLength) {
|
||||
swiper.emit('slidesLengthChange');
|
||||
}
|
||||
|
||||
if (snapGrid.length !== previousSnapGridLength) {
|
||||
if (swiper.params.watchOverflow) swiper.checkOverflow();
|
||||
swiper.emit('snapGridLengthChange');
|
||||
}
|
||||
|
||||
if (slidesGrid.length !== previousSlidesGridLength) {
|
||||
swiper.emit('slidesGridLengthChange');
|
||||
}
|
||||
|
||||
if (params.watchSlidesProgress) {
|
||||
swiper.updateSlidesOffset();
|
||||
}
|
||||
|
||||
return slides;
|
||||
}
|
||||
119
uni_modules/zebra-swiper/libs/update/updateSlidesClasses.js
Normal file
119
uni_modules/zebra-swiper/libs/update/updateSlidesClasses.js
Normal file
@@ -0,0 +1,119 @@
|
||||
export default function updateSlidesClasses() {
|
||||
const swiper = this;
|
||||
const {
|
||||
slides,
|
||||
params,
|
||||
$wrapperEl,
|
||||
activeIndex,
|
||||
realIndex
|
||||
} = swiper;
|
||||
if (!slides.length || !$wrapperEl) return;
|
||||
const isVirtual = swiper.virtual && params.virtual.enabled;
|
||||
for (var i = 0; i < slides.length; i++) {
|
||||
slides[i].removeClass(
|
||||
`${params.slideActiveClass} ${params.slideNextClass} ${params.slidePrevClass} ${params.slideDuplicateActiveClass} ${params.slideDuplicateNextClass} ${params.slideDuplicatePrevClass}`
|
||||
);
|
||||
}
|
||||
|
||||
let activeSlide;
|
||||
|
||||
if (isVirtual) {
|
||||
// activeSlide = swiper.$wrapperEl.find(`.${params.slideClass}[data-swiper-slide-index="${activeIndex}"]`);
|
||||
activeSlide = slides[slides.findIndex((item) => {
|
||||
return item.dataSwiperSlideIndex == activeIndex
|
||||
})];
|
||||
} else {
|
||||
activeSlide = slides[activeIndex];
|
||||
} // Active classes
|
||||
|
||||
if (!activeSlide) return
|
||||
activeSlide.addClass(params.slideActiveClass);
|
||||
|
||||
if (params.loop) {
|
||||
if (activeSlide.hasClass(params.slideDuplicateClass)) {
|
||||
// $wrapperEl.children[realIndex].addClass(params.slideDuplicateActiveClass);
|
||||
let index = slides.findIndex((item) => {
|
||||
return !item.hasClass(params.slideDuplicateClass) && item.dataSwiperSlideIndex == realIndex
|
||||
})
|
||||
slides[index] && slides[index].addClass(params.slideDuplicateActiveClass);
|
||||
} else {
|
||||
// $wrapperEl.children[realIndex].addClass(params.slideDuplicateActiveClass);
|
||||
let index = slides.findIndex((item) => {
|
||||
return item.hasClass(params.slideDuplicateClass) && item.dataSwiperSlideIndex == realIndex
|
||||
})
|
||||
slides[index] && slides[index].addClass(params.slideDuplicateActiveClass);
|
||||
}
|
||||
} // Next Slide
|
||||
|
||||
|
||||
let nextSlide = activeSlide.nextAll(`.${params.slideClass}`)[0];
|
||||
if (nextSlide) {
|
||||
nextSlide.addClass(params.slideNextClass);
|
||||
} else {
|
||||
if (params.loop && !nextSlide) {
|
||||
nextSlide = slides[0];
|
||||
nextSlide.addClass(params.slideNextClass);
|
||||
} // Prev Slide
|
||||
}
|
||||
|
||||
|
||||
|
||||
let prevSlide = activeSlide.prevAll(`.${params.slideClass}`)[0];
|
||||
if (prevSlide) {
|
||||
prevSlide.addClass(params.slidePrevClass);
|
||||
} else {
|
||||
if (params.loop && !prevSlide) {
|
||||
prevSlide = slides[slides.length - 1];
|
||||
prevSlide.addClass(params.slidePrevClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (params.loop) {
|
||||
// Duplicate to all looped slides
|
||||
if (nextSlide.hasClass(params.slideDuplicateClass)) {
|
||||
// $wrapperEl.children(
|
||||
// nextSlide.dataSwiperSlideIndex
|
||||
// ).addClass(params.slideDuplicateNextClass);
|
||||
|
||||
let index = slides.findIndex((item) => {
|
||||
return !item.hasClass(params.slideDuplicateClass) && item.dataSwiperSlideIndex == nextSlide
|
||||
.dataSwiperSlideIndex
|
||||
})
|
||||
slides[index] && slides[index].addClass(params.slideDuplicateNextClass);
|
||||
|
||||
|
||||
} else {
|
||||
// $wrapperEl.children(
|
||||
// nextSlide.dataSwiperSlideIndex
|
||||
// ).addClass(params.slideDuplicateNextClass);
|
||||
|
||||
let index = slides.findIndex((item) => {
|
||||
return item.hasClass(params.slideDuplicateClass) && item.dataSwiperSlideIndex == nextSlide
|
||||
.dataSwiperSlideIndex
|
||||
})
|
||||
slides[index] && slides[index].addClass(params.slideDuplicateNextClass);
|
||||
}
|
||||
if (prevSlide.hasClass(params.slideDuplicateClass)) {
|
||||
// $wrapperEl.children(
|
||||
// prevSlide.dataSwiperSlideIndex
|
||||
// ).addClass(params.slideDuplicatePrevClass);
|
||||
let index = slides.findIndex((item) => {
|
||||
return !item.hasClass(params.slideDuplicateClass) && item.dataSwiperSlideIndex == prevSlide
|
||||
.dataSwiperSlideIndex
|
||||
})
|
||||
slides[index] && slides[index].addClass(params.slideDuplicatePrevClass);
|
||||
} else {
|
||||
// $wrapperEl.children(
|
||||
// prevSlide.dataSwiperSlideIndex
|
||||
// ).addClass(params.slideDuplicatePrevClass);
|
||||
let index = slides.findIndex((item) => {
|
||||
return item.hasClass(params.slideDuplicateClass) && item.dataSwiperSlideIndex == prevSlide
|
||||
.dataSwiperSlideIndex
|
||||
})
|
||||
slides[index] && slides[index].addClass(params.slideDuplicatePrevClass);
|
||||
}
|
||||
}
|
||||
|
||||
swiper.emitSlidesClasses();
|
||||
}
|
||||
11
uni_modules/zebra-swiper/libs/update/updateSlidesOffset.js
Normal file
11
uni_modules/zebra-swiper/libs/update/updateSlidesOffset.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export default async function updateSlidesOffset() {
|
||||
const swiper = this;
|
||||
const slides = swiper.slides;
|
||||
|
||||
for (let i = 0; i < slides.length; i += 1) {
|
||||
let offset = (slides[i].swiperSlideSize + swiper.params.spaceBetween) * slides[i].index;
|
||||
slides[i].swiperSlideOffset = swiper.isHorizontal() ? offset :
|
||||
offset;
|
||||
}
|
||||
|
||||
}
|
||||
45
uni_modules/zebra-swiper/libs/update/updateSlidesProgress.js
Normal file
45
uni_modules/zebra-swiper/libs/update/updateSlidesProgress.js
Normal file
@@ -0,0 +1,45 @@
|
||||
export default function updateSlidesProgress(translate = this && this.translate || 0) {
|
||||
const swiper = this;
|
||||
const params = swiper.params;
|
||||
const {
|
||||
slides,
|
||||
rtlTranslate: rtl,
|
||||
snapGrid
|
||||
} = swiper;
|
||||
if (slides.length === 0) return;
|
||||
if (typeof slides[0].swiperSlideOffset === 'undefined' || typeof slides[slides.length - 1].swiperSlideOffset ===
|
||||
'undefined') swiper
|
||||
.updateSlidesOffset();
|
||||
let offsetCenter = -translate;
|
||||
if (rtl) offsetCenter = translate; // Visible Slides
|
||||
|
||||
swiper.visibleSlidesIndexes = [];
|
||||
swiper.visibleSlides = [];
|
||||
|
||||
// slides.forEach((item)=>)
|
||||
|
||||
for (let i = 0; i < slides.length; i += 1) {
|
||||
const slide = slides[i];
|
||||
let slideOffset = slide.swiperSlideOffset;
|
||||
if (params.cssMode && params.centeredSlides) {
|
||||
slideOffset -= slides[0].swiperSlideOffset;
|
||||
}
|
||||
|
||||
const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (
|
||||
slide.swiperSlideSize + params.spaceBetween);
|
||||
const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() :
|
||||
0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
|
||||
const slideBefore = -(offsetCenter - slideOffset);
|
||||
const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
||||
const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper
|
||||
.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
||||
if (isVisible) {
|
||||
swiper.visibleSlides.push(slide);
|
||||
swiper.visibleSlidesIndexes.push(i);
|
||||
slides[i].addClass(params.slideVisibleClass);
|
||||
}
|
||||
|
||||
slide.progress = rtl ? -slideProgress : slideProgress;
|
||||
slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
|
||||
}
|
||||
}
|
||||
35
uni_modules/zebra-swiper/libs/utils/utils.js
Normal file
35
uni_modules/zebra-swiper/libs/utils/utils.js
Normal file
@@ -0,0 +1,35 @@
|
||||
export function getAllRect(context, selector) {
|
||||
return new Promise((resolve) => {
|
||||
uni.createSelectorQuery()
|
||||
.in(context)
|
||||
.selectAll(selector)
|
||||
.boundingClientRect()
|
||||
.exec((rect = []) => resolve(rect[0]));
|
||||
});
|
||||
}
|
||||
|
||||
export function getRect(context, selector) {
|
||||
return new Promise((resolve) => {
|
||||
uni.createSelectorQuery()
|
||||
.in(context)
|
||||
.select(selector)
|
||||
.boundingClientRect()
|
||||
.exec((rect = []) => resolve(rect[0]));
|
||||
});
|
||||
}
|
||||
|
||||
export function requestAnimationFrame(cb) {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
if (systemInfo.platform === 'devtools') {
|
||||
return setTimeout(() => {
|
||||
cb();
|
||||
}, 1000 / 30);
|
||||
}
|
||||
return uni
|
||||
.createSelectorQuery()
|
||||
.selectViewport()
|
||||
.boundingClientRect()
|
||||
.exec(() => {
|
||||
cb();
|
||||
});
|
||||
}
|
||||
50
uni_modules/zebra-swiper/libs/vue2/get-changed-params.js
Normal file
50
uni_modules/zebra-swiper/libs/vue2/get-changed-params.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
paramsList
|
||||
} from './params-list.js';
|
||||
import {
|
||||
isObject
|
||||
} from './utils.js';
|
||||
|
||||
function getChangedParams(swiperParams, oldParams, children, oldChildren) {
|
||||
const keys = [];
|
||||
if (!oldParams) return keys;
|
||||
const addKey = (key) => {
|
||||
if (keys.indexOf(key) < 0) keys.push(key);
|
||||
};
|
||||
const oldChildrenKeys = oldChildren.map((child) => child.props && child.props.key);
|
||||
const childrenKeys = children.map((child) => child.props && child.props.key);
|
||||
if (oldChildrenKeys.join('') !== childrenKeys.join('')) keys.push('children');
|
||||
if (oldChildren.length !== children.length) keys.push('children');
|
||||
const watchParams = paramsList.filter((key) => key[0] === '_').map((key) => key.replace(/_/, ''));
|
||||
watchParams.forEach((key) => {
|
||||
if (key in swiperParams && key in oldParams) {
|
||||
if (isObject(swiperParams[key]) && isObject(oldParams[key])) {
|
||||
const newKeys = Object.keys(swiperParams[key]);
|
||||
const oldKeys = Object.keys(oldParams[key]);
|
||||
if (newKeys.length !== oldKeys.length) {
|
||||
addKey(key);
|
||||
} else {
|
||||
newKeys.forEach((newKey) => {
|
||||
if (swiperParams[key][newKey] !== oldParams[key][newKey]) {
|
||||
addKey(key);
|
||||
}
|
||||
});
|
||||
oldKeys.forEach((oldKey) => {
|
||||
if (swiperParams[key][oldKey] !== oldParams[key][oldKey]) addKey(key);
|
||||
});
|
||||
}
|
||||
} else if (swiperParams[key] !== oldParams[key]) {
|
||||
addKey(key);
|
||||
}
|
||||
} else if (key in swiperParams && !(key in oldParams)) {
|
||||
addKey(key);
|
||||
} else if (!(key in swiperParams) && key in oldParams) {
|
||||
addKey(key);
|
||||
}
|
||||
});
|
||||
return keys;
|
||||
}
|
||||
|
||||
export {
|
||||
getChangedParams
|
||||
};
|
||||
57
uni_modules/zebra-swiper/libs/vue2/get-params.js
Normal file
57
uni_modules/zebra-swiper/libs/vue2/get-params.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import Swiper from '../../index.js';
|
||||
import {
|
||||
isObject,
|
||||
extend
|
||||
} from './utils.js';
|
||||
import {
|
||||
paramsList
|
||||
} from './params-list.js';
|
||||
|
||||
function getParams(obj = {}) {
|
||||
const params = {
|
||||
on: {},
|
||||
};
|
||||
const passedParams = {};
|
||||
extend(params, Swiper.defaults);
|
||||
extend(params, Swiper.extendedDefaults);
|
||||
params._emitClasses = true;
|
||||
params.init = false;
|
||||
|
||||
const rest = {};
|
||||
const allowedParams = paramsList.map((key) => key.replace(/_/, ''));
|
||||
// Prevent empty Object.keys(obj) array on ios.
|
||||
const plainObj = Object.assign({}, obj);
|
||||
Object.keys(plainObj).forEach((key) => {
|
||||
if (typeof obj[key] === 'undefined') return;
|
||||
if (allowedParams.indexOf(key) >= 0) {
|
||||
if (isObject(obj[key])) {
|
||||
params[key] = {};
|
||||
passedParams[key] = {};
|
||||
extend(params[key], obj[key]);
|
||||
extend(passedParams[key], obj[key]);
|
||||
} else {
|
||||
params[key] = obj[key];
|
||||
passedParams[key] = obj[key];
|
||||
}
|
||||
} else if (key.search(/on[A-Z]/) === 0 && typeof obj[key] === 'function') {
|
||||
params.on[`${key[2].toLowerCase()}${key.substr(3)}`] = obj[key];
|
||||
} else {
|
||||
rest[key] = obj[key];
|
||||
}
|
||||
});
|
||||
|
||||
['navigation', 'pagination', 'scrollbar'].forEach((key) => {
|
||||
if (params[key] === true) params[key] = {};
|
||||
if (params[key] === false) delete params[key];
|
||||
});
|
||||
|
||||
return {
|
||||
params,
|
||||
passedParams,
|
||||
rest
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
getParams
|
||||
};
|
||||
40
uni_modules/zebra-swiper/libs/vue2/init-swiper.js
Normal file
40
uni_modules/zebra-swiper/libs/vue2/init-swiper.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import Swiper from '../../index.js';
|
||||
import {
|
||||
needsNavigation,
|
||||
needsPagination,
|
||||
needsScrollbar
|
||||
} from './utils.js';
|
||||
|
||||
function initSwiper(swiperParams, native) {
|
||||
return new Swiper(swiperParams, native);
|
||||
}
|
||||
|
||||
function mountSwiper({
|
||||
el,
|
||||
nextEl,
|
||||
prevEl,
|
||||
paginationEl,
|
||||
scrollbarEl,
|
||||
swiper
|
||||
}, swiperParams) {
|
||||
if (needsNavigation(swiperParams) && nextEl && prevEl) {
|
||||
swiper.params.navigation.nextEl = nextEl;
|
||||
swiper.originalParams.navigation.nextEl = nextEl;
|
||||
swiper.params.navigation.prevEl = prevEl;
|
||||
swiper.originalParams.navigation.prevEl = prevEl;
|
||||
}
|
||||
if (needsPagination(swiperParams) && paginationEl) {
|
||||
swiper.params.pagination.el = paginationEl;
|
||||
swiper.originalParams.pagination.el = paginationEl;
|
||||
}
|
||||
if (needsScrollbar(swiperParams) && scrollbarEl) {
|
||||
swiper.params.scrollbar.el = scrollbarEl;
|
||||
swiper.originalParams.scrollbar.el = scrollbarEl;
|
||||
}
|
||||
swiper.init(el);
|
||||
}
|
||||
|
||||
export {
|
||||
initSwiper,
|
||||
mountSwiper
|
||||
};
|
||||
73
uni_modules/zebra-swiper/libs/vue2/loop.js
Normal file
73
uni_modules/zebra-swiper/libs/vue2/loop.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import Swiper from '../../index.js';
|
||||
|
||||
function calcLoopedSlides(slides, swiperParams) {
|
||||
let slidesPerViewParams = swiperParams.slidesPerView;
|
||||
if (swiperParams.breakpoints) {
|
||||
const breakpoint = Swiper.prototype.getBreakpoint(swiperParams.breakpoints);
|
||||
const breakpointOnlyParams =
|
||||
breakpoint in swiperParams.breakpoints ? swiperParams.breakpoints[breakpoint] : undefined;
|
||||
if (breakpointOnlyParams && breakpointOnlyParams.slidesPerView) {
|
||||
slidesPerViewParams = breakpointOnlyParams.slidesPerView;
|
||||
}
|
||||
}
|
||||
let loopedSlides = Math.ceil(parseFloat(swiperParams.loopedSlides || slidesPerViewParams, 10));
|
||||
|
||||
loopedSlides += swiperParams.loopAdditionalSlides;
|
||||
|
||||
if (loopedSlides > slides.length) {
|
||||
loopedSlides = slides.length;
|
||||
}
|
||||
return loopedSlides;
|
||||
}
|
||||
|
||||
function renderLoop(native, swiperParams, data) {
|
||||
const modifiedValue = data;
|
||||
if (swiperParams.loopFillGroupWithBlank) {
|
||||
const blankSlidesNum =
|
||||
swiperParams.slidesPerGroup - (modifiedValue.length % swiperParams.slidesPerGroup);
|
||||
if (blankSlidesNum !== swiperParams.slidesPerGroup) {
|
||||
for (let i = 0; i < blankSlidesNum; i += 1) {
|
||||
const blankSlide = h('div', {
|
||||
class: `${swiperParams.slideClass} ${swiperParams.slideBlankClass}`,
|
||||
});
|
||||
modifiedValue.push(blankSlide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (swiperParams.slidesPerView === 'auto' && !swiperParams.loopedSlides) {
|
||||
swiperParams.loopedSlides = modifiedValue.length;
|
||||
}
|
||||
|
||||
const loopedSlides = calcLoopedSlides(modifiedValue, swiperParams);
|
||||
|
||||
const prependSlides = [];
|
||||
const appendSlides = [];
|
||||
const prependValue = [];
|
||||
const appendValue = [];
|
||||
modifiedValue.forEach((child, index) => {
|
||||
if (index < loopedSlides) {
|
||||
if (!native.loopUpdateData) {
|
||||
appendValue.push(child);
|
||||
}
|
||||
}
|
||||
if (index < modifiedValue.length && index >= modifiedValue.length - loopedSlides) {
|
||||
if (!native.loopUpdateData) {
|
||||
prependValue.push(child);
|
||||
}
|
||||
}
|
||||
})
|
||||
if (native) {
|
||||
if (!native.originalDataList) native.originalDataList = [];
|
||||
native.originalDataList = [...prependValue, ...modifiedValue, ...appendValue];
|
||||
}
|
||||
|
||||
return {
|
||||
data: [...prependValue, ...modifiedValue, ...appendValue]
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
calcLoopedSlides,
|
||||
renderLoop
|
||||
};
|
||||
123
uni_modules/zebra-swiper/libs/vue2/params-list.js
Normal file
123
uni_modules/zebra-swiper/libs/vue2/params-list.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/* underscore in name -> watch for changes */
|
||||
const paramsList = [
|
||||
'modules',
|
||||
'init',
|
||||
'_direction',
|
||||
'touchEventsTarget',
|
||||
'initialSlide',
|
||||
'_speed',
|
||||
'cssMode',
|
||||
'updateOnWindowResize',
|
||||
'resizeObserver',
|
||||
'nested',
|
||||
'focusableElements',
|
||||
'_enabled',
|
||||
'_width',
|
||||
'_height',
|
||||
'preventInteractionOnTransition',
|
||||
'userAgent',
|
||||
'url',
|
||||
'_edgeSwipeDetection',
|
||||
'_edgeSwipeThreshold',
|
||||
'_freeMode',
|
||||
'_autoHeight',
|
||||
'setWrapperSize',
|
||||
'virtualTranslate',
|
||||
'_effect',
|
||||
'breakpoints',
|
||||
'_spaceBetween',
|
||||
'_slidesPerView',
|
||||
'maxBackfaceHiddenSlides',
|
||||
'_grid',
|
||||
'_slidesPerGroup',
|
||||
'_slidesPerGroupSkip',
|
||||
'_slidesPerGroupAuto',
|
||||
'_centeredSlides',
|
||||
'_centeredSlidesBounds',
|
||||
'_slidesOffsetBefore',
|
||||
'_slidesOffsetAfter',
|
||||
'normalizeSlideIndex',
|
||||
'_centerInsufficientSlides',
|
||||
'_watchOverflow',
|
||||
'roundLengths',
|
||||
'touchRatio',
|
||||
'touchAngle',
|
||||
'simulateTouch',
|
||||
'_shortSwipes',
|
||||
'_longSwipes',
|
||||
'longSwipesRatio',
|
||||
'longSwipesMs',
|
||||
'_followFinger',
|
||||
'allowTouchMove',
|
||||
'_threshold',
|
||||
'touchMoveStopPropagation',
|
||||
'touchStartPreventDefault',
|
||||
'touchStartForcePreventDefault',
|
||||
'touchReleaseOnEdges',
|
||||
'uniqueNavElements',
|
||||
'_resistance',
|
||||
'_resistanceRatio',
|
||||
'_watchSlidesProgress',
|
||||
'_grabCursor',
|
||||
'preventClicks',
|
||||
'preventClicksPropagation',
|
||||
'_slideToClickedSlide',
|
||||
'_preloadImages',
|
||||
'updateOnImagesReady',
|
||||
'_loop',
|
||||
'_loopAdditionalSlides',
|
||||
'_loopedSlides',
|
||||
'_loopFillGroupWithBlank',
|
||||
'loopPreventsSlide',
|
||||
'_rewind',
|
||||
'_allowSlidePrev',
|
||||
'_allowSlideNext',
|
||||
'_swipeHandler',
|
||||
'_noSwiping',
|
||||
'noSwipingClass',
|
||||
'noSwipingSelector',
|
||||
'passiveListeners',
|
||||
'containerModifierClass',
|
||||
'slideClass',
|
||||
'slideBlankClass',
|
||||
'slideActiveClass',
|
||||
'slideDuplicateActiveClass',
|
||||
'slideVisibleClass',
|
||||
'slideDuplicateClass',
|
||||
'slideNextClass',
|
||||
'slideDuplicateNextClass',
|
||||
'slidePrevClass',
|
||||
'slideDuplicatePrevClass',
|
||||
'wrapperClass',
|
||||
'runCallbacksOnInit',
|
||||
'observer',
|
||||
'observeParents',
|
||||
'observeSlideChildren',
|
||||
|
||||
// modules
|
||||
'a11y',
|
||||
'_autoplay',
|
||||
'_controller',
|
||||
'coverflowEffect',
|
||||
'cubeEffect',
|
||||
'fadeEffect',
|
||||
'flipEffect',
|
||||
'creativeEffect',
|
||||
'cardsEffect',
|
||||
'panorama',
|
||||
'hashNavigation',
|
||||
'history',
|
||||
'keyboard',
|
||||
'lazy',
|
||||
'mousewheel',
|
||||
'_navigation',
|
||||
'_pagination',
|
||||
'parallax',
|
||||
'_scrollbar',
|
||||
'_thumbs',
|
||||
'_virtual',
|
||||
'zoom',
|
||||
];
|
||||
export {
|
||||
paramsList
|
||||
};
|
||||
167
uni_modules/zebra-swiper/libs/vue2/update-swiper.js
Normal file
167
uni_modules/zebra-swiper/libs/vue2/update-swiper.js
Normal file
@@ -0,0 +1,167 @@
|
||||
import {
|
||||
isObject,
|
||||
extend
|
||||
} from './utils.js';
|
||||
|
||||
async function updateSwiper({
|
||||
swiper,
|
||||
slides,
|
||||
passedParams,
|
||||
changedParams,
|
||||
nextEl,
|
||||
prevEl,
|
||||
paginationEl,
|
||||
scrollbarEl,
|
||||
}) {
|
||||
const updateParams = changedParams.filter((key) => key !== 'children' && key !== 'direction');
|
||||
const {
|
||||
params: currentParams,
|
||||
pagination,
|
||||
navigation,
|
||||
scrollbar,
|
||||
virtual,
|
||||
thumbs
|
||||
} = swiper;
|
||||
let needThumbsInit;
|
||||
let needControllerInit;
|
||||
let needPaginationInit;
|
||||
let needScrollbarInit;
|
||||
let needNavigationInit;
|
||||
if (
|
||||
changedParams.includes('thumbs') &&
|
||||
passedParams.thumbs &&
|
||||
passedParams.thumbs.swiper &&
|
||||
currentParams.thumbs &&
|
||||
!currentParams.thumbs.swiper
|
||||
) {
|
||||
needThumbsInit = true;
|
||||
}
|
||||
if (
|
||||
changedParams.includes('controller') &&
|
||||
passedParams.controller &&
|
||||
passedParams.controller.control &&
|
||||
currentParams.controller &&
|
||||
!currentParams.controller.control
|
||||
) {
|
||||
needControllerInit = true;
|
||||
}
|
||||
if (
|
||||
changedParams.includes('pagination') &&
|
||||
passedParams.pagination &&
|
||||
(passedParams.pagination.el || paginationEl) &&
|
||||
(currentParams.pagination || currentParams.pagination === false) &&
|
||||
pagination &&
|
||||
!pagination.el
|
||||
) {
|
||||
needPaginationInit = true;
|
||||
}
|
||||
|
||||
if (
|
||||
changedParams.includes('scrollbar') &&
|
||||
passedParams.scrollbar &&
|
||||
(passedParams.scrollbar.el || scrollbarEl) &&
|
||||
(currentParams.scrollbar || currentParams.scrollbar === false) &&
|
||||
scrollbar &&
|
||||
!scrollbar.el
|
||||
) {
|
||||
needScrollbarInit = true;
|
||||
}
|
||||
|
||||
if (
|
||||
changedParams.includes('navigation') &&
|
||||
passedParams.navigation &&
|
||||
(passedParams.navigation.prevEl || prevEl) &&
|
||||
(passedParams.navigation.nextEl || nextEl) &&
|
||||
(currentParams.navigation || currentParams.navigation === false) &&
|
||||
navigation &&
|
||||
!navigation.prevEl &&
|
||||
!navigation.nextEl
|
||||
) {
|
||||
needNavigationInit = true;
|
||||
}
|
||||
|
||||
const destroyModule = (mod) => {
|
||||
if (!swiper[mod]) return;
|
||||
swiper[mod].destroy();
|
||||
if (mod === 'navigation') {
|
||||
currentParams[mod].prevEl = undefined;
|
||||
currentParams[mod].nextEl = undefined;
|
||||
swiper[mod].prevEl = undefined;
|
||||
swiper[mod].nextEl = undefined;
|
||||
} else {
|
||||
currentParams[mod].el = undefined;
|
||||
swiper[mod].el = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
updateParams.forEach((key) => {
|
||||
if (isObject(currentParams[key]) && isObject(passedParams[key])) {
|
||||
extend(currentParams[key], passedParams[key]);
|
||||
} else {
|
||||
const newValue = passedParams[key];
|
||||
if (
|
||||
(newValue === true || newValue === false) &&
|
||||
(key === 'navigation' || key === 'pagination' || key === 'scrollbar')
|
||||
) {
|
||||
if (newValue === false) {
|
||||
destroyModule(key);
|
||||
}
|
||||
} else {
|
||||
currentParams[key] = passedParams[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
// if (changedParams.includes('virtual') && virtual && currentParams.virtual.enabled) {
|
||||
// virtual.update();
|
||||
// }
|
||||
if (changedParams.includes('children') && virtual && currentParams.virtual.enabled) {
|
||||
// virtual.slides = slides;
|
||||
virtual.update(true);
|
||||
} else if (changedParams.includes('children') && swiper.lazy && swiper.params.lazy.enabled) {
|
||||
swiper.lazy.load();
|
||||
}
|
||||
|
||||
if (needThumbsInit) {
|
||||
const initialized = thumbs.init();
|
||||
if (initialized) thumbs.update(true);
|
||||
}
|
||||
|
||||
if (needControllerInit) {
|
||||
swiper.controller.control = currentParams.controller.control;
|
||||
}
|
||||
|
||||
if (needPaginationInit) {
|
||||
if (paginationEl) currentParams.pagination.el = paginationEl;
|
||||
pagination.init();
|
||||
pagination.render();
|
||||
pagination.update();
|
||||
}
|
||||
|
||||
if (needScrollbarInit) {
|
||||
if (scrollbarEl) currentParams.scrollbar.el = scrollbarEl;
|
||||
scrollbar.init();
|
||||
scrollbar.updateSize();
|
||||
scrollbar.setTranslate();
|
||||
}
|
||||
|
||||
if (needNavigationInit) {
|
||||
if (nextEl) currentParams.navigation.nextEl = nextEl;
|
||||
if (prevEl) currentParams.navigation.prevEl = prevEl;
|
||||
navigation.init();
|
||||
navigation.update();
|
||||
}
|
||||
|
||||
if (changedParams.includes('allowSlideNext')) {
|
||||
swiper.allowSlideNext = passedParams.allowSlideNext;
|
||||
}
|
||||
if (changedParams.includes('allowSlidePrev')) {
|
||||
swiper.allowSlidePrev = passedParams.allowSlidePrev;
|
||||
}
|
||||
if (changedParams.includes('direction')) {
|
||||
swiper.changeDirection(passedParams.direction, false);
|
||||
}
|
||||
swiper.update();
|
||||
}
|
||||
export {
|
||||
updateSwiper
|
||||
};
|
||||
60
uni_modules/zebra-swiper/libs/vue2/utils.js
Normal file
60
uni_modules/zebra-swiper/libs/vue2/utils.js
Normal file
@@ -0,0 +1,60 @@
|
||||
function isObject(o) {
|
||||
return (
|
||||
typeof o === 'object' &&
|
||||
o !== null &&
|
||||
o.constructor &&
|
||||
Object.prototype.toString.call(o).slice(8, -1) === 'Object'
|
||||
);
|
||||
}
|
||||
|
||||
function extend(target, src) {
|
||||
const noExtend = ['__proto__', 'constructor', 'prototype'];
|
||||
Object.keys(src)
|
||||
.filter((key) => noExtend.indexOf(key) < 0)
|
||||
.forEach((key) => {
|
||||
if (typeof target[key] === 'undefined') target[key] = src[key];
|
||||
else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
|
||||
if (src[key].__swiper__) target[key] = src[key];
|
||||
else extend(target[key], src[key]);
|
||||
} else {
|
||||
target[key] = src[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function needsNavigation(props = {}) {
|
||||
return (
|
||||
props.navigation &&
|
||||
typeof props.navigation.nextEl === 'undefined' &&
|
||||
typeof props.navigation.prevEl === 'undefined'
|
||||
);
|
||||
}
|
||||
|
||||
function needsPagination(props = {}) {
|
||||
return props.pagination && typeof props.pagination.el === 'undefined';
|
||||
}
|
||||
|
||||
function needsScrollbar(props = {}) {
|
||||
return props.scrollbar;
|
||||
}
|
||||
|
||||
function uniqueClasses(classNames = '') {
|
||||
const classes = classNames
|
||||
.split(' ')
|
||||
.map((c) => c.trim())
|
||||
.filter((c) => !!c);
|
||||
const unique = [];
|
||||
classes.forEach((c) => {
|
||||
if (unique.indexOf(c) < 0) unique.push(c);
|
||||
});
|
||||
return unique.join(' ');
|
||||
}
|
||||
|
||||
export {
|
||||
isObject,
|
||||
extend,
|
||||
needsNavigation,
|
||||
needsPagination,
|
||||
needsScrollbar,
|
||||
uniqueClasses
|
||||
};
|
||||
44
uni_modules/zebra-swiper/libs/vue2/virtual.js
Normal file
44
uni_modules/zebra-swiper/libs/vue2/virtual.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// import { h } from 'vue';
|
||||
|
||||
function updateOnVirtualData(swiper) {
|
||||
if (
|
||||
!swiper ||
|
||||
swiper.destroyed ||
|
||||
!swiper.params.virtual ||
|
||||
(swiper.params.virtual && !swiper.params.virtual.enabled)
|
||||
) return;
|
||||
swiper.updateSlides();
|
||||
swiper.updateProgress();
|
||||
swiper.updateSlidesClasses();
|
||||
if (swiper.lazy && swiper.params.lazy.enabled) {
|
||||
swiper.lazy.load();
|
||||
}
|
||||
if (swiper.parallax && swiper.params.parallax && swiper.params.parallax.enabled) {
|
||||
swiper.parallax.setTranslate();
|
||||
}
|
||||
}
|
||||
|
||||
function renderVirtual(swiperRef, slides, virtualData) {
|
||||
if (!virtualData) return null;
|
||||
const style = swiperRef.isHorizontal() ? {
|
||||
[swiperRef.rtlTranslate ? 'right' : 'left']: `${virtualData.offset}px`,
|
||||
} : {
|
||||
top: `${virtualData.offset}px`,
|
||||
};
|
||||
return slides
|
||||
.filter((slide, index) => index >= virtualData.from && index <= virtualData.to)
|
||||
.map((slide) => {
|
||||
if (!slide.props) slide.props = {};
|
||||
if (!slide.props.style) slide.props.style = {};
|
||||
slide.props.swiperRef = swiperRef;
|
||||
slide.props.style = style;
|
||||
return h(slide.type, {
|
||||
...slide.props
|
||||
}, slide.children);
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
renderVirtual,
|
||||
updateOnVirtualData
|
||||
};
|
||||
Reference in New Issue
Block a user