code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
function disableDraggable() {
if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
events('off');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | disableDraggable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function init() {
const {
scrollbar,
$el: $swiperEl
} = swiper;
swiper.params.scrollbar = createElementIfNotDefined(swiper, swiper.originalParams.scrollbar, swiper.params.scrollbar, {
el: 'swiper-scrollbar'
});
const params = swiper.params.scrollbar;
if (!params.el) return;
let $el = $(params.el);
if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {
$el = $swiperEl.find(params.el);
}
$el.addClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
let $dragEl = $el.find(`.${swiper.params.scrollbar.dragClass}`);
if ($dragEl.length === 0) {
$dragEl = $(`<div class="${swiper.params.scrollbar.dragClass}"></div>`);
$el.append($dragEl);
}
Object.assign(scrollbar, {
$el,
el: $el[0],
$dragEl,
dragEl: $dragEl[0]
});
if (params.draggable) {
enableDraggable();
}
if ($el) {
$el[swiper.enabled ? 'removeClass' : 'addClass'](swiper.params.scrollbar.lockClass);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function destroy() {
const params = swiper.params.scrollbar;
const $el = swiper.scrollbar.$el;
if ($el) {
$el.removeClass(swiper.isHorizontal() ? params.horizontalClass : params.verticalClass);
}
disableDraggable();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | destroy | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
enable = () => {
swiper.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass);
if (swiper.scrollbar.$el) {
swiper.scrollbar.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass);
}
init();
updateSize();
setTranslate();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | enable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
enable = () => {
swiper.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass);
if (swiper.scrollbar.$el) {
swiper.scrollbar.$el.removeClass(swiper.params.scrollbar.scrollbarDisabledClass);
}
init();
updateSize();
setTranslate();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | enable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
disable = () => {
swiper.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass);
if (swiper.scrollbar.$el) {
swiper.scrollbar.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass);
}
destroy();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | disable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
disable = () => {
swiper.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass);
if (swiper.scrollbar.$el) {
swiper.scrollbar.$el.addClass(swiper.params.scrollbar.scrollbarDisabledClass);
}
destroy();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | disable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function Parallax(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
parallax: {
enabled: false
}
});
const setTransform = (el, progress) => {
const {
rtl
} = swiper;
const $el = $(el);
const rtlFactor = rtl ? -1 : 1;
const p = $el.attr('data-swiper-parallax') || '0';
let x = $el.attr('data-swiper-parallax-x');
let y = $el.attr('data-swiper-parallax-y');
const scale = $el.attr('data-swiper-parallax-scale');
const opacity = $el.attr('data-swiper-parallax-opacity');
if (x || y) {
x = x || '0';
y = y || '0';
} else if (swiper.isHorizontal()) {
x = p;
y = '0';
} else {
y = p;
x = '0';
}
if (x.indexOf('%') >= 0) {
x = `${parseInt(x, 10) * progress * rtlFactor}%`;
} else {
x = `${x * progress * rtlFactor}px`;
}
if (y.indexOf('%') >= 0) {
y = `${parseInt(y, 10) * progress}%`;
} else {
y = `${y * progress}px`;
}
if (typeof opacity !== 'undefined' && opacity !== null) {
const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
$el[0].style.opacity = currentOpacity;
}
if (typeof scale === 'undefined' || scale === null) {
$el.transform(`translate3d(${x}, ${y}, 0px)`);
} else {
const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
$el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentScale})`);
}
};
const setTranslate = () => {
const {
$el,
slides,
progress,
snapGrid
} = swiper;
$el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
setTransform(el, progress);
});
slides.each((slideEl, slideIndex) => {
let slideProgress = slideEl.progress;
if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
}
slideProgress = Math.min(Math.max(slideProgress, -1), 1);
$(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
setTransform(el, slideProgress);
});
});
};
const setTransition = function (duration) {
if (duration === void 0) {
duration = swiper.params.speed;
}
const {
$el
} = swiper;
$el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxEl => {
const $parallaxEl = $(parallaxEl);
let parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration;
if (duration === 0) parallaxDuration = 0;
$parallaxEl.transition(parallaxDuration);
});
};
on('beforeInit', () => {
if (!swiper.params.parallax.enabled) return;
swiper.params.watchSlidesProgress = true;
swiper.originalParams.watchSlidesProgress = true;
});
on('init', () => {
if (!swiper.params.parallax.enabled) return;
setTranslate();
});
on('setTranslate', () => {
if (!swiper.params.parallax.enabled) return;
setTranslate();
});
on('setTransition', (_swiper, duration) => {
if (!swiper.params.parallax.enabled) return;
setTransition(duration);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Parallax | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setTransform = (el, progress) => {
const {
rtl
} = swiper;
const $el = $(el);
const rtlFactor = rtl ? -1 : 1;
const p = $el.attr('data-swiper-parallax') || '0';
let x = $el.attr('data-swiper-parallax-x');
let y = $el.attr('data-swiper-parallax-y');
const scale = $el.attr('data-swiper-parallax-scale');
const opacity = $el.attr('data-swiper-parallax-opacity');
if (x || y) {
x = x || '0';
y = y || '0';
} else if (swiper.isHorizontal()) {
x = p;
y = '0';
} else {
y = p;
x = '0';
}
if (x.indexOf('%') >= 0) {
x = `${parseInt(x, 10) * progress * rtlFactor}%`;
} else {
x = `${x * progress * rtlFactor}px`;
}
if (y.indexOf('%') >= 0) {
y = `${parseInt(y, 10) * progress}%`;
} else {
y = `${y * progress}px`;
}
if (typeof opacity !== 'undefined' && opacity !== null) {
const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
$el[0].style.opacity = currentOpacity;
}
if (typeof scale === 'undefined' || scale === null) {
$el.transform(`translate3d(${x}, ${y}, 0px)`);
} else {
const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
$el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentScale})`);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTransform | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setTransform = (el, progress) => {
const {
rtl
} = swiper;
const $el = $(el);
const rtlFactor = rtl ? -1 : 1;
const p = $el.attr('data-swiper-parallax') || '0';
let x = $el.attr('data-swiper-parallax-x');
let y = $el.attr('data-swiper-parallax-y');
const scale = $el.attr('data-swiper-parallax-scale');
const opacity = $el.attr('data-swiper-parallax-opacity');
if (x || y) {
x = x || '0';
y = y || '0';
} else if (swiper.isHorizontal()) {
x = p;
y = '0';
} else {
y = p;
x = '0';
}
if (x.indexOf('%') >= 0) {
x = `${parseInt(x, 10) * progress * rtlFactor}%`;
} else {
x = `${x * progress * rtlFactor}px`;
}
if (y.indexOf('%') >= 0) {
y = `${parseInt(y, 10) * progress}%`;
} else {
y = `${y * progress}px`;
}
if (typeof opacity !== 'undefined' && opacity !== null) {
const currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
$el[0].style.opacity = currentOpacity;
}
if (typeof scale === 'undefined' || scale === null) {
$el.transform(`translate3d(${x}, ${y}, 0px)`);
} else {
const currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
$el.transform(`translate3d(${x}, ${y}, 0px) scale(${currentScale})`);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTransform | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setTranslate = () => {
const {
$el,
slides,
progress,
snapGrid
} = swiper;
$el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
setTransform(el, progress);
});
slides.each((slideEl, slideIndex) => {
let slideProgress = slideEl.progress;
if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
}
slideProgress = Math.min(Math.max(slideProgress, -1), 1);
$(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
setTransform(el, slideProgress);
});
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTranslate | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setTranslate = () => {
const {
$el,
slides,
progress,
snapGrid
} = swiper;
$el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
setTransform(el, progress);
});
slides.each((slideEl, slideIndex) => {
let slideProgress = slideEl.progress;
if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
}
slideProgress = Math.min(Math.max(slideProgress, -1), 1);
$(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(el => {
setTransform(el, slideProgress);
});
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTranslate | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setTransition = function (duration) {
if (duration === void 0) {
duration = swiper.params.speed;
}
const {
$el
} = swiper;
$el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxEl => {
const $parallaxEl = $(parallaxEl);
let parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration;
if (duration === 0) parallaxDuration = 0;
$parallaxEl.transition(parallaxDuration);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTransition | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setTransition = function (duration) {
if (duration === void 0) {
duration = swiper.params.speed;
}
const {
$el
} = swiper;
$el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(parallaxEl => {
const $parallaxEl = $(parallaxEl);
let parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration;
if (duration === 0) parallaxDuration = 0;
$parallaxEl.transition(parallaxDuration);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTransition | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function Zoom(_ref) {
let {
swiper,
extendParams,
on,
emit
} = _ref;
const window = getWindow();
extendParams({
zoom: {
enabled: false,
maxRatio: 3,
minRatio: 1,
toggle: true,
containerClass: 'swiper-zoom-container',
zoomedSlideClass: 'swiper-slide-zoomed'
}
});
swiper.zoom = {
enabled: false
};
let currentScale = 1;
let isScaling = false;
let gesturesEnabled;
let fakeGestureTouched;
let fakeGestureMoved;
const gesture = {
$slideEl: undefined,
slideWidth: undefined,
slideHeight: undefined,
$imageEl: undefined,
$imageWrapEl: undefined,
maxRatio: 3
};
const image = {
isTouched: undefined,
isMoved: undefined,
currentX: undefined,
currentY: undefined,
minX: undefined,
minY: undefined,
maxX: undefined,
maxY: undefined,
width: undefined,
height: undefined,
startX: undefined,
startY: undefined,
touchesStart: {},
touchesCurrent: {}
};
const velocity = {
x: undefined,
y: undefined,
prevPositionX: undefined,
prevPositionY: undefined,
prevTime: undefined
};
let scale = 1;
Object.defineProperty(swiper.zoom, 'scale', {
get() {
return scale;
},
set(value) {
if (scale !== value) {
const imageEl = gesture.$imageEl ? gesture.$imageEl[0] : undefined;
const slideEl = gesture.$slideEl ? gesture.$slideEl[0] : undefined;
emit('zoomChange', value, imageEl, slideEl);
}
scale = value;
}
});
function getDistanceBetweenTouches(e) {
if (e.targetTouches.length < 2) return 1;
const x1 = e.targetTouches[0].pageX;
const y1 = e.targetTouches[0].pageY;
const x2 = e.targetTouches[1].pageX;
const y2 = e.targetTouches[1].pageY;
const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
return distance;
} // Events
function onGestureStart(e) {
const support = swiper.support;
const params = swiper.params.zoom;
fakeGestureTouched = false;
fakeGestureMoved = false;
if (!support.gestures) {
if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
return;
}
fakeGestureTouched = true;
gesture.scaleStart = getDistanceBetweenTouches(e);
}
if (!gesture.$slideEl || !gesture.$slideEl.length) {
gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`);
if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
if (gesture.$imageWrapEl.length === 0) {
gesture.$imageEl = undefined;
return;
}
}
if (gesture.$imageEl) {
gesture.$imageEl.transition(0);
}
isScaling = true;
}
function onGestureChange(e) {
const support = swiper.support;
const params = swiper.params.zoom;
const zoom = swiper.zoom;
if (!support.gestures) {
if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
return;
}
fakeGestureMoved = true;
gesture.scaleMove = getDistanceBetweenTouches(e);
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0) {
if (e.type === 'gesturechange') onGestureStart(e);
return;
}
if (support.gestures) {
zoom.scale = e.scale * currentScale;
} else {
zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale;
}
if (zoom.scale > gesture.maxRatio) {
zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5;
}
if (zoom.scale < params.minRatio) {
zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5;
}
gesture.$imageEl.transform(`translate3d(0,0,0) scale(${zoom.scale})`);
}
function onGestureEnd(e) {
const device = swiper.device;
const support = swiper.support;
const params = swiper.params.zoom;
const zoom = swiper.zoom;
if (!support.gestures) {
if (!fakeGestureTouched || !fakeGestureMoved) {
return;
}
if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) {
return;
}
fakeGestureTouched = false;
fakeGestureMoved = false;
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
gesture.$imageEl.transition(swiper.params.speed).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
currentScale = zoom.scale;
isScaling = false;
if (zoom.scale === 1) gesture.$slideEl = undefined;
}
function onTouchStart(e) {
const device = swiper.device;
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
if (image.isTouched) return;
if (device.android && e.cancelable) e.preventDefault();
image.isTouched = true;
image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
}
function onTouchMove(e) {
const zoom = swiper.zoom;
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
swiper.allowClick = false;
if (!image.isTouched || !gesture.$slideEl) return;
if (!image.isMoved) {
image.width = gesture.$imageEl[0].offsetWidth;
image.height = gesture.$imageEl[0].offsetHeight;
image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0;
image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0;
gesture.slideWidth = gesture.$slideEl[0].offsetWidth;
gesture.slideHeight = gesture.$slideEl[0].offsetHeight;
gesture.$imageWrapEl.transition(0);
} // Define if we need image drag
const scaledWidth = image.width * zoom.scale;
const scaledHeight = image.height * zoom.scale;
if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return;
image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
image.maxX = -image.minX;
image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
image.maxY = -image.minY;
image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
if (!image.isMoved && !isScaling) {
if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
image.isTouched = false;
return;
}
if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
image.isTouched = false;
return;
}
}
if (e.cancelable) {
e.preventDefault();
}
e.stopPropagation();
image.isMoved = true;
image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX;
image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY;
if (image.currentX < image.minX) {
image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8;
}
if (image.currentX > image.maxX) {
image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8;
}
if (image.currentY < image.minY) {
image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8;
}
if (image.currentY > image.maxY) {
image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8;
} // Velocity
if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
if (!velocity.prevTime) velocity.prevTime = Date.now();
velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
velocity.prevPositionX = image.touchesCurrent.x;
velocity.prevPositionY = image.touchesCurrent.y;
velocity.prevTime = Date.now();
gesture.$imageWrapEl.transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`);
}
function onTouchEnd() {
const zoom = swiper.zoom;
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
if (!image.isTouched || !image.isMoved) {
image.isTouched = false;
image.isMoved = false;
return;
}
image.isTouched = false;
image.isMoved = false;
let momentumDurationX = 300;
let momentumDurationY = 300;
const momentumDistanceX = velocity.x * momentumDurationX;
const newPositionX = image.currentX + momentumDistanceX;
const momentumDistanceY = velocity.y * momentumDurationY;
const newPositionY = image.currentY + momentumDistanceY; // Fix duration
if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
const momentumDuration = Math.max(momentumDurationX, momentumDurationY);
image.currentX = newPositionX;
image.currentY = newPositionY; // Define if we need image drag
const scaledWidth = image.width * zoom.scale;
const scaledHeight = image.height * zoom.scale;
image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
image.maxX = -image.minX;
image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
image.maxY = -image.minY;
image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
gesture.$imageWrapEl.transition(momentumDuration).transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`);
}
function onTransitionEnd() {
const zoom = swiper.zoom;
if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) {
if (gesture.$imageEl) {
gesture.$imageEl.transform('translate3d(0,0,0) scale(1)');
}
if (gesture.$imageWrapEl) {
gesture.$imageWrapEl.transform('translate3d(0,0,0)');
}
zoom.scale = 1;
currentScale = 1;
gesture.$slideEl = undefined;
gesture.$imageEl = undefined;
gesture.$imageWrapEl = undefined;
}
}
function zoomIn(e) {
const zoom = swiper.zoom;
const params = swiper.params.zoom;
if (!gesture.$slideEl) {
if (e && e.target) {
gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`);
}
if (!gesture.$slideEl) {
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`);
} else {
gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
}
}
gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return;
if (swiper.params.cssMode) {
swiper.wrapperEl.style.overflow = 'hidden';
swiper.wrapperEl.style.touchAction = 'none';
}
gesture.$slideEl.addClass(`${params.zoomedSlideClass}`);
let touchX;
let touchY;
let offsetX;
let offsetY;
let diffX;
let diffY;
let translateX;
let translateY;
let imageWidth;
let imageHeight;
let scaledWidth;
let scaledHeight;
let translateMinX;
let translateMinY;
let translateMaxX;
let translateMaxY;
let slideWidth;
let slideHeight;
if (typeof image.touchesStart.x === 'undefined' && e) {
touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
} else {
touchX = image.touchesStart.x;
touchY = image.touchesStart.y;
}
zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
if (e) {
slideWidth = gesture.$slideEl[0].offsetWidth;
slideHeight = gesture.$slideEl[0].offsetHeight;
offsetX = gesture.$slideEl.offset().left + window.scrollX;
offsetY = gesture.$slideEl.offset().top + window.scrollY;
diffX = offsetX + slideWidth / 2 - touchX;
diffY = offsetY + slideHeight / 2 - touchY;
imageWidth = gesture.$imageEl[0].offsetWidth;
imageHeight = gesture.$imageEl[0].offsetHeight;
scaledWidth = imageWidth * zoom.scale;
scaledHeight = imageHeight * zoom.scale;
translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
translateMaxX = -translateMinX;
translateMaxY = -translateMinY;
translateX = diffX * zoom.scale;
translateY = diffY * zoom.scale;
if (translateX < translateMinX) {
translateX = translateMinX;
}
if (translateX > translateMaxX) {
translateX = translateMaxX;
}
if (translateY < translateMinY) {
translateY = translateMinY;
}
if (translateY > translateMaxY) {
translateY = translateMaxY;
}
} else {
translateX = 0;
translateY = 0;
}
gesture.$imageWrapEl.transition(300).transform(`translate3d(${translateX}px, ${translateY}px,0)`);
gesture.$imageEl.transition(300).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
}
function zoomOut() {
const zoom = swiper.zoom;
const params = swiper.params.zoom;
if (!gesture.$slideEl) {
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`);
} else {
gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
}
gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return;
if (swiper.params.cssMode) {
swiper.wrapperEl.style.overflow = '';
swiper.wrapperEl.style.touchAction = '';
}
zoom.scale = 1;
currentScale = 1;
gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)');
gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)');
gesture.$slideEl.removeClass(`${params.zoomedSlideClass}`);
gesture.$slideEl = undefined;
} // Toggle Zoom
function zoomToggle(e) {
const zoom = swiper.zoom;
if (zoom.scale && zoom.scale !== 1) {
// Zoom Out
zoomOut();
} else {
// Zoom In
zoomIn(e);
}
}
function getListeners() {
const support = swiper.support;
const passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
passive: true,
capture: false
} : false;
const activeListenerWithCapture = support.passiveListener ? {
passive: false,
capture: true
} : true;
return {
passiveListener,
activeListenerWithCapture
};
}
function getSlideSelector() {
return `.${swiper.params.slideClass}`;
}
function toggleGestures(method) {
const {
passiveListener
} = getListeners();
const slideSelector = getSlideSelector();
swiper.$wrapperEl[method]('gesturestart', slideSelector, onGestureStart, passiveListener);
swiper.$wrapperEl[method]('gesturechange', slideSelector, onGestureChange, passiveListener);
swiper.$wrapperEl[method]('gestureend', slideSelector, onGestureEnd, passiveListener);
}
function enableGestures() {
if (gesturesEnabled) return;
gesturesEnabled = true;
toggleGestures('on');
}
function disableGestures() {
if (!gesturesEnabled) return;
gesturesEnabled = false;
toggleGestures('off');
} // Attach/Detach Events
function enable() {
const zoom = swiper.zoom;
if (zoom.enabled) return;
zoom.enabled = true;
const support = swiper.support;
const {
passiveListener,
activeListenerWithCapture
} = getListeners();
const slideSelector = getSlideSelector(); // Scale image
if (support.gestures) {
swiper.$wrapperEl.on(swiper.touchEvents.start, enableGestures, passiveListener);
swiper.$wrapperEl.on(swiper.touchEvents.end, disableGestures, passiveListener);
} else if (swiper.touchEvents.start === 'touchstart') {
swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener);
swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture);
swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener);
if (swiper.touchEvents.cancel) {
swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener);
}
} // Move image
swiper.$wrapperEl.on(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture);
}
function disable() {
const zoom = swiper.zoom;
if (!zoom.enabled) return;
const support = swiper.support;
zoom.enabled = false;
const {
passiveListener,
activeListenerWithCapture
} = getListeners();
const slideSelector = getSlideSelector(); // Scale image
if (support.gestures) {
swiper.$wrapperEl.off(swiper.touchEvents.start, enableGestures, passiveListener);
swiper.$wrapperEl.off(swiper.touchEvents.end, disableGestures, passiveListener);
} else if (swiper.touchEvents.start === 'touchstart') {
swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener);
swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture);
swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener);
if (swiper.touchEvents.cancel) {
swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener);
}
} // Move image
swiper.$wrapperEl.off(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture);
}
on('init', () => {
if (swiper.params.zoom.enabled) {
enable();
}
});
on('destroy', () => {
disable();
});
on('touchStart', (_s, e) => {
if (!swiper.zoom.enabled) return;
onTouchStart(e);
});
on('touchEnd', (_s, e) => {
if (!swiper.zoom.enabled) return;
onTouchEnd();
});
on('doubleTap', (_s, e) => {
if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
zoomToggle(e);
}
});
on('transitionEnd', () => {
if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
onTransitionEnd();
}
});
on('slideChange', () => {
if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
onTransitionEnd();
}
});
Object.assign(swiper.zoom, {
enable,
disable,
in: zoomIn,
out: zoomOut,
toggle: zoomToggle
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Zoom | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
get() {
return scale;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | get | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
set(value) {
if (scale !== value) {
const imageEl = gesture.$imageEl ? gesture.$imageEl[0] : undefined;
const slideEl = gesture.$slideEl ? gesture.$slideEl[0] : undefined;
emit('zoomChange', value, imageEl, slideEl);
}
scale = value;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | set | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function getDistanceBetweenTouches(e) {
if (e.targetTouches.length < 2) return 1;
const x1 = e.targetTouches[0].pageX;
const y1 = e.targetTouches[0].pageY;
const x2 = e.targetTouches[1].pageX;
const y2 = e.targetTouches[1].pageY;
const distance = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
return distance;
} // Events | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getDistanceBetweenTouches | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onGestureStart(e) {
const support = swiper.support;
const params = swiper.params.zoom;
fakeGestureTouched = false;
fakeGestureMoved = false;
if (!support.gestures) {
if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
return;
}
fakeGestureTouched = true;
gesture.scaleStart = getDistanceBetweenTouches(e);
}
if (!gesture.$slideEl || !gesture.$slideEl.length) {
gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`);
if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
if (gesture.$imageWrapEl.length === 0) {
gesture.$imageEl = undefined;
return;
}
}
if (gesture.$imageEl) {
gesture.$imageEl.transition(0);
}
isScaling = true;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onGestureStart | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onGestureChange(e) {
const support = swiper.support;
const params = swiper.params.zoom;
const zoom = swiper.zoom;
if (!support.gestures) {
if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
return;
}
fakeGestureMoved = true;
gesture.scaleMove = getDistanceBetweenTouches(e);
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0) {
if (e.type === 'gesturechange') onGestureStart(e);
return;
}
if (support.gestures) {
zoom.scale = e.scale * currentScale;
} else {
zoom.scale = gesture.scaleMove / gesture.scaleStart * currentScale;
}
if (zoom.scale > gesture.maxRatio) {
zoom.scale = gesture.maxRatio - 1 + (zoom.scale - gesture.maxRatio + 1) ** 0.5;
}
if (zoom.scale < params.minRatio) {
zoom.scale = params.minRatio + 1 - (params.minRatio - zoom.scale + 1) ** 0.5;
}
gesture.$imageEl.transform(`translate3d(0,0,0) scale(${zoom.scale})`);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onGestureChange | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onGestureEnd(e) {
const device = swiper.device;
const support = swiper.support;
const params = swiper.params.zoom;
const zoom = swiper.zoom;
if (!support.gestures) {
if (!fakeGestureTouched || !fakeGestureMoved) {
return;
}
if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) {
return;
}
fakeGestureTouched = false;
fakeGestureMoved = false;
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
gesture.$imageEl.transition(swiper.params.speed).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
currentScale = zoom.scale;
isScaling = false;
if (zoom.scale === 1) gesture.$slideEl = undefined;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onGestureEnd | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onTouchStart(e) {
const device = swiper.device;
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
if (image.isTouched) return;
if (device.android && e.cancelable) e.preventDefault();
image.isTouched = true;
image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onTouchStart | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onTouchMove(e) {
const zoom = swiper.zoom;
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
swiper.allowClick = false;
if (!image.isTouched || !gesture.$slideEl) return;
if (!image.isMoved) {
image.width = gesture.$imageEl[0].offsetWidth;
image.height = gesture.$imageEl[0].offsetHeight;
image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0;
image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0;
gesture.slideWidth = gesture.$slideEl[0].offsetWidth;
gesture.slideHeight = gesture.$slideEl[0].offsetHeight;
gesture.$imageWrapEl.transition(0);
} // Define if we need image drag
const scaledWidth = image.width * zoom.scale;
const scaledHeight = image.height * zoom.scale;
if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return;
image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
image.maxX = -image.minX;
image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
image.maxY = -image.minY;
image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
if (!image.isMoved && !isScaling) {
if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
image.isTouched = false;
return;
}
if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
image.isTouched = false;
return;
}
}
if (e.cancelable) {
e.preventDefault();
}
e.stopPropagation();
image.isMoved = true;
image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX;
image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY;
if (image.currentX < image.minX) {
image.currentX = image.minX + 1 - (image.minX - image.currentX + 1) ** 0.8;
}
if (image.currentX > image.maxX) {
image.currentX = image.maxX - 1 + (image.currentX - image.maxX + 1) ** 0.8;
}
if (image.currentY < image.minY) {
image.currentY = image.minY + 1 - (image.minY - image.currentY + 1) ** 0.8;
}
if (image.currentY > image.maxY) {
image.currentY = image.maxY - 1 + (image.currentY - image.maxY + 1) ** 0.8;
} // Velocity
if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
if (!velocity.prevTime) velocity.prevTime = Date.now();
velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
velocity.prevPositionX = image.touchesCurrent.x;
velocity.prevPositionY = image.touchesCurrent.y;
velocity.prevTime = Date.now();
gesture.$imageWrapEl.transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onTouchMove | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onTouchEnd() {
const zoom = swiper.zoom;
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
if (!image.isTouched || !image.isMoved) {
image.isTouched = false;
image.isMoved = false;
return;
}
image.isTouched = false;
image.isMoved = false;
let momentumDurationX = 300;
let momentumDurationY = 300;
const momentumDistanceX = velocity.x * momentumDurationX;
const newPositionX = image.currentX + momentumDistanceX;
const momentumDistanceY = velocity.y * momentumDurationY;
const newPositionY = image.currentY + momentumDistanceY; // Fix duration
if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
const momentumDuration = Math.max(momentumDurationX, momentumDurationY);
image.currentX = newPositionX;
image.currentY = newPositionY; // Define if we need image drag
const scaledWidth = image.width * zoom.scale;
const scaledHeight = image.height * zoom.scale;
image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
image.maxX = -image.minX;
image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
image.maxY = -image.minY;
image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
gesture.$imageWrapEl.transition(momentumDuration).transform(`translate3d(${image.currentX}px, ${image.currentY}px,0)`);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onTouchEnd | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onTransitionEnd() {
const zoom = swiper.zoom;
if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) {
if (gesture.$imageEl) {
gesture.$imageEl.transform('translate3d(0,0,0) scale(1)');
}
if (gesture.$imageWrapEl) {
gesture.$imageWrapEl.transform('translate3d(0,0,0)');
}
zoom.scale = 1;
currentScale = 1;
gesture.$slideEl = undefined;
gesture.$imageEl = undefined;
gesture.$imageWrapEl = undefined;
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onTransitionEnd | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function zoomIn(e) {
const zoom = swiper.zoom;
const params = swiper.params.zoom;
if (!gesture.$slideEl) {
if (e && e.target) {
gesture.$slideEl = $(e.target).closest(`.${swiper.params.slideClass}`);
}
if (!gesture.$slideEl) {
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`);
} else {
gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
}
}
gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return;
if (swiper.params.cssMode) {
swiper.wrapperEl.style.overflow = 'hidden';
swiper.wrapperEl.style.touchAction = 'none';
}
gesture.$slideEl.addClass(`${params.zoomedSlideClass}`);
let touchX;
let touchY;
let offsetX;
let offsetY;
let diffX;
let diffY;
let translateX;
let translateY;
let imageWidth;
let imageHeight;
let scaledWidth;
let scaledHeight;
let translateMinX;
let translateMinY;
let translateMaxX;
let translateMaxY;
let slideWidth;
let slideHeight;
if (typeof image.touchesStart.x === 'undefined' && e) {
touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
} else {
touchX = image.touchesStart.x;
touchY = image.touchesStart.y;
}
zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
if (e) {
slideWidth = gesture.$slideEl[0].offsetWidth;
slideHeight = gesture.$slideEl[0].offsetHeight;
offsetX = gesture.$slideEl.offset().left + window.scrollX;
offsetY = gesture.$slideEl.offset().top + window.scrollY;
diffX = offsetX + slideWidth / 2 - touchX;
diffY = offsetY + slideHeight / 2 - touchY;
imageWidth = gesture.$imageEl[0].offsetWidth;
imageHeight = gesture.$imageEl[0].offsetHeight;
scaledWidth = imageWidth * zoom.scale;
scaledHeight = imageHeight * zoom.scale;
translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
translateMaxX = -translateMinX;
translateMaxY = -translateMinY;
translateX = diffX * zoom.scale;
translateY = diffY * zoom.scale;
if (translateX < translateMinX) {
translateX = translateMinX;
}
if (translateX > translateMaxX) {
translateX = translateMaxX;
}
if (translateY < translateMinY) {
translateY = translateMinY;
}
if (translateY > translateMaxY) {
translateY = translateMaxY;
}
} else {
translateX = 0;
translateY = 0;
}
gesture.$imageWrapEl.transition(300).transform(`translate3d(${translateX}px, ${translateY}px,0)`);
gesture.$imageEl.transition(300).transform(`translate3d(0,0,0) scale(${zoom.scale})`);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | zoomIn | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function zoomOut() {
const zoom = swiper.zoom;
const params = swiper.params.zoom;
if (!gesture.$slideEl) {
if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
gesture.$slideEl = swiper.$wrapperEl.children(`.${swiper.params.slideActiveClass}`);
} else {
gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
}
gesture.$imageEl = gesture.$slideEl.find(`.${params.containerClass}`).eq(0).find('picture, img, svg, canvas, .swiper-zoom-target').eq(0);
gesture.$imageWrapEl = gesture.$imageEl.parent(`.${params.containerClass}`);
}
if (!gesture.$imageEl || gesture.$imageEl.length === 0 || !gesture.$imageWrapEl || gesture.$imageWrapEl.length === 0) return;
if (swiper.params.cssMode) {
swiper.wrapperEl.style.overflow = '';
swiper.wrapperEl.style.touchAction = '';
}
zoom.scale = 1;
currentScale = 1;
gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)');
gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)');
gesture.$slideEl.removeClass(`${params.zoomedSlideClass}`);
gesture.$slideEl = undefined;
} // Toggle Zoom | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | zoomOut | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function zoomToggle(e) {
const zoom = swiper.zoom;
if (zoom.scale && zoom.scale !== 1) {
// Zoom Out
zoomOut();
} else {
// Zoom In
zoomIn(e);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | zoomToggle | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function getListeners() {
const support = swiper.support;
const passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
passive: true,
capture: false
} : false;
const activeListenerWithCapture = support.passiveListener ? {
passive: false,
capture: true
} : true;
return {
passiveListener,
activeListenerWithCapture
};
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getListeners | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function getSlideSelector() {
return `.${swiper.params.slideClass}`;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getSlideSelector | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function toggleGestures(method) {
const {
passiveListener
} = getListeners();
const slideSelector = getSlideSelector();
swiper.$wrapperEl[method]('gesturestart', slideSelector, onGestureStart, passiveListener);
swiper.$wrapperEl[method]('gesturechange', slideSelector, onGestureChange, passiveListener);
swiper.$wrapperEl[method]('gestureend', slideSelector, onGestureEnd, passiveListener);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | toggleGestures | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function enableGestures() {
if (gesturesEnabled) return;
gesturesEnabled = true;
toggleGestures('on');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | enableGestures | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function disableGestures() {
if (!gesturesEnabled) return;
gesturesEnabled = false;
toggleGestures('off');
} // Attach/Detach Events | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | disableGestures | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function enable() {
const zoom = swiper.zoom;
if (zoom.enabled) return;
zoom.enabled = true;
const support = swiper.support;
const {
passiveListener,
activeListenerWithCapture
} = getListeners();
const slideSelector = getSlideSelector(); // Scale image
if (support.gestures) {
swiper.$wrapperEl.on(swiper.touchEvents.start, enableGestures, passiveListener);
swiper.$wrapperEl.on(swiper.touchEvents.end, disableGestures, passiveListener);
} else if (swiper.touchEvents.start === 'touchstart') {
swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener);
swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture);
swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener);
if (swiper.touchEvents.cancel) {
swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener);
}
} // Move image
swiper.$wrapperEl.on(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | enable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function disable() {
const zoom = swiper.zoom;
if (!zoom.enabled) return;
const support = swiper.support;
zoom.enabled = false;
const {
passiveListener,
activeListenerWithCapture
} = getListeners();
const slideSelector = getSlideSelector(); // Scale image
if (support.gestures) {
swiper.$wrapperEl.off(swiper.touchEvents.start, enableGestures, passiveListener);
swiper.$wrapperEl.off(swiper.touchEvents.end, disableGestures, passiveListener);
} else if (swiper.touchEvents.start === 'touchstart') {
swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, onGestureStart, passiveListener);
swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, onGestureChange, activeListenerWithCapture);
swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, onGestureEnd, passiveListener);
if (swiper.touchEvents.cancel) {
swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, onGestureEnd, passiveListener);
}
} // Move image
swiper.$wrapperEl.off(swiper.touchEvents.move, `.${swiper.params.zoom.containerClass}`, onTouchMove, activeListenerWithCapture);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | disable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function Lazy(_ref) {
let {
swiper,
extendParams,
on,
emit
} = _ref;
extendParams({
lazy: {
checkInView: false,
enabled: false,
loadPrevNext: false,
loadPrevNextAmount: 1,
loadOnTransitionStart: false,
scrollingElement: '',
elementClass: 'swiper-lazy',
loadingClass: 'swiper-lazy-loading',
loadedClass: 'swiper-lazy-loaded',
preloaderClass: 'swiper-lazy-preloader'
}
});
swiper.lazy = {};
let scrollHandlerAttached = false;
let initialImageLoaded = false;
function loadInSlide(index, loadInDuplicate) {
if (loadInDuplicate === void 0) {
loadInDuplicate = true;
}
const params = swiper.params.lazy;
if (typeof index === 'undefined') return;
if (swiper.slides.length === 0) return;
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
const $slideEl = isVirtual ? swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-swiper-slide-index="${index}"]`) : swiper.slides.eq(index);
const $images = $slideEl.find(`.${params.elementClass}:not(.${params.loadedClass}):not(.${params.loadingClass})`);
if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) {
$images.push($slideEl[0]);
}
if ($images.length === 0) return;
$images.each(imageEl => {
const $imageEl = $(imageEl);
$imageEl.addClass(params.loadingClass);
const background = $imageEl.attr('data-background');
const src = $imageEl.attr('data-src');
const srcset = $imageEl.attr('data-srcset');
const sizes = $imageEl.attr('data-sizes');
const $pictureEl = $imageEl.parent('picture');
swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, () => {
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return;
if (background) {
$imageEl.css('background-image', `url("${background}")`);
$imageEl.removeAttr('data-background');
} else {
if (srcset) {
$imageEl.attr('srcset', srcset);
$imageEl.removeAttr('data-srcset');
}
if (sizes) {
$imageEl.attr('sizes', sizes);
$imageEl.removeAttr('data-sizes');
}
if ($pictureEl.length) {
$pictureEl.children('source').each(sourceEl => {
const $source = $(sourceEl);
if ($source.attr('data-srcset')) {
$source.attr('srcset', $source.attr('data-srcset'));
$source.removeAttr('data-srcset');
}
});
}
if (src) {
$imageEl.attr('src', src);
$imageEl.removeAttr('data-src');
}
}
$imageEl.addClass(params.loadedClass).removeClass(params.loadingClass);
$slideEl.find(`.${params.preloaderClass}`).remove();
if (swiper.params.loop && loadInDuplicate) {
const slideOriginalIndex = $slideEl.attr('data-swiper-slide-index');
if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) {
const originalSlide = swiper.$wrapperEl.children(`[data-swiper-slide-index="${slideOriginalIndex}"]:not(.${swiper.params.slideDuplicateClass})`);
loadInSlide(originalSlide.index(), false);
} else {
const duplicatedSlide = swiper.$wrapperEl.children(`.${swiper.params.slideDuplicateClass}[data-swiper-slide-index="${slideOriginalIndex}"]`);
loadInSlide(duplicatedSlide.index(), false);
}
}
emit('lazyImageReady', $slideEl[0], $imageEl[0]);
if (swiper.params.autoHeight) {
swiper.updateAutoHeight();
}
});
emit('lazyImageLoad', $slideEl[0], $imageEl[0]);
});
}
function load() {
const {
$wrapperEl,
params: swiperParams,
slides,
activeIndex
} = swiper;
const isVirtual = swiper.virtual && swiperParams.virtual.enabled;
const params = swiperParams.lazy;
let slidesPerView = swiperParams.slidesPerView;
if (slidesPerView === 'auto') {
slidesPerView = 0;
}
function slideExist(index) {
if (isVirtual) {
if ($wrapperEl.children(`.${swiperParams.slideClass}[data-swiper-slide-index="${index}"]`).length) {
return true;
}
} else if (slides[index]) return true;
return false;
}
function slideIndex(slideEl) {
if (isVirtual) {
return $(slideEl).attr('data-swiper-slide-index');
}
return $(slideEl).index();
}
if (!initialImageLoaded) initialImageLoaded = true;
if (swiper.params.watchSlidesProgress) {
$wrapperEl.children(`.${swiperParams.slideVisibleClass}`).each(slideEl => {
const index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index();
loadInSlide(index);
});
} else if (slidesPerView > 1) {
for (let i = activeIndex; i < activeIndex + slidesPerView; i += 1) {
if (slideExist(i)) loadInSlide(i);
}
} else {
loadInSlide(activeIndex);
}
if (params.loadPrevNext) {
if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) {
const amount = params.loadPrevNextAmount;
const spv = Math.ceil(slidesPerView);
const maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length);
const minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides
for (let i = activeIndex + spv; i < maxIndex; i += 1) {
if (slideExist(i)) loadInSlide(i);
} // Prev Slides
for (let i = minIndex; i < activeIndex; i += 1) {
if (slideExist(i)) loadInSlide(i);
}
} else {
const nextSlide = $wrapperEl.children(`.${swiperParams.slideNextClass}`);
if (nextSlide.length > 0) loadInSlide(slideIndex(nextSlide));
const prevSlide = $wrapperEl.children(`.${swiperParams.slidePrevClass}`);
if (prevSlide.length > 0) loadInSlide(slideIndex(prevSlide));
}
}
}
function checkInViewOnLoad() {
const window = getWindow();
if (!swiper || swiper.destroyed) return;
const $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window);
const isWindow = $scrollElement[0] === window;
const scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth;
const scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight;
const swiperOffset = swiper.$el.offset();
const {
rtlTranslate: rtl
} = swiper;
let inView = false;
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]];
for (let i = 0; i < swiperCoord.length; i += 1) {
const point = swiperCoord[i];
if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) {
if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
inView = true;
}
}
const passiveListener = swiper.touchEvents.start === 'touchstart' && swiper.support.passiveListener && swiper.params.passiveListeners ? {
passive: true,
capture: false
} : false;
if (inView) {
load();
$scrollElement.off('scroll', checkInViewOnLoad, passiveListener);
} else if (!scrollHandlerAttached) {
scrollHandlerAttached = true;
$scrollElement.on('scroll', checkInViewOnLoad, passiveListener);
}
}
on('beforeInit', () => {
if (swiper.params.lazy.enabled && swiper.params.preloadImages) {
swiper.params.preloadImages = false;
}
});
on('init', () => {
if (swiper.params.lazy.enabled) {
if (swiper.params.lazy.checkInView) {
checkInViewOnLoad();
} else {
load();
}
}
});
on('scroll', () => {
if (swiper.params.freeMode && swiper.params.freeMode.enabled && !swiper.params.freeMode.sticky) {
load();
}
});
on('scrollbarDragMove resize _freeModeNoMomentumRelease', () => {
if (swiper.params.lazy.enabled) {
if (swiper.params.lazy.checkInView) {
checkInViewOnLoad();
} else {
load();
}
}
});
on('transitionStart', () => {
if (swiper.params.lazy.enabled) {
if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !initialImageLoaded) {
if (swiper.params.lazy.checkInView) {
checkInViewOnLoad();
} else {
load();
}
}
}
});
on('transitionEnd', () => {
if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) {
if (swiper.params.lazy.checkInView) {
checkInViewOnLoad();
} else {
load();
}
}
});
on('slideChange', () => {
const {
lazy,
cssMode,
watchSlidesProgress,
touchReleaseOnEdges,
resistanceRatio
} = swiper.params;
if (lazy.enabled && (cssMode || watchSlidesProgress && (touchReleaseOnEdges || resistanceRatio === 0))) {
load();
}
});
on('destroy', () => {
if (!swiper.$el) return;
swiper.$el.find(`.${swiper.params.lazy.loadingClass}`).removeClass(swiper.params.lazy.loadingClass);
});
Object.assign(swiper.lazy, {
load,
loadInSlide
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Lazy | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function loadInSlide(index, loadInDuplicate) {
if (loadInDuplicate === void 0) {
loadInDuplicate = true;
}
const params = swiper.params.lazy;
if (typeof index === 'undefined') return;
if (swiper.slides.length === 0) return;
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
const $slideEl = isVirtual ? swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-swiper-slide-index="${index}"]`) : swiper.slides.eq(index);
const $images = $slideEl.find(`.${params.elementClass}:not(.${params.loadedClass}):not(.${params.loadingClass})`);
if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) {
$images.push($slideEl[0]);
}
if ($images.length === 0) return;
$images.each(imageEl => {
const $imageEl = $(imageEl);
$imageEl.addClass(params.loadingClass);
const background = $imageEl.attr('data-background');
const src = $imageEl.attr('data-src');
const srcset = $imageEl.attr('data-srcset');
const sizes = $imageEl.attr('data-sizes');
const $pictureEl = $imageEl.parent('picture');
swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, () => {
if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return;
if (background) {
$imageEl.css('background-image', `url("${background}")`);
$imageEl.removeAttr('data-background');
} else {
if (srcset) {
$imageEl.attr('srcset', srcset);
$imageEl.removeAttr('data-srcset');
}
if (sizes) {
$imageEl.attr('sizes', sizes);
$imageEl.removeAttr('data-sizes');
}
if ($pictureEl.length) {
$pictureEl.children('source').each(sourceEl => {
const $source = $(sourceEl);
if ($source.attr('data-srcset')) {
$source.attr('srcset', $source.attr('data-srcset'));
$source.removeAttr('data-srcset');
}
});
}
if (src) {
$imageEl.attr('src', src);
$imageEl.removeAttr('data-src');
}
}
$imageEl.addClass(params.loadedClass).removeClass(params.loadingClass);
$slideEl.find(`.${params.preloaderClass}`).remove();
if (swiper.params.loop && loadInDuplicate) {
const slideOriginalIndex = $slideEl.attr('data-swiper-slide-index');
if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) {
const originalSlide = swiper.$wrapperEl.children(`[data-swiper-slide-index="${slideOriginalIndex}"]:not(.${swiper.params.slideDuplicateClass})`);
loadInSlide(originalSlide.index(), false);
} else {
const duplicatedSlide = swiper.$wrapperEl.children(`.${swiper.params.slideDuplicateClass}[data-swiper-slide-index="${slideOriginalIndex}"]`);
loadInSlide(duplicatedSlide.index(), false);
}
}
emit('lazyImageReady', $slideEl[0], $imageEl[0]);
if (swiper.params.autoHeight) {
swiper.updateAutoHeight();
}
});
emit('lazyImageLoad', $slideEl[0], $imageEl[0]);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | loadInSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function load() {
const {
$wrapperEl,
params: swiperParams,
slides,
activeIndex
} = swiper;
const isVirtual = swiper.virtual && swiperParams.virtual.enabled;
const params = swiperParams.lazy;
let slidesPerView = swiperParams.slidesPerView;
if (slidesPerView === 'auto') {
slidesPerView = 0;
}
function slideExist(index) {
if (isVirtual) {
if ($wrapperEl.children(`.${swiperParams.slideClass}[data-swiper-slide-index="${index}"]`).length) {
return true;
}
} else if (slides[index]) return true;
return false;
}
function slideIndex(slideEl) {
if (isVirtual) {
return $(slideEl).attr('data-swiper-slide-index');
}
return $(slideEl).index();
}
if (!initialImageLoaded) initialImageLoaded = true;
if (swiper.params.watchSlidesProgress) {
$wrapperEl.children(`.${swiperParams.slideVisibleClass}`).each(slideEl => {
const index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index();
loadInSlide(index);
});
} else if (slidesPerView > 1) {
for (let i = activeIndex; i < activeIndex + slidesPerView; i += 1) {
if (slideExist(i)) loadInSlide(i);
}
} else {
loadInSlide(activeIndex);
}
if (params.loadPrevNext) {
if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) {
const amount = params.loadPrevNextAmount;
const spv = Math.ceil(slidesPerView);
const maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length);
const minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); // Next Slides
for (let i = activeIndex + spv; i < maxIndex; i += 1) {
if (slideExist(i)) loadInSlide(i);
} // Prev Slides
for (let i = minIndex; i < activeIndex; i += 1) {
if (slideExist(i)) loadInSlide(i);
}
} else {
const nextSlide = $wrapperEl.children(`.${swiperParams.slideNextClass}`);
if (nextSlide.length > 0) loadInSlide(slideIndex(nextSlide));
const prevSlide = $wrapperEl.children(`.${swiperParams.slidePrevClass}`);
if (prevSlide.length > 0) loadInSlide(slideIndex(prevSlide));
}
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | load | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function slideExist(index) {
if (isVirtual) {
if ($wrapperEl.children(`.${swiperParams.slideClass}[data-swiper-slide-index="${index}"]`).length) {
return true;
}
} else if (slides[index]) return true;
return false;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | slideExist | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function slideIndex(slideEl) {
if (isVirtual) {
return $(slideEl).attr('data-swiper-slide-index');
}
return $(slideEl).index();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | slideIndex | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function checkInViewOnLoad() {
const window = getWindow();
if (!swiper || swiper.destroyed) return;
const $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window);
const isWindow = $scrollElement[0] === window;
const scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth;
const scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight;
const swiperOffset = swiper.$el.offset();
const {
rtlTranslate: rtl
} = swiper;
let inView = false;
if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
const swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]];
for (let i = 0; i < swiperCoord.length; i += 1) {
const point = swiperCoord[i];
if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) {
if (point[0] === 0 && point[1] === 0) continue; // eslint-disable-line
inView = true;
}
}
const passiveListener = swiper.touchEvents.start === 'touchstart' && swiper.support.passiveListener && swiper.params.passiveListeners ? {
passive: true,
capture: false
} : false;
if (inView) {
load();
$scrollElement.off('scroll', checkInViewOnLoad, passiveListener);
} else if (!scrollHandlerAttached) {
scrollHandlerAttached = true;
$scrollElement.on('scroll', checkInViewOnLoad, passiveListener);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | checkInViewOnLoad | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function getInterpolateFunction(c) {
if (!swiper.controller.spline) {
swiper.controller.spline = swiper.params.loop ? new LinearSpline(swiper.slidesGrid, c.slidesGrid) : new LinearSpline(swiper.snapGrid, c.snapGrid);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getInterpolateFunction | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function setTranslate(_t, byController) {
const controlled = swiper.controller.control;
let multiplier;
let controlledTranslate;
const Swiper = swiper.constructor;
function setControlledTranslate(c) {
// this will create an Interpolate function based on the snapGrids
// x is the Grid of the scrolled scroller and y will be the controlled scroller
// it makes sense to create this only once and recall it for the interpolation
// the function does a lot of value caching for performance
const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
if (swiper.params.controller.by === 'slide') {
getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
// but it did not work out
controlledTranslate = -swiper.controller.spline.interpolate(-translate);
}
if (!controlledTranslate || swiper.params.controller.by === 'container') {
multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
}
if (swiper.params.controller.inverse) {
controlledTranslate = c.maxTranslate() - controlledTranslate;
}
c.updateProgress(controlledTranslate);
c.setTranslate(controlledTranslate, swiper);
c.updateActiveIndex();
c.updateSlidesClasses();
}
if (Array.isArray(controlled)) {
for (let i = 0; i < controlled.length; i += 1) {
if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
setControlledTranslate(controlled[i]);
}
}
} else if (controlled instanceof Swiper && byController !== controlled) {
setControlledTranslate(controlled);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTranslate | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function setControlledTranslate(c) {
// this will create an Interpolate function based on the snapGrids
// x is the Grid of the scrolled scroller and y will be the controlled scroller
// it makes sense to create this only once and recall it for the interpolation
// the function does a lot of value caching for performance
const translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
if (swiper.params.controller.by === 'slide') {
getInterpolateFunction(c); // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
// but it did not work out
controlledTranslate = -swiper.controller.spline.interpolate(-translate);
}
if (!controlledTranslate || swiper.params.controller.by === 'container') {
multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
}
if (swiper.params.controller.inverse) {
controlledTranslate = c.maxTranslate() - controlledTranslate;
}
c.updateProgress(controlledTranslate);
c.setTranslate(controlledTranslate, swiper);
c.updateActiveIndex();
c.updateSlidesClasses();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setControlledTranslate | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function setTransition(duration, byController) {
const Swiper = swiper.constructor;
const controlled = swiper.controller.control;
let i;
function setControlledTransition(c) {
c.setTransition(duration, swiper);
if (duration !== 0) {
c.transitionStart();
if (c.params.autoHeight) {
nextTick(() => {
c.updateAutoHeight();
});
}
c.$wrapperEl.transitionEnd(() => {
if (!controlled) return;
if (c.params.loop && swiper.params.controller.by === 'slide') {
c.loopFix();
}
c.transitionEnd();
});
}
}
if (Array.isArray(controlled)) {
for (i = 0; i < controlled.length; i += 1) {
if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
setControlledTransition(controlled[i]);
}
}
} else if (controlled instanceof Swiper && byController !== controlled) {
setControlledTransition(controlled);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setTransition | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function setControlledTransition(c) {
c.setTransition(duration, swiper);
if (duration !== 0) {
c.transitionStart();
if (c.params.autoHeight) {
nextTick(() => {
c.updateAutoHeight();
});
}
c.$wrapperEl.transitionEnd(() => {
if (!controlled) return;
if (c.params.loop && swiper.params.controller.by === 'slide') {
c.loopFix();
}
c.transitionEnd();
});
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setControlledTransition | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function removeSpline() {
if (!swiper.controller.control) return;
if (swiper.controller.spline) {
swiper.controller.spline = undefined;
delete swiper.controller.spline;
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | removeSpline | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function A11y(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
a11y: {
enabled: true,
notificationClass: 'swiper-notification',
prevSlideMessage: 'Previous slide',
nextSlideMessage: 'Next slide',
firstSlideMessage: 'This is the first slide',
lastSlideMessage: 'This is the last slide',
paginationBulletMessage: 'Go to slide {{index}}',
slideLabelMessage: '{{index}} / {{slidesLength}}',
containerMessage: null,
containerRoleDescriptionMessage: null,
itemRoleDescriptionMessage: null,
slideRole: 'group',
id: null
}
});
swiper.a11y = {
clicked: false
};
let liveRegion = null;
function notify(message) {
const notification = liveRegion;
if (notification.length === 0) return;
notification.html('');
notification.html(message);
}
function getRandomNumber(size) {
if (size === void 0) {
size = 16;
}
const randomChar = () => Math.round(16 * Math.random()).toString(16);
return 'x'.repeat(size).replace(/x/g, randomChar);
}
function makeElFocusable($el) {
$el.attr('tabIndex', '0');
}
function makeElNotFocusable($el) {
$el.attr('tabIndex', '-1');
}
function addElRole($el, role) {
$el.attr('role', role);
}
function addElRoleDescription($el, description) {
$el.attr('aria-roledescription', description);
}
function addElControls($el, controls) {
$el.attr('aria-controls', controls);
}
function addElLabel($el, label) {
$el.attr('aria-label', label);
}
function addElId($el, id) {
$el.attr('id', id);
}
function addElLive($el, live) {
$el.attr('aria-live', live);
}
function disableEl($el) {
$el.attr('aria-disabled', true);
}
function enableEl($el) {
$el.attr('aria-disabled', false);
}
function onEnterOrSpaceKey(e) {
if (e.keyCode !== 13 && e.keyCode !== 32) return;
const params = swiper.params.a11y;
const $targetEl = $(e.target);
if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) {
if (!(swiper.isEnd && !swiper.params.loop)) {
swiper.slideNext();
}
if (swiper.isEnd) {
notify(params.lastSlideMessage);
} else {
notify(params.nextSlideMessage);
}
}
if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) {
if (!(swiper.isBeginning && !swiper.params.loop)) {
swiper.slidePrev();
}
if (swiper.isBeginning) {
notify(params.firstSlideMessage);
} else {
notify(params.prevSlideMessage);
}
}
if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) {
$targetEl[0].click();
}
}
function updateNavigation() {
if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
const {
$nextEl,
$prevEl
} = swiper.navigation;
if ($prevEl && $prevEl.length > 0) {
if (swiper.isBeginning) {
disableEl($prevEl);
makeElNotFocusable($prevEl);
} else {
enableEl($prevEl);
makeElFocusable($prevEl);
}
}
if ($nextEl && $nextEl.length > 0) {
if (swiper.isEnd) {
disableEl($nextEl);
makeElNotFocusable($nextEl);
} else {
enableEl($nextEl);
makeElFocusable($nextEl);
}
}
}
function hasPagination() {
return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
}
function hasClickablePagination() {
return hasPagination() && swiper.params.pagination.clickable;
}
function updatePagination() {
const params = swiper.params.a11y;
if (!hasPagination()) return;
swiper.pagination.bullets.each(bulletEl => {
const $bulletEl = $(bulletEl);
if (swiper.params.pagination.clickable) {
makeElFocusable($bulletEl);
if (!swiper.params.pagination.renderBullet) {
addElRole($bulletEl, 'button');
addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1));
}
}
if ($bulletEl.is(`.${swiper.params.pagination.bulletActiveClass}`)) {
$bulletEl.attr('aria-current', 'true');
} else {
$bulletEl.removeAttr('aria-current');
}
});
}
const initNavEl = ($el, wrapperId, message) => {
makeElFocusable($el);
if ($el[0].tagName !== 'BUTTON') {
addElRole($el, 'button');
$el.on('keydown', onEnterOrSpaceKey);
}
addElLabel($el, message);
addElControls($el, wrapperId);
};
const handlePointerDown = () => {
swiper.a11y.clicked = true;
};
const handlePointerUp = () => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
if (!swiper.destroyed) {
swiper.a11y.clicked = false;
}
});
});
};
const handleFocus = e => {
if (swiper.a11y.clicked) return;
const slideEl = e.target.closest(`.${swiper.params.slideClass}`);
if (!slideEl || !swiper.slides.includes(slideEl)) return;
const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
if (isActive || isVisible) return;
if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
if (swiper.isHorizontal()) {
swiper.el.scrollLeft = 0;
} else {
swiper.el.scrollTop = 0;
}
swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
};
const initSlides = () => {
const params = swiper.params.a11y;
if (params.itemRoleDescriptionMessage) {
addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage);
}
if (params.slideRole) {
addElRole($(swiper.slides), params.slideRole);
}
const slidesLength = swiper.params.loop ? swiper.slides.filter(el => !el.classList.contains(swiper.params.slideDuplicateClass)).length : swiper.slides.length;
if (params.slideLabelMessage) {
swiper.slides.each((slideEl, index) => {
const $slideEl = $(slideEl);
const slideIndex = swiper.params.loop ? parseInt($slideEl.attr('data-swiper-slide-index'), 10) : index;
const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
addElLabel($slideEl, ariaLabelMessage);
});
}
};
const init = () => {
const params = swiper.params.a11y;
swiper.$el.append(liveRegion); // Container
const $containerEl = swiper.$el;
if (params.containerRoleDescriptionMessage) {
addElRoleDescription($containerEl, params.containerRoleDescriptionMessage);
}
if (params.containerMessage) {
addElLabel($containerEl, params.containerMessage);
} // Wrapper
const $wrapperEl = swiper.$wrapperEl;
const wrapperId = params.id || $wrapperEl.attr('id') || `swiper-wrapper-${getRandomNumber(16)}`;
const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
addElId($wrapperEl, wrapperId);
addElLive($wrapperEl, live); // Slide
initSlides(); // Navigation
let $nextEl;
let $prevEl;
if (swiper.navigation && swiper.navigation.$nextEl) {
$nextEl = swiper.navigation.$nextEl;
}
if (swiper.navigation && swiper.navigation.$prevEl) {
$prevEl = swiper.navigation.$prevEl;
}
if ($nextEl && $nextEl.length) {
initNavEl($nextEl, wrapperId, params.nextSlideMessage);
}
if ($prevEl && $prevEl.length) {
initNavEl($prevEl, wrapperId, params.prevSlideMessage);
} // Pagination
if (hasClickablePagination()) {
swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
} // Tab focus
swiper.$el.on('focus', handleFocus, true);
swiper.$el.on('pointerdown', handlePointerDown, true);
swiper.$el.on('pointerup', handlePointerUp, true);
};
function destroy() {
if (liveRegion && liveRegion.length > 0) liveRegion.remove();
let $nextEl;
let $prevEl;
if (swiper.navigation && swiper.navigation.$nextEl) {
$nextEl = swiper.navigation.$nextEl;
}
if (swiper.navigation && swiper.navigation.$prevEl) {
$prevEl = swiper.navigation.$prevEl;
}
if ($nextEl) {
$nextEl.off('keydown', onEnterOrSpaceKey);
}
if ($prevEl) {
$prevEl.off('keydown', onEnterOrSpaceKey);
} // Pagination
if (hasClickablePagination()) {
swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
} // Tab focus
swiper.$el.off('focus', handleFocus, true);
swiper.$el.off('pointerdown', handlePointerDown, true);
swiper.$el.off('pointerup', handlePointerUp, true);
}
on('beforeInit', () => {
liveRegion = $(`<span class="${swiper.params.a11y.notificationClass}" aria-live="assertive" aria-atomic="true"></span>`);
});
on('afterInit', () => {
if (!swiper.params.a11y.enabled) return;
init();
});
on('slidesLengthChange snapGridLengthChange slidesGridLengthChange', () => {
if (!swiper.params.a11y.enabled) return;
initSlides();
});
on('fromEdge toEdge afterInit lock unlock', () => {
if (!swiper.params.a11y.enabled) return;
updateNavigation();
});
on('paginationUpdate', () => {
if (!swiper.params.a11y.enabled) return;
updatePagination();
});
on('destroy', () => {
if (!swiper.params.a11y.enabled) return;
destroy();
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | A11y | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function notify(message) {
const notification = liveRegion;
if (notification.length === 0) return;
notification.html('');
notification.html(message);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | notify | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function getRandomNumber(size) {
if (size === void 0) {
size = 16;
}
const randomChar = () => Math.round(16 * Math.random()).toString(16);
return 'x'.repeat(size).replace(/x/g, randomChar);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getRandomNumber | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function makeElFocusable($el) {
$el.attr('tabIndex', '0');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | makeElFocusable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function makeElNotFocusable($el) {
$el.attr('tabIndex', '-1');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | makeElNotFocusable | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function addElRole($el, role) {
$el.attr('role', role);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addElRole | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function addElRoleDescription($el, description) {
$el.attr('aria-roledescription', description);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addElRoleDescription | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function addElControls($el, controls) {
$el.attr('aria-controls', controls);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addElControls | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function addElLabel($el, label) {
$el.attr('aria-label', label);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addElLabel | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function addElId($el, id) {
$el.attr('id', id);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addElId | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function addElLive($el, live) {
$el.attr('aria-live', live);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addElLive | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function disableEl($el) {
$el.attr('aria-disabled', true);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | disableEl | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function enableEl($el) {
$el.attr('aria-disabled', false);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | enableEl | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function onEnterOrSpaceKey(e) {
if (e.keyCode !== 13 && e.keyCode !== 32) return;
const params = swiper.params.a11y;
const $targetEl = $(e.target);
if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) {
if (!(swiper.isEnd && !swiper.params.loop)) {
swiper.slideNext();
}
if (swiper.isEnd) {
notify(params.lastSlideMessage);
} else {
notify(params.nextSlideMessage);
}
}
if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) {
if (!(swiper.isBeginning && !swiper.params.loop)) {
swiper.slidePrev();
}
if (swiper.isBeginning) {
notify(params.firstSlideMessage);
} else {
notify(params.prevSlideMessage);
}
}
if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) {
$targetEl[0].click();
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onEnterOrSpaceKey | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function updateNavigation() {
if (swiper.params.loop || swiper.params.rewind || !swiper.navigation) return;
const {
$nextEl,
$prevEl
} = swiper.navigation;
if ($prevEl && $prevEl.length > 0) {
if (swiper.isBeginning) {
disableEl($prevEl);
makeElNotFocusable($prevEl);
} else {
enableEl($prevEl);
makeElFocusable($prevEl);
}
}
if ($nextEl && $nextEl.length > 0) {
if (swiper.isEnd) {
disableEl($nextEl);
makeElNotFocusable($nextEl);
} else {
enableEl($nextEl);
makeElFocusable($nextEl);
}
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | updateNavigation | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function hasPagination() {
return swiper.pagination && swiper.pagination.bullets && swiper.pagination.bullets.length;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | hasPagination | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function hasClickablePagination() {
return hasPagination() && swiper.params.pagination.clickable;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | hasClickablePagination | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function updatePagination() {
const params = swiper.params.a11y;
if (!hasPagination()) return;
swiper.pagination.bullets.each(bulletEl => {
const $bulletEl = $(bulletEl);
if (swiper.params.pagination.clickable) {
makeElFocusable($bulletEl);
if (!swiper.params.pagination.renderBullet) {
addElRole($bulletEl, 'button');
addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1));
}
}
if ($bulletEl.is(`.${swiper.params.pagination.bulletActiveClass}`)) {
$bulletEl.attr('aria-current', 'true');
} else {
$bulletEl.removeAttr('aria-current');
}
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | updatePagination | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
initNavEl = ($el, wrapperId, message) => {
makeElFocusable($el);
if ($el[0].tagName !== 'BUTTON') {
addElRole($el, 'button');
$el.on('keydown', onEnterOrSpaceKey);
}
addElLabel($el, message);
addElControls($el, wrapperId);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | initNavEl | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
initNavEl = ($el, wrapperId, message) => {
makeElFocusable($el);
if ($el[0].tagName !== 'BUTTON') {
addElRole($el, 'button');
$el.on('keydown', onEnterOrSpaceKey);
}
addElLabel($el, message);
addElControls($el, wrapperId);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | initNavEl | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
handlePointerDown = () => {
swiper.a11y.clicked = true;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | handlePointerDown | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
handlePointerDown = () => {
swiper.a11y.clicked = true;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | handlePointerDown | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
handlePointerUp = () => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
if (!swiper.destroyed) {
swiper.a11y.clicked = false;
}
});
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | handlePointerUp | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
handlePointerUp = () => {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
if (!swiper.destroyed) {
swiper.a11y.clicked = false;
}
});
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | handlePointerUp | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
handleFocus = e => {
if (swiper.a11y.clicked) return;
const slideEl = e.target.closest(`.${swiper.params.slideClass}`);
if (!slideEl || !swiper.slides.includes(slideEl)) return;
const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
if (isActive || isVisible) return;
if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
if (swiper.isHorizontal()) {
swiper.el.scrollLeft = 0;
} else {
swiper.el.scrollTop = 0;
}
swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | handleFocus | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
handleFocus = e => {
if (swiper.a11y.clicked) return;
const slideEl = e.target.closest(`.${swiper.params.slideClass}`);
if (!slideEl || !swiper.slides.includes(slideEl)) return;
const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
if (isActive || isVisible) return;
if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
if (swiper.isHorizontal()) {
swiper.el.scrollLeft = 0;
} else {
swiper.el.scrollTop = 0;
}
swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | handleFocus | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
initSlides = () => {
const params = swiper.params.a11y;
if (params.itemRoleDescriptionMessage) {
addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage);
}
if (params.slideRole) {
addElRole($(swiper.slides), params.slideRole);
}
const slidesLength = swiper.params.loop ? swiper.slides.filter(el => !el.classList.contains(swiper.params.slideDuplicateClass)).length : swiper.slides.length;
if (params.slideLabelMessage) {
swiper.slides.each((slideEl, index) => {
const $slideEl = $(slideEl);
const slideIndex = swiper.params.loop ? parseInt($slideEl.attr('data-swiper-slide-index'), 10) : index;
const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
addElLabel($slideEl, ariaLabelMessage);
});
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | initSlides | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
initSlides = () => {
const params = swiper.params.a11y;
if (params.itemRoleDescriptionMessage) {
addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage);
}
if (params.slideRole) {
addElRole($(swiper.slides), params.slideRole);
}
const slidesLength = swiper.params.loop ? swiper.slides.filter(el => !el.classList.contains(swiper.params.slideDuplicateClass)).length : swiper.slides.length;
if (params.slideLabelMessage) {
swiper.slides.each((slideEl, index) => {
const $slideEl = $(slideEl);
const slideIndex = swiper.params.loop ? parseInt($slideEl.attr('data-swiper-slide-index'), 10) : index;
const ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, slideIndex + 1).replace(/\{\{slidesLength\}\}/, slidesLength);
addElLabel($slideEl, ariaLabelMessage);
});
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | initSlides | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
init = () => {
const params = swiper.params.a11y;
swiper.$el.append(liveRegion); // Container
const $containerEl = swiper.$el;
if (params.containerRoleDescriptionMessage) {
addElRoleDescription($containerEl, params.containerRoleDescriptionMessage);
}
if (params.containerMessage) {
addElLabel($containerEl, params.containerMessage);
} // Wrapper
const $wrapperEl = swiper.$wrapperEl;
const wrapperId = params.id || $wrapperEl.attr('id') || `swiper-wrapper-${getRandomNumber(16)}`;
const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
addElId($wrapperEl, wrapperId);
addElLive($wrapperEl, live); // Slide
initSlides(); // Navigation
let $nextEl;
let $prevEl;
if (swiper.navigation && swiper.navigation.$nextEl) {
$nextEl = swiper.navigation.$nextEl;
}
if (swiper.navigation && swiper.navigation.$prevEl) {
$prevEl = swiper.navigation.$prevEl;
}
if ($nextEl && $nextEl.length) {
initNavEl($nextEl, wrapperId, params.nextSlideMessage);
}
if ($prevEl && $prevEl.length) {
initNavEl($prevEl, wrapperId, params.prevSlideMessage);
} // Pagination
if (hasClickablePagination()) {
swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
} // Tab focus
swiper.$el.on('focus', handleFocus, true);
swiper.$el.on('pointerdown', handlePointerDown, true);
swiper.$el.on('pointerup', handlePointerUp, true);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
init = () => {
const params = swiper.params.a11y;
swiper.$el.append(liveRegion); // Container
const $containerEl = swiper.$el;
if (params.containerRoleDescriptionMessage) {
addElRoleDescription($containerEl, params.containerRoleDescriptionMessage);
}
if (params.containerMessage) {
addElLabel($containerEl, params.containerMessage);
} // Wrapper
const $wrapperEl = swiper.$wrapperEl;
const wrapperId = params.id || $wrapperEl.attr('id') || `swiper-wrapper-${getRandomNumber(16)}`;
const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
addElId($wrapperEl, wrapperId);
addElLive($wrapperEl, live); // Slide
initSlides(); // Navigation
let $nextEl;
let $prevEl;
if (swiper.navigation && swiper.navigation.$nextEl) {
$nextEl = swiper.navigation.$nextEl;
}
if (swiper.navigation && swiper.navigation.$prevEl) {
$prevEl = swiper.navigation.$prevEl;
}
if ($nextEl && $nextEl.length) {
initNavEl($nextEl, wrapperId, params.nextSlideMessage);
}
if ($prevEl && $prevEl.length) {
initNavEl($prevEl, wrapperId, params.prevSlideMessage);
} // Pagination
if (hasClickablePagination()) {
swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
} // Tab focus
swiper.$el.on('focus', handleFocus, true);
swiper.$el.on('pointerdown', handlePointerDown, true);
swiper.$el.on('pointerup', handlePointerUp, true);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function destroy() {
if (liveRegion && liveRegion.length > 0) liveRegion.remove();
let $nextEl;
let $prevEl;
if (swiper.navigation && swiper.navigation.$nextEl) {
$nextEl = swiper.navigation.$nextEl;
}
if (swiper.navigation && swiper.navigation.$prevEl) {
$prevEl = swiper.navigation.$prevEl;
}
if ($nextEl) {
$nextEl.off('keydown', onEnterOrSpaceKey);
}
if ($prevEl) {
$prevEl.off('keydown', onEnterOrSpaceKey);
} // Pagination
if (hasClickablePagination()) {
swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), onEnterOrSpaceKey);
} // Tab focus
swiper.$el.off('focus', handleFocus, true);
swiper.$el.off('pointerdown', handlePointerDown, true);
swiper.$el.off('pointerup', handlePointerUp, true);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | destroy | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function History(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
history: {
enabled: false,
root: '',
replaceState: false,
key: 'slides',
keepQuery: false
}
});
let initialized = false;
let paths = {};
const slugify = text => {
return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
};
const getPathValues = urlOverride => {
const window = getWindow();
let location;
if (urlOverride) {
location = new URL(urlOverride);
} else {
location = window.location;
}
const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
const total = pathArray.length;
const key = pathArray[total - 2];
const value = pathArray[total - 1];
return {
key,
value
};
};
const setHistory = (key, index) => {
const window = getWindow();
if (!initialized || !swiper.params.history.enabled) return;
let location;
if (swiper.params.url) {
location = new URL(swiper.params.url);
} else {
location = window.location;
}
const slide = swiper.slides.eq(index);
let value = slugify(slide.attr('data-history'));
if (swiper.params.history.root.length > 0) {
let root = swiper.params.history.root;
if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
value = `${root}/${key}/${value}`;
} else if (!location.pathname.includes(key)) {
value = `${key}/${value}`;
}
if (swiper.params.history.keepQuery) {
value += location.search;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({
value
}, null, value);
} else {
window.history.pushState({
value
}, null, value);
}
};
const scrollToSlide = (speed, value, runCallbacks) => {
if (value) {
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHistory = slugify(slide.attr('data-history'));
if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, runCallbacks);
}
}
} else {
swiper.slideTo(0, speed, runCallbacks);
}
};
const setHistoryPopState = () => {
paths = getPathValues(swiper.params.url);
scrollToSlide(swiper.params.speed, paths.value, false);
};
const init = () => {
const window = getWindow();
if (!swiper.params.history) return;
if (!window.history || !window.history.pushState) {
swiper.params.history.enabled = false;
swiper.params.hashNavigation.enabled = true;
return;
}
initialized = true;
paths = getPathValues(swiper.params.url);
if (!paths.key && !paths.value) return;
scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
if (!swiper.params.history.replaceState) {
window.addEventListener('popstate', setHistoryPopState);
}
};
const destroy = () => {
const window = getWindow();
if (!swiper.params.history.replaceState) {
window.removeEventListener('popstate', setHistoryPopState);
}
};
on('init', () => {
if (swiper.params.history.enabled) {
init();
}
});
on('destroy', () => {
if (swiper.params.history.enabled) {
destroy();
}
});
on('transitionEnd _freeModeNoMomentumRelease', () => {
if (initialized) {
setHistory(swiper.params.history.key, swiper.activeIndex);
}
});
on('slideChange', () => {
if (initialized && swiper.params.cssMode) {
setHistory(swiper.params.history.key, swiper.activeIndex);
}
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | History | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
slugify = text => {
return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | slugify | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
slugify = text => {
return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | slugify | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
getPathValues = urlOverride => {
const window = getWindow();
let location;
if (urlOverride) {
location = new URL(urlOverride);
} else {
location = window.location;
}
const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
const total = pathArray.length;
const key = pathArray[total - 2];
const value = pathArray[total - 1];
return {
key,
value
};
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getPathValues | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
getPathValues = urlOverride => {
const window = getWindow();
let location;
if (urlOverride) {
location = new URL(urlOverride);
} else {
location = window.location;
}
const pathArray = location.pathname.slice(1).split('/').filter(part => part !== '');
const total = pathArray.length;
const key = pathArray[total - 2];
const value = pathArray[total - 1];
return {
key,
value
};
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getPathValues | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setHistory = (key, index) => {
const window = getWindow();
if (!initialized || !swiper.params.history.enabled) return;
let location;
if (swiper.params.url) {
location = new URL(swiper.params.url);
} else {
location = window.location;
}
const slide = swiper.slides.eq(index);
let value = slugify(slide.attr('data-history'));
if (swiper.params.history.root.length > 0) {
let root = swiper.params.history.root;
if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
value = `${root}/${key}/${value}`;
} else if (!location.pathname.includes(key)) {
value = `${key}/${value}`;
}
if (swiper.params.history.keepQuery) {
value += location.search;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({
value
}, null, value);
} else {
window.history.pushState({
value
}, null, value);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setHistory | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setHistory = (key, index) => {
const window = getWindow();
if (!initialized || !swiper.params.history.enabled) return;
let location;
if (swiper.params.url) {
location = new URL(swiper.params.url);
} else {
location = window.location;
}
const slide = swiper.slides.eq(index);
let value = slugify(slide.attr('data-history'));
if (swiper.params.history.root.length > 0) {
let root = swiper.params.history.root;
if (root[root.length - 1] === '/') root = root.slice(0, root.length - 1);
value = `${root}/${key}/${value}`;
} else if (!location.pathname.includes(key)) {
value = `${key}/${value}`;
}
if (swiper.params.history.keepQuery) {
value += location.search;
}
const currentState = window.history.state;
if (currentState && currentState.value === value) {
return;
}
if (swiper.params.history.replaceState) {
window.history.replaceState({
value
}, null, value);
} else {
window.history.pushState({
value
}, null, value);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setHistory | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
scrollToSlide = (speed, value, runCallbacks) => {
if (value) {
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHistory = slugify(slide.attr('data-history'));
if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, runCallbacks);
}
}
} else {
swiper.slideTo(0, speed, runCallbacks);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | scrollToSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
scrollToSlide = (speed, value, runCallbacks) => {
if (value) {
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHistory = slugify(slide.attr('data-history'));
if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, runCallbacks);
}
}
} else {
swiper.slideTo(0, speed, runCallbacks);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | scrollToSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setHistoryPopState = () => {
paths = getPathValues(swiper.params.url);
scrollToSlide(swiper.params.speed, paths.value, false);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setHistoryPopState | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setHistoryPopState = () => {
paths = getPathValues(swiper.params.url);
scrollToSlide(swiper.params.speed, paths.value, false);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setHistoryPopState | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
init = () => {
const window = getWindow();
if (!swiper.params.history) return;
if (!window.history || !window.history.pushState) {
swiper.params.history.enabled = false;
swiper.params.hashNavigation.enabled = true;
return;
}
initialized = true;
paths = getPathValues(swiper.params.url);
if (!paths.key && !paths.value) return;
scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
if (!swiper.params.history.replaceState) {
window.addEventListener('popstate', setHistoryPopState);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
init = () => {
const window = getWindow();
if (!swiper.params.history) return;
if (!window.history || !window.history.pushState) {
swiper.params.history.enabled = false;
swiper.params.hashNavigation.enabled = true;
return;
}
initialized = true;
paths = getPathValues(swiper.params.url);
if (!paths.key && !paths.value) return;
scrollToSlide(0, paths.value, swiper.params.runCallbacksOnInit);
if (!swiper.params.history.replaceState) {
window.addEventListener('popstate', setHistoryPopState);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
destroy = () => {
const window = getWindow();
if (!swiper.params.history.replaceState) {
window.removeEventListener('popstate', setHistoryPopState);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | destroy | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
destroy = () => {
const window = getWindow();
if (!swiper.params.history.replaceState) {
window.removeEventListener('popstate', setHistoryPopState);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | destroy | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
function HashNavigation(_ref) {
let {
swiper,
extendParams,
emit,
on
} = _ref;
let initialized = false;
const document = getDocument();
const window = getWindow();
extendParams({
hashNavigation: {
enabled: false,
replaceState: false,
watchState: false
}
});
const onHashChange = () => {
emit('hashChange');
const newHash = document.location.hash.replace('#', '');
const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
if (newHash !== activeSlideHash) {
const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index();
if (typeof newIndex === 'undefined') return;
swiper.slideTo(newIndex);
}
};
const setHash = () => {
if (!initialized || !swiper.params.hashNavigation.enabled) return;
if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
window.history.replaceState(null, null, `#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || '');
emit('hashSet');
} else {
const slide = swiper.slides.eq(swiper.activeIndex);
const hash = slide.attr('data-hash') || slide.attr('data-history');
document.location.hash = hash || '';
emit('hashSet');
}
};
const init = () => {
if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
initialized = true;
const hash = document.location.hash.replace('#', '');
if (hash) {
const speed = 0;
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHash = slide.attr('data-hash') || slide.attr('data-history');
if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
}
}
}
if (swiper.params.hashNavigation.watchState) {
$(window).on('hashchange', onHashChange);
}
};
const destroy = () => {
if (swiper.params.hashNavigation.watchState) {
$(window).off('hashchange', onHashChange);
}
};
on('init', () => {
if (swiper.params.hashNavigation.enabled) {
init();
}
});
on('destroy', () => {
if (swiper.params.hashNavigation.enabled) {
destroy();
}
});
on('transitionEnd _freeModeNoMomentumRelease', () => {
if (initialized) {
setHash();
}
});
on('slideChange', () => {
if (initialized && swiper.params.cssMode) {
setHash();
}
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | HashNavigation | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
onHashChange = () => {
emit('hashChange');
const newHash = document.location.hash.replace('#', '');
const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
if (newHash !== activeSlideHash) {
const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index();
if (typeof newIndex === 'undefined') return;
swiper.slideTo(newIndex);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onHashChange | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
onHashChange = () => {
emit('hashChange');
const newHash = document.location.hash.replace('#', '');
const activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
if (newHash !== activeSlideHash) {
const newIndex = swiper.$wrapperEl.children(`.${swiper.params.slideClass}[data-hash="${newHash}"]`).index();
if (typeof newIndex === 'undefined') return;
swiper.slideTo(newIndex);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onHashChange | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setHash = () => {
if (!initialized || !swiper.params.hashNavigation.enabled) return;
if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
window.history.replaceState(null, null, `#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || '');
emit('hashSet');
} else {
const slide = swiper.slides.eq(swiper.activeIndex);
const hash = slide.attr('data-hash') || slide.attr('data-history');
document.location.hash = hash || '';
emit('hashSet');
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setHash | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
setHash = () => {
if (!initialized || !swiper.params.hashNavigation.enabled) return;
if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
window.history.replaceState(null, null, `#${swiper.slides.eq(swiper.activeIndex).attr('data-hash')}` || '');
emit('hashSet');
} else {
const slide = swiper.slides.eq(swiper.activeIndex);
const hash = slide.attr('data-hash') || slide.attr('data-history');
document.location.hash = hash || '';
emit('hashSet');
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | setHash | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
init = () => {
if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
initialized = true;
const hash = document.location.hash.replace('#', '');
if (hash) {
const speed = 0;
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHash = slide.attr('data-hash') || slide.attr('data-history');
if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
}
}
}
if (swiper.params.hashNavigation.watchState) {
$(window).on('hashchange', onHashChange);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
init = () => {
if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
initialized = true;
const hash = document.location.hash.replace('#', '');
if (hash) {
const speed = 0;
for (let i = 0, length = swiper.slides.length; i < length; i += 1) {
const slide = swiper.slides.eq(i);
const slideHash = slide.attr('data-hash') || slide.attr('data-history');
if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
const index = slide.index();
swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
}
}
}
if (swiper.params.hashNavigation.watchState) {
$(window).on('hashchange', onHashChange);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | init | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.esm.browser.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.