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 |
---|---|---|---|---|---|---|---|
destroy = () => {
if (swiper.params.hashNavigation.watchState) {
$(window).off('hashchange', onHashChange);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function Autoplay(_ref) {
let {
swiper,
extendParams,
on,
emit
} = _ref;
let timeout;
swiper.autoplay = {
running: false,
paused: false
};
extendParams({
autoplay: {
enabled: false,
delay: 3000,
waitForTransition: true,
disableOnInteraction: true,
stopOnLastSlide: false,
reverseDirection: false,
pauseOnMouseEnter: false
}
});
function run() {
if (!swiper.size) {
swiper.autoplay.running = false;
swiper.autoplay.paused = false;
return;
}
const $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
let delay = swiper.params.autoplay.delay;
if ($activeSlideEl.attr('data-swiper-autoplay')) {
delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
}
clearTimeout(timeout);
timeout = nextTick(() => {
let autoplayResult;
if (swiper.params.autoplay.reverseDirection) {
if (swiper.params.loop) {
swiper.loopFix();
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.isBeginning) {
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.params.autoplay.stopOnLastSlide) {
autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
emit('autoplay');
} else {
stop();
}
} else if (swiper.params.loop) {
swiper.loopFix();
autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.isEnd) {
autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.params.autoplay.stopOnLastSlide) {
autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
emit('autoplay');
} else {
stop();
}
if (swiper.params.cssMode && swiper.autoplay.running) run();else if (autoplayResult === false) {
run();
}
}, delay);
}
function start() {
if (typeof timeout !== 'undefined') return false;
if (swiper.autoplay.running) return false;
swiper.autoplay.running = true;
emit('autoplayStart');
run();
return true;
}
function stop() {
if (!swiper.autoplay.running) return false;
if (typeof timeout === 'undefined') return false;
if (timeout) {
clearTimeout(timeout);
timeout = undefined;
}
swiper.autoplay.running = false;
emit('autoplayStop');
return true;
}
function pause(speed) {
if (!swiper.autoplay.running) return;
if (swiper.autoplay.paused) return;
if (timeout) clearTimeout(timeout);
swiper.autoplay.paused = true;
if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
swiper.autoplay.paused = false;
run();
} else {
['transitionend', 'webkitTransitionEnd'].forEach(event => {
swiper.$wrapperEl[0].addEventListener(event, onTransitionEnd);
});
}
}
function onVisibilityChange() {
const document = getDocument();
if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
pause();
}
if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
run();
swiper.autoplay.paused = false;
}
}
function onTransitionEnd(e) {
if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
if (e.target !== swiper.$wrapperEl[0]) return;
['transitionend', 'webkitTransitionEnd'].forEach(event => {
swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
});
swiper.autoplay.paused = false;
if (!swiper.autoplay.running) {
stop();
} else {
run();
}
}
function onMouseEnter() {
if (swiper.params.autoplay.disableOnInteraction) {
stop();
} else {
emit('autoplayPause');
pause();
}
['transitionend', 'webkitTransitionEnd'].forEach(event => {
swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
});
}
function onMouseLeave() {
if (swiper.params.autoplay.disableOnInteraction) {
return;
}
swiper.autoplay.paused = false;
emit('autoplayResume');
run();
}
function attachMouseEvents() {
if (swiper.params.autoplay.pauseOnMouseEnter) {
swiper.$el.on('mouseenter', onMouseEnter);
swiper.$el.on('mouseleave', onMouseLeave);
}
}
function detachMouseEvents() {
swiper.$el.off('mouseenter', onMouseEnter);
swiper.$el.off('mouseleave', onMouseLeave);
}
on('init', () => {
if (swiper.params.autoplay.enabled) {
start();
const document = getDocument();
document.addEventListener('visibilitychange', onVisibilityChange);
attachMouseEvents();
}
});
on('beforeTransitionStart', (_s, speed, internal) => {
if (swiper.autoplay.running) {
if (internal || !swiper.params.autoplay.disableOnInteraction) {
swiper.autoplay.pause(speed);
} else {
stop();
}
}
});
on('sliderFirstMove', () => {
if (swiper.autoplay.running) {
if (swiper.params.autoplay.disableOnInteraction) {
stop();
} else {
pause();
}
}
});
on('touchEnd', () => {
if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) {
run();
}
});
on('destroy', () => {
detachMouseEvents();
if (swiper.autoplay.running) {
stop();
}
const document = getDocument();
document.removeEventListener('visibilitychange', onVisibilityChange);
});
Object.assign(swiper.autoplay, {
pause,
run,
start,
stop
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Autoplay | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function run() {
if (!swiper.size) {
swiper.autoplay.running = false;
swiper.autoplay.paused = false;
return;
}
const $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
let delay = swiper.params.autoplay.delay;
if ($activeSlideEl.attr('data-swiper-autoplay')) {
delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
}
clearTimeout(timeout);
timeout = nextTick(() => {
let autoplayResult;
if (swiper.params.autoplay.reverseDirection) {
if (swiper.params.loop) {
swiper.loopFix();
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.isBeginning) {
autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.params.autoplay.stopOnLastSlide) {
autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
emit('autoplay');
} else {
stop();
}
} else if (swiper.params.loop) {
swiper.loopFix();
autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.isEnd) {
autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
emit('autoplay');
} else if (!swiper.params.autoplay.stopOnLastSlide) {
autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
emit('autoplay');
} else {
stop();
}
if (swiper.params.cssMode && swiper.autoplay.running) run();else if (autoplayResult === false) {
run();
}
}, delay);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | run | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function start() {
if (typeof timeout !== 'undefined') return false;
if (swiper.autoplay.running) return false;
swiper.autoplay.running = true;
emit('autoplayStart');
run();
return true;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | start | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function stop() {
if (!swiper.autoplay.running) return false;
if (typeof timeout === 'undefined') return false;
if (timeout) {
clearTimeout(timeout);
timeout = undefined;
}
swiper.autoplay.running = false;
emit('autoplayStop');
return true;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | stop | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function pause(speed) {
if (!swiper.autoplay.running) return;
if (swiper.autoplay.paused) return;
if (timeout) clearTimeout(timeout);
swiper.autoplay.paused = true;
if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
swiper.autoplay.paused = false;
run();
} else {
['transitionend', 'webkitTransitionEnd'].forEach(event => {
swiper.$wrapperEl[0].addEventListener(event, onTransitionEnd);
});
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | pause | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onVisibilityChange() {
const document = getDocument();
if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
pause();
}
if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
run();
swiper.autoplay.paused = false;
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onVisibilityChange | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onTransitionEnd(e) {
if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
if (e.target !== swiper.$wrapperEl[0]) return;
['transitionend', 'webkitTransitionEnd'].forEach(event => {
swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
});
swiper.autoplay.paused = false;
if (!swiper.autoplay.running) {
stop();
} else {
run();
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onMouseEnter() {
if (swiper.params.autoplay.disableOnInteraction) {
stop();
} else {
emit('autoplayPause');
pause();
}
['transitionend', 'webkitTransitionEnd'].forEach(event => {
swiper.$wrapperEl[0].removeEventListener(event, onTransitionEnd);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onMouseEnter | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onMouseLeave() {
if (swiper.params.autoplay.disableOnInteraction) {
return;
}
swiper.autoplay.paused = false;
emit('autoplayResume');
run();
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onMouseLeave | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function attachMouseEvents() {
if (swiper.params.autoplay.pauseOnMouseEnter) {
swiper.$el.on('mouseenter', onMouseEnter);
swiper.$el.on('mouseleave', onMouseLeave);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | attachMouseEvents | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function detachMouseEvents() {
swiper.$el.off('mouseenter', onMouseEnter);
swiper.$el.off('mouseleave', onMouseLeave);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | detachMouseEvents | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function Thumb(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
thumbs: {
swiper: null,
multipleActiveThumbs: true,
autoScrollOffset: 0,
slideThumbActiveClass: 'swiper-slide-thumb-active',
thumbsContainerClass: 'swiper-thumbs'
}
});
let initialized = false;
let swiperCreated = false;
swiper.thumbs = {
swiper: null
};
function onThumbClick() {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
const clickedIndex = thumbsSwiper.clickedIndex;
const clickedSlide = thumbsSwiper.clickedSlide;
if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return;
if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
let slideToIndex;
if (thumbsSwiper.params.loop) {
slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10);
} else {
slideToIndex = clickedIndex;
}
if (swiper.params.loop) {
let currentIndex = swiper.activeIndex;
if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) {
swiper.loopFix(); // eslint-disable-next-line
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
currentIndex = swiper.activeIndex;
}
const prevIndex = swiper.slides.eq(currentIndex).prevAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index();
const nextIndex = swiper.slides.eq(currentIndex).nextAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index();
if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex;
}
swiper.slideTo(slideToIndex);
}
function init() {
const {
thumbs: thumbsParams
} = swiper.params;
if (initialized) return false;
initialized = true;
const SwiperClass = swiper.constructor;
if (thumbsParams.swiper instanceof SwiperClass) {
swiper.thumbs.swiper = thumbsParams.swiper;
Object.assign(swiper.thumbs.swiper.originalParams, {
watchSlidesProgress: true,
slideToClickedSlide: false
});
Object.assign(swiper.thumbs.swiper.params, {
watchSlidesProgress: true,
slideToClickedSlide: false
});
} else if (isObject(thumbsParams.swiper)) {
const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper);
Object.assign(thumbsSwiperParams, {
watchSlidesProgress: true,
slideToClickedSlide: false
});
swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams);
swiperCreated = true;
}
swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass);
swiper.thumbs.swiper.on('tap', onThumbClick);
return true;
}
function update(initial) {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; // Activate thumbs
let thumbsToActivate = 1;
const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
thumbsToActivate = swiper.params.slidesPerView;
}
if (!swiper.params.thumbs.multipleActiveThumbs) {
thumbsToActivate = 1;
}
thumbsToActivate = Math.floor(thumbsToActivate);
thumbsSwiper.slides.removeClass(thumbActiveClass);
if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
for (let i = 0; i < thumbsToActivate; i += 1) {
thumbsSwiper.$wrapperEl.children(`[data-swiper-slide-index="${swiper.realIndex + i}"]`).addClass(thumbActiveClass);
}
} else {
for (let i = 0; i < thumbsToActivate; i += 1) {
thumbsSwiper.slides.eq(swiper.realIndex + i).addClass(thumbActiveClass);
}
}
const autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
const useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
let currentThumbsIndex = thumbsSwiper.activeIndex;
let newThumbsIndex;
let direction;
if (thumbsSwiper.params.loop) {
if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) {
thumbsSwiper.loopFix(); // eslint-disable-next-line
thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft;
currentThumbsIndex = thumbsSwiper.activeIndex;
} // Find actual thumbs index to slide to
const prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index();
const nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index();
if (typeof prevThumbsIndex === 'undefined') {
newThumbsIndex = nextThumbsIndex;
} else if (typeof nextThumbsIndex === 'undefined') {
newThumbsIndex = prevThumbsIndex;
} else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) {
newThumbsIndex = thumbsSwiper.params.slidesPerGroup > 1 ? nextThumbsIndex : currentThumbsIndex;
} else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) {
newThumbsIndex = nextThumbsIndex;
} else {
newThumbsIndex = prevThumbsIndex;
}
direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
} else {
newThumbsIndex = swiper.realIndex;
direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
}
if (useOffset) {
newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
}
if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
if (thumbsSwiper.params.centeredSlides) {
if (newThumbsIndex > currentThumbsIndex) {
newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
} else {
newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
}
} else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ;
thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
}
}
}
on('beforeInit', () => {
const {
thumbs
} = swiper.params;
if (!thumbs || !thumbs.swiper) return;
init();
update(true);
});
on('slideChange update resize observerUpdate', () => {
update();
});
on('setTransition', (_s, duration) => {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
thumbsSwiper.setTransition(duration);
});
on('beforeDestroy', () => {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
if (swiperCreated) {
thumbsSwiper.destroy();
}
});
Object.assign(swiper.thumbs, {
init,
update
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Thumb | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onThumbClick() {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
const clickedIndex = thumbsSwiper.clickedIndex;
const clickedSlide = thumbsSwiper.clickedSlide;
if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return;
if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
let slideToIndex;
if (thumbsSwiper.params.loop) {
slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10);
} else {
slideToIndex = clickedIndex;
}
if (swiper.params.loop) {
let currentIndex = swiper.activeIndex;
if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) {
swiper.loopFix(); // eslint-disable-next-line
swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
currentIndex = swiper.activeIndex;
}
const prevIndex = swiper.slides.eq(currentIndex).prevAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index();
const nextIndex = swiper.slides.eq(currentIndex).nextAll(`[data-swiper-slide-index="${slideToIndex}"]`).eq(0).index();
if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex;
}
swiper.slideTo(slideToIndex);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | onThumbClick | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function init() {
const {
thumbs: thumbsParams
} = swiper.params;
if (initialized) return false;
initialized = true;
const SwiperClass = swiper.constructor;
if (thumbsParams.swiper instanceof SwiperClass) {
swiper.thumbs.swiper = thumbsParams.swiper;
Object.assign(swiper.thumbs.swiper.originalParams, {
watchSlidesProgress: true,
slideToClickedSlide: false
});
Object.assign(swiper.thumbs.swiper.params, {
watchSlidesProgress: true,
slideToClickedSlide: false
});
} else if (isObject(thumbsParams.swiper)) {
const thumbsSwiperParams = Object.assign({}, thumbsParams.swiper);
Object.assign(thumbsSwiperParams, {
watchSlidesProgress: true,
slideToClickedSlide: false
});
swiper.thumbs.swiper = new SwiperClass(thumbsSwiperParams);
swiperCreated = true;
}
swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass);
swiper.thumbs.swiper.on('tap', onThumbClick);
return 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function update(initial) {
const thumbsSwiper = swiper.thumbs.swiper;
if (!thumbsSwiper || thumbsSwiper.destroyed) return;
const slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView; // Activate thumbs
let thumbsToActivate = 1;
const thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
thumbsToActivate = swiper.params.slidesPerView;
}
if (!swiper.params.thumbs.multipleActiveThumbs) {
thumbsToActivate = 1;
}
thumbsToActivate = Math.floor(thumbsToActivate);
thumbsSwiper.slides.removeClass(thumbActiveClass);
if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
for (let i = 0; i < thumbsToActivate; i += 1) {
thumbsSwiper.$wrapperEl.children(`[data-swiper-slide-index="${swiper.realIndex + i}"]`).addClass(thumbActiveClass);
}
} else {
for (let i = 0; i < thumbsToActivate; i += 1) {
thumbsSwiper.slides.eq(swiper.realIndex + i).addClass(thumbActiveClass);
}
}
const autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
const useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
let currentThumbsIndex = thumbsSwiper.activeIndex;
let newThumbsIndex;
let direction;
if (thumbsSwiper.params.loop) {
if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) {
thumbsSwiper.loopFix(); // eslint-disable-next-line
thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft;
currentThumbsIndex = thumbsSwiper.activeIndex;
} // Find actual thumbs index to slide to
const prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index();
const nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(`[data-swiper-slide-index="${swiper.realIndex}"]`).eq(0).index();
if (typeof prevThumbsIndex === 'undefined') {
newThumbsIndex = nextThumbsIndex;
} else if (typeof nextThumbsIndex === 'undefined') {
newThumbsIndex = prevThumbsIndex;
} else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) {
newThumbsIndex = thumbsSwiper.params.slidesPerGroup > 1 ? nextThumbsIndex : currentThumbsIndex;
} else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) {
newThumbsIndex = nextThumbsIndex;
} else {
newThumbsIndex = prevThumbsIndex;
}
direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
} else {
newThumbsIndex = swiper.realIndex;
direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
}
if (useOffset) {
newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
}
if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
if (thumbsSwiper.params.centeredSlides) {
if (newThumbsIndex > currentThumbsIndex) {
newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
} else {
newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
}
} else if (newThumbsIndex > currentThumbsIndex && thumbsSwiper.params.slidesPerGroup === 1) ;
thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
}
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | update | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function freeMode(_ref) {
let {
swiper,
extendParams,
emit,
once
} = _ref;
extendParams({
freeMode: {
enabled: false,
momentum: true,
momentumRatio: 1,
momentumBounce: true,
momentumBounceRatio: 1,
momentumVelocityRatio: 1,
sticky: false,
minimumVelocity: 0.02
}
});
function onTouchStart() {
const translate = swiper.getTranslate();
swiper.setTranslate(translate);
swiper.setTransition(0);
swiper.touchEventsData.velocities.length = 0;
swiper.freeMode.onTouchEnd({
currentPos: swiper.rtl ? swiper.translate : -swiper.translate
});
}
function onTouchMove() {
const {
touchEventsData: data,
touches
} = swiper; // Velocity
if (data.velocities.length === 0) {
data.velocities.push({
position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
time: data.touchStartTime
});
}
data.velocities.push({
position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
time: now()
});
}
function onTouchEnd(_ref2) {
let {
currentPos
} = _ref2;
const {
params,
$wrapperEl,
rtlTranslate: rtl,
snapGrid,
touchEventsData: data
} = swiper; // Time diff
const touchEndTime = now();
const timeDiff = touchEndTime - data.touchStartTime;
if (currentPos < -swiper.minTranslate()) {
swiper.slideTo(swiper.activeIndex);
return;
}
if (currentPos > -swiper.maxTranslate()) {
if (swiper.slides.length < snapGrid.length) {
swiper.slideTo(snapGrid.length - 1);
} else {
swiper.slideTo(swiper.slides.length - 1);
}
return;
}
if (params.freeMode.momentum) {
if (data.velocities.length > 1) {
const lastMoveEvent = data.velocities.pop();
const velocityEvent = data.velocities.pop();
const distance = lastMoveEvent.position - velocityEvent.position;
const time = lastMoveEvent.time - velocityEvent.time;
swiper.velocity = distance / time;
swiper.velocity /= 2;
if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) {
swiper.velocity = 0;
} // this implies that the user stopped moving a finger then released.
// There would be no events with distance zero, so the last event is stale.
if (time > 150 || now() - lastMoveEvent.time > 300) {
swiper.velocity = 0;
}
} else {
swiper.velocity = 0;
}
swiper.velocity *= params.freeMode.momentumVelocityRatio;
data.velocities.length = 0;
let momentumDuration = 1000 * params.freeMode.momentumRatio;
const momentumDistance = swiper.velocity * momentumDuration;
let newPosition = swiper.translate + momentumDistance;
if (rtl) newPosition = -newPosition;
let doBounce = false;
let afterBouncePosition;
const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio;
let needsLoopFix;
if (newPosition < swiper.maxTranslate()) {
if (params.freeMode.momentumBounce) {
if (newPosition + swiper.maxTranslate() < -bounceAmount) {
newPosition = swiper.maxTranslate() - bounceAmount;
}
afterBouncePosition = swiper.maxTranslate();
doBounce = true;
data.allowMomentumBounce = true;
} else {
newPosition = swiper.maxTranslate();
}
if (params.loop && params.centeredSlides) needsLoopFix = true;
} else if (newPosition > swiper.minTranslate()) {
if (params.freeMode.momentumBounce) {
if (newPosition - swiper.minTranslate() > bounceAmount) {
newPosition = swiper.minTranslate() + bounceAmount;
}
afterBouncePosition = swiper.minTranslate();
doBounce = true;
data.allowMomentumBounce = true;
} else {
newPosition = swiper.minTranslate();
}
if (params.loop && params.centeredSlides) needsLoopFix = true;
} else if (params.freeMode.sticky) {
let nextSlide;
for (let j = 0; j < snapGrid.length; j += 1) {
if (snapGrid[j] > -newPosition) {
nextSlide = j;
break;
}
}
if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
newPosition = snapGrid[nextSlide];
} else {
newPosition = snapGrid[nextSlide - 1];
}
newPosition = -newPosition;
}
if (needsLoopFix) {
once('transitionEnd', () => {
swiper.loopFix();
});
} // Fix duration
if (swiper.velocity !== 0) {
if (rtl) {
momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
} else {
momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
}
if (params.freeMode.sticky) {
// If freeMode.sticky is active and the user ends a swipe with a slow-velocity
// event, then durations can be 20+ seconds to slide one (or zero!) slides.
// It's easy to see this when simulating touch with mouse events. To fix this,
// limit single-slide swipes to the default slide duration. This also has the
// nice side effect of matching slide speed if the user stopped moving before
// lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
// For faster swipes, also apply limits (albeit higher ones).
const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
if (moveDistance < currentSlideSize) {
momentumDuration = params.speed;
} else if (moveDistance < 2 * currentSlideSize) {
momentumDuration = params.speed * 1.5;
} else {
momentumDuration = params.speed * 2.5;
}
}
} else if (params.freeMode.sticky) {
swiper.slideToClosest();
return;
}
if (params.freeMode.momentumBounce && doBounce) {
swiper.updateProgress(afterBouncePosition);
swiper.setTransition(momentumDuration);
swiper.setTranslate(newPosition);
swiper.transitionStart(true, swiper.swipeDirection);
swiper.animating = true;
$wrapperEl.transitionEnd(() => {
if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
emit('momentumBounce');
swiper.setTransition(params.speed);
setTimeout(() => {
swiper.setTranslate(afterBouncePosition);
$wrapperEl.transitionEnd(() => {
if (!swiper || swiper.destroyed) return;
swiper.transitionEnd();
});
}, 0);
});
} else if (swiper.velocity) {
emit('_freeModeNoMomentumRelease');
swiper.updateProgress(newPosition);
swiper.setTransition(momentumDuration);
swiper.setTranslate(newPosition);
swiper.transitionStart(true, swiper.swipeDirection);
if (!swiper.animating) {
swiper.animating = true;
$wrapperEl.transitionEnd(() => {
if (!swiper || swiper.destroyed) return;
swiper.transitionEnd();
});
}
} else {
swiper.updateProgress(newPosition);
}
swiper.updateActiveIndex();
swiper.updateSlidesClasses();
} else if (params.freeMode.sticky) {
swiper.slideToClosest();
return;
} else if (params.freeMode) {
emit('_freeModeNoMomentumRelease');
}
if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) {
swiper.updateProgress();
swiper.updateActiveIndex();
swiper.updateSlidesClasses();
}
}
Object.assign(swiper, {
freeMode: {
onTouchStart,
onTouchMove,
onTouchEnd
}
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | freeMode | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onTouchStart() {
const translate = swiper.getTranslate();
swiper.setTranslate(translate);
swiper.setTransition(0);
swiper.touchEventsData.velocities.length = 0;
swiper.freeMode.onTouchEnd({
currentPos: swiper.rtl ? swiper.translate : -swiper.translate
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onTouchMove() {
const {
touchEventsData: data,
touches
} = swiper; // Velocity
if (data.velocities.length === 0) {
data.velocities.push({
position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
time: data.touchStartTime
});
}
data.velocities.push({
position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
time: now()
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function onTouchEnd(_ref2) {
let {
currentPos
} = _ref2;
const {
params,
$wrapperEl,
rtlTranslate: rtl,
snapGrid,
touchEventsData: data
} = swiper; // Time diff
const touchEndTime = now();
const timeDiff = touchEndTime - data.touchStartTime;
if (currentPos < -swiper.minTranslate()) {
swiper.slideTo(swiper.activeIndex);
return;
}
if (currentPos > -swiper.maxTranslate()) {
if (swiper.slides.length < snapGrid.length) {
swiper.slideTo(snapGrid.length - 1);
} else {
swiper.slideTo(swiper.slides.length - 1);
}
return;
}
if (params.freeMode.momentum) {
if (data.velocities.length > 1) {
const lastMoveEvent = data.velocities.pop();
const velocityEvent = data.velocities.pop();
const distance = lastMoveEvent.position - velocityEvent.position;
const time = lastMoveEvent.time - velocityEvent.time;
swiper.velocity = distance / time;
swiper.velocity /= 2;
if (Math.abs(swiper.velocity) < params.freeMode.minimumVelocity) {
swiper.velocity = 0;
} // this implies that the user stopped moving a finger then released.
// There would be no events with distance zero, so the last event is stale.
if (time > 150 || now() - lastMoveEvent.time > 300) {
swiper.velocity = 0;
}
} else {
swiper.velocity = 0;
}
swiper.velocity *= params.freeMode.momentumVelocityRatio;
data.velocities.length = 0;
let momentumDuration = 1000 * params.freeMode.momentumRatio;
const momentumDistance = swiper.velocity * momentumDuration;
let newPosition = swiper.translate + momentumDistance;
if (rtl) newPosition = -newPosition;
let doBounce = false;
let afterBouncePosition;
const bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeMode.momentumBounceRatio;
let needsLoopFix;
if (newPosition < swiper.maxTranslate()) {
if (params.freeMode.momentumBounce) {
if (newPosition + swiper.maxTranslate() < -bounceAmount) {
newPosition = swiper.maxTranslate() - bounceAmount;
}
afterBouncePosition = swiper.maxTranslate();
doBounce = true;
data.allowMomentumBounce = true;
} else {
newPosition = swiper.maxTranslate();
}
if (params.loop && params.centeredSlides) needsLoopFix = true;
} else if (newPosition > swiper.minTranslate()) {
if (params.freeMode.momentumBounce) {
if (newPosition - swiper.minTranslate() > bounceAmount) {
newPosition = swiper.minTranslate() + bounceAmount;
}
afterBouncePosition = swiper.minTranslate();
doBounce = true;
data.allowMomentumBounce = true;
} else {
newPosition = swiper.minTranslate();
}
if (params.loop && params.centeredSlides) needsLoopFix = true;
} else if (params.freeMode.sticky) {
let nextSlide;
for (let j = 0; j < snapGrid.length; j += 1) {
if (snapGrid[j] > -newPosition) {
nextSlide = j;
break;
}
}
if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
newPosition = snapGrid[nextSlide];
} else {
newPosition = snapGrid[nextSlide - 1];
}
newPosition = -newPosition;
}
if (needsLoopFix) {
once('transitionEnd', () => {
swiper.loopFix();
});
} // Fix duration
if (swiper.velocity !== 0) {
if (rtl) {
momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
} else {
momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
}
if (params.freeMode.sticky) {
// If freeMode.sticky is active and the user ends a swipe with a slow-velocity
// event, then durations can be 20+ seconds to slide one (or zero!) slides.
// It's easy to see this when simulating touch with mouse events. To fix this,
// limit single-slide swipes to the default slide duration. This also has the
// nice side effect of matching slide speed if the user stopped moving before
// lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
// For faster swipes, also apply limits (albeit higher ones).
const moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
const currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
if (moveDistance < currentSlideSize) {
momentumDuration = params.speed;
} else if (moveDistance < 2 * currentSlideSize) {
momentumDuration = params.speed * 1.5;
} else {
momentumDuration = params.speed * 2.5;
}
}
} else if (params.freeMode.sticky) {
swiper.slideToClosest();
return;
}
if (params.freeMode.momentumBounce && doBounce) {
swiper.updateProgress(afterBouncePosition);
swiper.setTransition(momentumDuration);
swiper.setTranslate(newPosition);
swiper.transitionStart(true, swiper.swipeDirection);
swiper.animating = true;
$wrapperEl.transitionEnd(() => {
if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
emit('momentumBounce');
swiper.setTransition(params.speed);
setTimeout(() => {
swiper.setTranslate(afterBouncePosition);
$wrapperEl.transitionEnd(() => {
if (!swiper || swiper.destroyed) return;
swiper.transitionEnd();
});
}, 0);
});
} else if (swiper.velocity) {
emit('_freeModeNoMomentumRelease');
swiper.updateProgress(newPosition);
swiper.setTransition(momentumDuration);
swiper.setTranslate(newPosition);
swiper.transitionStart(true, swiper.swipeDirection);
if (!swiper.animating) {
swiper.animating = true;
$wrapperEl.transitionEnd(() => {
if (!swiper || swiper.destroyed) return;
swiper.transitionEnd();
});
}
} else {
swiper.updateProgress(newPosition);
}
swiper.updateActiveIndex();
swiper.updateSlidesClasses();
} else if (params.freeMode.sticky) {
swiper.slideToClosest();
return;
} else if (params.freeMode) {
emit('_freeModeNoMomentumRelease');
}
if (!params.freeMode.momentum || timeDiff >= params.longSwipesMs) {
swiper.updateProgress();
swiper.updateActiveIndex();
swiper.updateSlidesClasses();
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function Grid(_ref) {
let {
swiper,
extendParams
} = _ref;
extendParams({
grid: {
rows: 1,
fill: 'column'
}
});
let slidesNumberEvenToRows;
let slidesPerRow;
let numFullColumns;
const initSlides = slidesLength => {
const {
slidesPerView
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid;
slidesPerRow = slidesNumberEvenToRows / rows;
numFullColumns = Math.floor(slidesLength / rows);
if (Math.floor(slidesLength / rows) === slidesLength / rows) {
slidesNumberEvenToRows = slidesLength;
} else {
slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
}
if (slidesPerView !== 'auto' && fill === 'row') {
slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
}
};
const updateSlide = (i, slide, slidesLength, getDirectionLabel) => {
const {
slidesPerGroup,
spaceBetween
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid; // Set slides order
let newSlideOrderIndex;
let column;
let row;
if (fill === 'row' && slidesPerGroup > 1) {
const groupIndex = Math.floor(i / (slidesPerGroup * rows));
const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
row = Math.floor(slideIndexInGroup / columnsInGroup);
column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
slide.css({
'-webkit-order': newSlideOrderIndex,
order: newSlideOrderIndex
});
} else if (fill === 'column') {
column = Math.floor(i / rows);
row = i - column * rows;
if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
row += 1;
if (row >= rows) {
row = 0;
column += 1;
}
}
} else {
row = Math.floor(i / slidesPerRow);
column = i - row * slidesPerRow;
}
slide.css(getDirectionLabel('margin-top'), row !== 0 ? spaceBetween && `${spaceBetween}px` : '');
};
const updateWrapperSize = (slideSize, snapGrid, getDirectionLabel) => {
const {
spaceBetween,
centeredSlides,
roundLengths
} = swiper.params;
const {
rows
} = swiper.params.grid;
swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
swiper.$wrapperEl.css({
[getDirectionLabel('width')]: `${swiper.virtualSize + spaceBetween}px`
});
if (centeredSlides) {
snapGrid.splice(0, snapGrid.length);
const newSlidesGrid = [];
for (let i = 0; i < snapGrid.length; i += 1) {
let slidesGridItem = snapGrid[i];
if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
}
snapGrid.push(...newSlidesGrid);
}
};
swiper.grid = {
initSlides,
updateSlide,
updateWrapperSize
};
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Grid | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
initSlides = slidesLength => {
const {
slidesPerView
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid;
slidesPerRow = slidesNumberEvenToRows / rows;
numFullColumns = Math.floor(slidesLength / rows);
if (Math.floor(slidesLength / rows) === slidesLength / rows) {
slidesNumberEvenToRows = slidesLength;
} else {
slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
}
if (slidesPerView !== 'auto' && fill === 'row') {
slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
initSlides = slidesLength => {
const {
slidesPerView
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid;
slidesPerRow = slidesNumberEvenToRows / rows;
numFullColumns = Math.floor(slidesLength / rows);
if (Math.floor(slidesLength / rows) === slidesLength / rows) {
slidesNumberEvenToRows = slidesLength;
} else {
slidesNumberEvenToRows = Math.ceil(slidesLength / rows) * rows;
}
if (slidesPerView !== 'auto' && fill === 'row') {
slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, slidesPerView * rows);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
updateSlide = (i, slide, slidesLength, getDirectionLabel) => {
const {
slidesPerGroup,
spaceBetween
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid; // Set slides order
let newSlideOrderIndex;
let column;
let row;
if (fill === 'row' && slidesPerGroup > 1) {
const groupIndex = Math.floor(i / (slidesPerGroup * rows));
const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
row = Math.floor(slideIndexInGroup / columnsInGroup);
column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
slide.css({
'-webkit-order': newSlideOrderIndex,
order: newSlideOrderIndex
});
} else if (fill === 'column') {
column = Math.floor(i / rows);
row = i - column * rows;
if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
row += 1;
if (row >= rows) {
row = 0;
column += 1;
}
}
} else {
row = Math.floor(i / slidesPerRow);
column = i - row * slidesPerRow;
}
slide.css(getDirectionLabel('margin-top'), row !== 0 ? spaceBetween && `${spaceBetween}px` : '');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | updateSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
updateSlide = (i, slide, slidesLength, getDirectionLabel) => {
const {
slidesPerGroup,
spaceBetween
} = swiper.params;
const {
rows,
fill
} = swiper.params.grid; // Set slides order
let newSlideOrderIndex;
let column;
let row;
if (fill === 'row' && slidesPerGroup > 1) {
const groupIndex = Math.floor(i / (slidesPerGroup * rows));
const slideIndexInGroup = i - rows * slidesPerGroup * groupIndex;
const columnsInGroup = groupIndex === 0 ? slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * rows * slidesPerGroup) / rows), slidesPerGroup);
row = Math.floor(slideIndexInGroup / columnsInGroup);
column = slideIndexInGroup - row * columnsInGroup + groupIndex * slidesPerGroup;
newSlideOrderIndex = column + row * slidesNumberEvenToRows / rows;
slide.css({
'-webkit-order': newSlideOrderIndex,
order: newSlideOrderIndex
});
} else if (fill === 'column') {
column = Math.floor(i / rows);
row = i - column * rows;
if (column > numFullColumns || column === numFullColumns && row === rows - 1) {
row += 1;
if (row >= rows) {
row = 0;
column += 1;
}
}
} else {
row = Math.floor(i / slidesPerRow);
column = i - row * slidesPerRow;
}
slide.css(getDirectionLabel('margin-top'), row !== 0 ? spaceBetween && `${spaceBetween}px` : '');
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | updateSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
updateWrapperSize = (slideSize, snapGrid, getDirectionLabel) => {
const {
spaceBetween,
centeredSlides,
roundLengths
} = swiper.params;
const {
rows
} = swiper.params.grid;
swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
swiper.$wrapperEl.css({
[getDirectionLabel('width')]: `${swiper.virtualSize + spaceBetween}px`
});
if (centeredSlides) {
snapGrid.splice(0, snapGrid.length);
const newSlidesGrid = [];
for (let i = 0; i < snapGrid.length; i += 1) {
let slidesGridItem = snapGrid[i];
if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
}
snapGrid.push(...newSlidesGrid);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | updateWrapperSize | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
updateWrapperSize = (slideSize, snapGrid, getDirectionLabel) => {
const {
spaceBetween,
centeredSlides,
roundLengths
} = swiper.params;
const {
rows
} = swiper.params.grid;
swiper.virtualSize = (slideSize + spaceBetween) * slidesNumberEvenToRows;
swiper.virtualSize = Math.ceil(swiper.virtualSize / rows) - spaceBetween;
swiper.$wrapperEl.css({
[getDirectionLabel('width')]: `${swiper.virtualSize + spaceBetween}px`
});
if (centeredSlides) {
snapGrid.splice(0, snapGrid.length);
const newSlidesGrid = [];
for (let i = 0; i < snapGrid.length; i += 1) {
let slidesGridItem = snapGrid[i];
if (roundLengths) slidesGridItem = Math.floor(slidesGridItem);
if (snapGrid[i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
}
snapGrid.push(...newSlidesGrid);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | updateWrapperSize | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function appendSlide(slides) {
const swiper = this;
const {
$wrapperEl,
params
} = swiper;
if (params.loop) {
swiper.loopDestroy();
}
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) $wrapperEl.append(slides[i]);
}
} else {
$wrapperEl.append(slides);
}
if (params.loop) {
swiper.loopCreate();
}
if (!params.observer) {
swiper.update();
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | appendSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function prependSlide(slides) {
const swiper = this;
const {
params,
$wrapperEl,
activeIndex
} = swiper;
if (params.loop) {
swiper.loopDestroy();
}
let newActiveIndex = activeIndex + 1;
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) $wrapperEl.prepend(slides[i]);
}
newActiveIndex = activeIndex + slides.length;
} else {
$wrapperEl.prepend(slides);
}
if (params.loop) {
swiper.loopCreate();
}
if (!params.observer) {
swiper.update();
}
swiper.slideTo(newActiveIndex, 0, false);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | prependSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function addSlide(index, slides) {
const swiper = this;
const {
$wrapperEl,
params,
activeIndex
} = swiper;
let activeIndexBuffer = activeIndex;
if (params.loop) {
activeIndexBuffer -= swiper.loopedSlides;
swiper.loopDestroy();
swiper.slides = $wrapperEl.children(`.${params.slideClass}`);
}
const baseLength = swiper.slides.length;
if (index <= 0) {
swiper.prependSlide(slides);
return;
}
if (index >= baseLength) {
swiper.appendSlide(slides);
return;
}
let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
const slidesBuffer = [];
for (let i = baseLength - 1; i >= index; i -= 1) {
const currentSlide = swiper.slides.eq(i);
currentSlide.remove();
slidesBuffer.unshift(currentSlide);
}
if (typeof slides === 'object' && 'length' in slides) {
for (let i = 0; i < slides.length; i += 1) {
if (slides[i]) $wrapperEl.append(slides[i]);
}
newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
} else {
$wrapperEl.append(slides);
}
for (let i = 0; i < slidesBuffer.length; i += 1) {
$wrapperEl.append(slidesBuffer[i]);
}
if (params.loop) {
swiper.loopCreate();
}
if (!params.observer) {
swiper.update();
}
if (params.loop) {
swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
} else {
swiper.slideTo(newActiveIndex, 0, false);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | addSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function removeSlide(slidesIndexes) {
const swiper = this;
const {
params,
$wrapperEl,
activeIndex
} = swiper;
let activeIndexBuffer = activeIndex;
if (params.loop) {
activeIndexBuffer -= swiper.loopedSlides;
swiper.loopDestroy();
swiper.slides = $wrapperEl.children(`.${params.slideClass}`);
}
let newActiveIndex = activeIndexBuffer;
let indexToRemove;
if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
for (let i = 0; i < slidesIndexes.length; i += 1) {
indexToRemove = slidesIndexes[i];
if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove();
if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
}
newActiveIndex = Math.max(newActiveIndex, 0);
} else {
indexToRemove = slidesIndexes;
if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove();
if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
newActiveIndex = Math.max(newActiveIndex, 0);
}
if (params.loop) {
swiper.loopCreate();
}
if (!params.observer) {
swiper.update();
}
if (params.loop) {
swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
} else {
swiper.slideTo(newActiveIndex, 0, false);
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | removeSlide | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function removeAllSlides() {
const swiper = this;
const slidesIndexes = [];
for (let i = 0; i < swiper.slides.length; i += 1) {
slidesIndexes.push(i);
}
swiper.removeSlide(slidesIndexes);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | removeAllSlides | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function Manipulation(_ref) {
let {
swiper
} = _ref;
Object.assign(swiper, {
appendSlide: appendSlide.bind(swiper),
prependSlide: prependSlide.bind(swiper),
addSlide: addSlide.bind(swiper),
removeSlide: removeSlide.bind(swiper),
removeAllSlides: removeAllSlides.bind(swiper)
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | Manipulation | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function effectInit(params) {
const {
effect,
swiper,
on,
setTranslate,
setTransition,
overwriteParams,
perspective,
recreateShadows,
getEffectParams
} = params;
on('beforeInit', () => {
if (swiper.params.effect !== effect) return;
swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
if (perspective && perspective()) {
swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
}
const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
Object.assign(swiper.params, overwriteParamsResult);
Object.assign(swiper.originalParams, overwriteParamsResult);
});
on('setTranslate', () => {
if (swiper.params.effect !== effect) return;
setTranslate();
});
on('setTransition', (_s, duration) => {
if (swiper.params.effect !== effect) return;
setTransition(duration);
});
on('transitionEnd', () => {
if (swiper.params.effect !== effect) return;
if (recreateShadows) {
if (!getEffectParams || !getEffectParams().slideShadows) return; // remove shadows
swiper.slides.each(slideEl => {
const $slideEl = swiper.$(slideEl);
$slideEl.find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').remove();
}); // create new one
recreateShadows();
}
});
let requireUpdateOnVirtual;
on('virtualUpdate', () => {
if (swiper.params.effect !== effect) return;
if (!swiper.slides.length) {
requireUpdateOnVirtual = true;
}
requestAnimationFrame(() => {
if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) {
setTranslate();
requireUpdateOnVirtual = false;
}
});
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | effectInit | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function effectTarget(effectParams, $slideEl) {
if (effectParams.transformEl) {
return $slideEl.find(effectParams.transformEl).css({
'backface-visibility': 'hidden',
'-webkit-backface-visibility': 'hidden'
});
}
return $slideEl;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | effectTarget | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function effectVirtualTransitionEnd(_ref) {
let {
swiper,
duration,
transformEl,
allSlides
} = _ref;
const {
slides,
activeIndex,
$wrapperEl
} = swiper;
if (swiper.params.virtualTranslate && duration !== 0) {
let eventTriggered = false;
let $transitionEndTarget;
if (allSlides) {
$transitionEndTarget = transformEl ? slides.find(transformEl) : slides;
} else {
$transitionEndTarget = transformEl ? slides.eq(activeIndex).find(transformEl) : slides.eq(activeIndex);
}
$transitionEndTarget.transitionEnd(() => {
if (eventTriggered) return;
if (!swiper || swiper.destroyed) return;
eventTriggered = true;
swiper.animating = false;
const triggerEvents = ['webkitTransitionEnd', 'transitionend'];
for (let i = 0; i < triggerEvents.length; i += 1) {
$wrapperEl.trigger(triggerEvents[i]);
}
});
}
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | effectVirtualTransitionEnd | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function EffectFade(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
fadeEffect: {
crossFade: false,
transformEl: null
}
});
const setTranslate = () => {
const {
slides
} = swiper;
const params = swiper.params.fadeEffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = swiper.slides.eq(i);
const offset = $slideEl[0].swiperSlideOffset;
let tx = -offset;
if (!swiper.params.virtualTranslate) tx -= swiper.translate;
let ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
}
const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
const $targetEl = effectTarget(params, $slideEl);
$targetEl.css({
opacity: slideOpacity
}).transform(`translate3d(${tx}px, ${ty}px, 0px)`);
}
};
const setTransition = duration => {
const {
transformEl
} = swiper.params.fadeEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl,
allSlides: true
});
};
effectInit({
effect: 'fade',
swiper,
on,
setTranslate,
setTransition,
overwriteParams: () => ({
slidesPerView: 1,
slidesPerGroup: 1,
watchSlidesProgress: true,
spaceBetween: 0,
virtualTranslate: !swiper.params.cssMode
})
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | EffectFade | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides
} = swiper;
const params = swiper.params.fadeEffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = swiper.slides.eq(i);
const offset = $slideEl[0].swiperSlideOffset;
let tx = -offset;
if (!swiper.params.virtualTranslate) tx -= swiper.translate;
let ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
}
const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
const $targetEl = effectTarget(params, $slideEl);
$targetEl.css({
opacity: slideOpacity
}).transform(`translate3d(${tx}px, ${ty}px, 0px)`);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides
} = swiper;
const params = swiper.params.fadeEffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = swiper.slides.eq(i);
const offset = $slideEl[0].swiperSlideOffset;
let tx = -offset;
if (!swiper.params.virtualTranslate) tx -= swiper.translate;
let ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
}
const slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
const $targetEl = effectTarget(params, $slideEl);
$targetEl.css({
opacity: slideOpacity
}).transform(`translate3d(${tx}px, ${ty}px, 0px)`);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.fadeEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl,
allSlides: true
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.fadeEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl,
allSlides: true
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function EffectCube(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
cubeEffect: {
slideShadows: true,
shadow: true,
shadowOffset: 20,
shadowScale: 0.94
}
});
const createSlideShadows = ($slideEl, progress, isHorizontal) => {
let shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if (shadowBefore.length === 0) {
shadowBefore = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}"></div>`);
$slideEl.append(shadowBefore);
}
if (shadowAfter.length === 0) {
shadowAfter = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}"></div>`);
$slideEl.append(shadowAfter);
}
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
};
const recreateShadows = () => {
// create new ones
const isHorizontal = swiper.isHorizontal();
swiper.slides.each(slideEl => {
const progress = Math.max(Math.min(slideEl.progress, 1), -1);
createSlideShadows($(slideEl), progress, isHorizontal);
});
};
const setTranslate = () => {
const {
$el,
$wrapperEl,
slides,
width: swiperWidth,
height: swiperHeight,
rtlTranslate: rtl,
size: swiperSize,
browser
} = swiper;
const params = swiper.params.cubeEffect;
const isHorizontal = swiper.isHorizontal();
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
let wrapperRotate = 0;
let $cubeShadowEl;
if (params.shadow) {
if (isHorizontal) {
$cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow');
if ($cubeShadowEl.length === 0) {
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
$wrapperEl.append($cubeShadowEl);
}
$cubeShadowEl.css({
height: `${swiperWidth}px`
});
} else {
$cubeShadowEl = $el.find('.swiper-cube-shadow');
if ($cubeShadowEl.length === 0) {
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
$el.append($cubeShadowEl);
}
}
}
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
let slideIndex = i;
if (isVirtual) {
slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10);
}
let slideAngle = slideIndex * 90;
let round = Math.floor(slideAngle / 360);
if (rtl) {
slideAngle = -slideAngle;
round = Math.floor(-slideAngle / 360);
}
const progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
let tx = 0;
let ty = 0;
let tz = 0;
if (slideIndex % 4 === 0) {
tx = -round * 4 * swiperSize;
tz = 0;
} else if ((slideIndex - 1) % 4 === 0) {
tx = 0;
tz = -round * 4 * swiperSize;
} else if ((slideIndex - 2) % 4 === 0) {
tx = swiperSize + round * 4 * swiperSize;
tz = swiperSize;
} else if ((slideIndex - 3) % 4 === 0) {
tx = -swiperSize;
tz = 3 * swiperSize + swiperSize * 4 * round;
}
if (rtl) {
tx = -tx;
}
if (!isHorizontal) {
ty = tx;
tx = 0;
}
const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
if (progress <= 1 && progress > -1) {
wrapperRotate = slideIndex * 90 + progress * 90;
if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
}
$slideEl.transform(transform);
if (params.slideShadows) {
createSlideShadows($slideEl, progress, isHorizontal);
}
}
$wrapperEl.css({
'-webkit-transform-origin': `50% 50% -${swiperSize / 2}px`,
'transform-origin': `50% 50% -${swiperSize / 2}px`
});
if (params.shadow) {
if (isHorizontal) {
$cubeShadowEl.transform(`translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(90deg) rotateZ(0deg) scale(${params.shadowScale})`);
} else {
const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
const scale1 = params.shadowScale;
const scale2 = params.shadowScale / multiplier;
const offset = params.shadowOffset;
$cubeShadowEl.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-90deg)`);
}
}
const zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0;
$wrapperEl.transform(`translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`);
$wrapperEl[0].style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
};
const setTransition = duration => {
const {
$el,
slides
} = swiper;
slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
$el.find('.swiper-cube-shadow').transition(duration);
}
};
effectInit({
effect: 'cube',
swiper,
on,
setTranslate,
setTransition,
recreateShadows,
getEffectParams: () => swiper.params.cubeEffect,
perspective: () => true,
overwriteParams: () => ({
slidesPerView: 1,
slidesPerGroup: 1,
watchSlidesProgress: true,
resistanceRatio: 0,
spaceBetween: 0,
centeredSlides: false,
virtualTranslate: true
})
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | EffectCube | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
createSlideShadows = ($slideEl, progress, isHorizontal) => {
let shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if (shadowBefore.length === 0) {
shadowBefore = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}"></div>`);
$slideEl.append(shadowBefore);
}
if (shadowAfter.length === 0) {
shadowAfter = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}"></div>`);
$slideEl.append(shadowAfter);
}
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | createSlideShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
createSlideShadows = ($slideEl, progress, isHorizontal) => {
let shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if (shadowBefore.length === 0) {
shadowBefore = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'left' : 'top'}"></div>`);
$slideEl.append(shadowBefore);
}
if (shadowAfter.length === 0) {
shadowAfter = $(`<div class="swiper-slide-shadow-${isHorizontal ? 'right' : 'bottom'}"></div>`);
$slideEl.append(shadowAfter);
}
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | createSlideShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
recreateShadows = () => {
// create new ones
const isHorizontal = swiper.isHorizontal();
swiper.slides.each(slideEl => {
const progress = Math.max(Math.min(slideEl.progress, 1), -1);
createSlideShadows($(slideEl), progress, isHorizontal);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | recreateShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
recreateShadows = () => {
// create new ones
const isHorizontal = swiper.isHorizontal();
swiper.slides.each(slideEl => {
const progress = Math.max(Math.min(slideEl.progress, 1), -1);
createSlideShadows($(slideEl), progress, isHorizontal);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | recreateShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
$el,
$wrapperEl,
slides,
width: swiperWidth,
height: swiperHeight,
rtlTranslate: rtl,
size: swiperSize,
browser
} = swiper;
const params = swiper.params.cubeEffect;
const isHorizontal = swiper.isHorizontal();
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
let wrapperRotate = 0;
let $cubeShadowEl;
if (params.shadow) {
if (isHorizontal) {
$cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow');
if ($cubeShadowEl.length === 0) {
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
$wrapperEl.append($cubeShadowEl);
}
$cubeShadowEl.css({
height: `${swiperWidth}px`
});
} else {
$cubeShadowEl = $el.find('.swiper-cube-shadow');
if ($cubeShadowEl.length === 0) {
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
$el.append($cubeShadowEl);
}
}
}
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
let slideIndex = i;
if (isVirtual) {
slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10);
}
let slideAngle = slideIndex * 90;
let round = Math.floor(slideAngle / 360);
if (rtl) {
slideAngle = -slideAngle;
round = Math.floor(-slideAngle / 360);
}
const progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
let tx = 0;
let ty = 0;
let tz = 0;
if (slideIndex % 4 === 0) {
tx = -round * 4 * swiperSize;
tz = 0;
} else if ((slideIndex - 1) % 4 === 0) {
tx = 0;
tz = -round * 4 * swiperSize;
} else if ((slideIndex - 2) % 4 === 0) {
tx = swiperSize + round * 4 * swiperSize;
tz = swiperSize;
} else if ((slideIndex - 3) % 4 === 0) {
tx = -swiperSize;
tz = 3 * swiperSize + swiperSize * 4 * round;
}
if (rtl) {
tx = -tx;
}
if (!isHorizontal) {
ty = tx;
tx = 0;
}
const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
if (progress <= 1 && progress > -1) {
wrapperRotate = slideIndex * 90 + progress * 90;
if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
}
$slideEl.transform(transform);
if (params.slideShadows) {
createSlideShadows($slideEl, progress, isHorizontal);
}
}
$wrapperEl.css({
'-webkit-transform-origin': `50% 50% -${swiperSize / 2}px`,
'transform-origin': `50% 50% -${swiperSize / 2}px`
});
if (params.shadow) {
if (isHorizontal) {
$cubeShadowEl.transform(`translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(90deg) rotateZ(0deg) scale(${params.shadowScale})`);
} else {
const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
const scale1 = params.shadowScale;
const scale2 = params.shadowScale / multiplier;
const offset = params.shadowOffset;
$cubeShadowEl.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-90deg)`);
}
}
const zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0;
$wrapperEl.transform(`translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`);
$wrapperEl[0].style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
$el,
$wrapperEl,
slides,
width: swiperWidth,
height: swiperHeight,
rtlTranslate: rtl,
size: swiperSize,
browser
} = swiper;
const params = swiper.params.cubeEffect;
const isHorizontal = swiper.isHorizontal();
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
let wrapperRotate = 0;
let $cubeShadowEl;
if (params.shadow) {
if (isHorizontal) {
$cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow');
if ($cubeShadowEl.length === 0) {
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
$wrapperEl.append($cubeShadowEl);
}
$cubeShadowEl.css({
height: `${swiperWidth}px`
});
} else {
$cubeShadowEl = $el.find('.swiper-cube-shadow');
if ($cubeShadowEl.length === 0) {
$cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
$el.append($cubeShadowEl);
}
}
}
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
let slideIndex = i;
if (isVirtual) {
slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10);
}
let slideAngle = slideIndex * 90;
let round = Math.floor(slideAngle / 360);
if (rtl) {
slideAngle = -slideAngle;
round = Math.floor(-slideAngle / 360);
}
const progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
let tx = 0;
let ty = 0;
let tz = 0;
if (slideIndex % 4 === 0) {
tx = -round * 4 * swiperSize;
tz = 0;
} else if ((slideIndex - 1) % 4 === 0) {
tx = 0;
tz = -round * 4 * swiperSize;
} else if ((slideIndex - 2) % 4 === 0) {
tx = swiperSize + round * 4 * swiperSize;
tz = swiperSize;
} else if ((slideIndex - 3) % 4 === 0) {
tx = -swiperSize;
tz = 3 * swiperSize + swiperSize * 4 * round;
}
if (rtl) {
tx = -tx;
}
if (!isHorizontal) {
ty = tx;
tx = 0;
}
const transform = `rotateX(${isHorizontal ? 0 : -slideAngle}deg) rotateY(${isHorizontal ? slideAngle : 0}deg) translate3d(${tx}px, ${ty}px, ${tz}px)`;
if (progress <= 1 && progress > -1) {
wrapperRotate = slideIndex * 90 + progress * 90;
if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
}
$slideEl.transform(transform);
if (params.slideShadows) {
createSlideShadows($slideEl, progress, isHorizontal);
}
}
$wrapperEl.css({
'-webkit-transform-origin': `50% 50% -${swiperSize / 2}px`,
'transform-origin': `50% 50% -${swiperSize / 2}px`
});
if (params.shadow) {
if (isHorizontal) {
$cubeShadowEl.transform(`translate3d(0px, ${swiperWidth / 2 + params.shadowOffset}px, ${-swiperWidth / 2}px) rotateX(90deg) rotateZ(0deg) scale(${params.shadowScale})`);
} else {
const shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
const multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
const scale1 = params.shadowScale;
const scale2 = params.shadowScale / multiplier;
const offset = params.shadowOffset;
$cubeShadowEl.transform(`scale3d(${scale1}, 1, ${scale2}) translate3d(0px, ${swiperHeight / 2 + offset}px, ${-swiperHeight / 2 / scale2}px) rotateX(-90deg)`);
}
}
const zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0;
$wrapperEl.transform(`translate3d(0px,0,${zFactor}px) rotateX(${swiper.isHorizontal() ? 0 : wrapperRotate}deg) rotateY(${swiper.isHorizontal() ? -wrapperRotate : 0}deg)`);
$wrapperEl[0].style.setProperty('--swiper-cube-translate-z', `${zFactor}px`);
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
$el,
slides
} = swiper;
slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
$el.find('.swiper-cube-shadow').transition(duration);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
$el,
slides
} = swiper;
slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
$el.find('.swiper-cube-shadow').transition(duration);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function createShadow(params, $slideEl, side) {
const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}`;
const $shadowContainer = params.transformEl ? $slideEl.find(params.transformEl) : $slideEl;
let $shadowEl = $shadowContainer.children(`.${shadowClass}`);
if (!$shadowEl.length) {
$shadowEl = $(`<div class="swiper-slide-shadow${side ? `-${side}` : ''}"></div>`);
$shadowContainer.append($shadowEl);
}
return $shadowEl;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | createShadow | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function EffectFlip(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
flipEffect: {
slideShadows: true,
limitRotation: true,
transformEl: null
}
});
const createSlideShadows = ($slideEl, progress, params) => {
let shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if (shadowBefore.length === 0) {
shadowBefore = createShadow(params, $slideEl, swiper.isHorizontal() ? 'left' : 'top');
}
if (shadowAfter.length === 0) {
shadowAfter = createShadow(params, $slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
}
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
};
const recreateShadows = () => {
// Set shadows
const params = swiper.params.flipEffect;
swiper.slides.each(slideEl => {
const $slideEl = $(slideEl);
let progress = $slideEl[0].progress;
if (swiper.params.flipEffect.limitRotation) {
progress = Math.max(Math.min(slideEl.progress, 1), -1);
}
createSlideShadows($slideEl, progress, params);
});
};
const setTranslate = () => {
const {
slides,
rtlTranslate: rtl
} = swiper;
const params = swiper.params.flipEffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
let progress = $slideEl[0].progress;
if (swiper.params.flipEffect.limitRotation) {
progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
}
const offset = $slideEl[0].swiperSlideOffset;
const rotate = -180 * progress;
let rotateY = rotate;
let rotateX = 0;
let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
let ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
rotateX = -rotateY;
rotateY = 0;
} else if (rtl) {
rotateY = -rotateY;
}
$slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
if (params.slideShadows) {
createSlideShadows($slideEl, progress, params);
}
const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform);
}
};
const setTransition = duration => {
const {
transformEl
} = swiper.params.flipEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl
});
};
effectInit({
effect: 'flip',
swiper,
on,
setTranslate,
setTransition,
recreateShadows,
getEffectParams: () => swiper.params.flipEffect,
perspective: () => true,
overwriteParams: () => ({
slidesPerView: 1,
slidesPerGroup: 1,
watchSlidesProgress: true,
spaceBetween: 0,
virtualTranslate: !swiper.params.cssMode
})
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | EffectFlip | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
createSlideShadows = ($slideEl, progress, params) => {
let shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if (shadowBefore.length === 0) {
shadowBefore = createShadow(params, $slideEl, swiper.isHorizontal() ? 'left' : 'top');
}
if (shadowAfter.length === 0) {
shadowAfter = createShadow(params, $slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
}
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | createSlideShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
createSlideShadows = ($slideEl, progress, params) => {
let shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if (shadowBefore.length === 0) {
shadowBefore = createShadow(params, $slideEl, swiper.isHorizontal() ? 'left' : 'top');
}
if (shadowAfter.length === 0) {
shadowAfter = createShadow(params, $slideEl, swiper.isHorizontal() ? 'right' : 'bottom');
}
if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | createSlideShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
recreateShadows = () => {
// Set shadows
const params = swiper.params.flipEffect;
swiper.slides.each(slideEl => {
const $slideEl = $(slideEl);
let progress = $slideEl[0].progress;
if (swiper.params.flipEffect.limitRotation) {
progress = Math.max(Math.min(slideEl.progress, 1), -1);
}
createSlideShadows($slideEl, progress, params);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | recreateShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
recreateShadows = () => {
// Set shadows
const params = swiper.params.flipEffect;
swiper.slides.each(slideEl => {
const $slideEl = $(slideEl);
let progress = $slideEl[0].progress;
if (swiper.params.flipEffect.limitRotation) {
progress = Math.max(Math.min(slideEl.progress, 1), -1);
}
createSlideShadows($slideEl, progress, params);
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | recreateShadows | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides,
rtlTranslate: rtl
} = swiper;
const params = swiper.params.flipEffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
let progress = $slideEl[0].progress;
if (swiper.params.flipEffect.limitRotation) {
progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
}
const offset = $slideEl[0].swiperSlideOffset;
const rotate = -180 * progress;
let rotateY = rotate;
let rotateX = 0;
let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
let ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
rotateX = -rotateY;
rotateY = 0;
} else if (rtl) {
rotateY = -rotateY;
}
$slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
if (params.slideShadows) {
createSlideShadows($slideEl, progress, params);
}
const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides,
rtlTranslate: rtl
} = swiper;
const params = swiper.params.flipEffect;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
let progress = $slideEl[0].progress;
if (swiper.params.flipEffect.limitRotation) {
progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
}
const offset = $slideEl[0].swiperSlideOffset;
const rotate = -180 * progress;
let rotateY = rotate;
let rotateX = 0;
let tx = swiper.params.cssMode ? -offset - swiper.translate : -offset;
let ty = 0;
if (!swiper.isHorizontal()) {
ty = tx;
tx = 0;
rotateX = -rotateY;
rotateY = 0;
} else if (rtl) {
rotateY = -rotateY;
}
$slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
if (params.slideShadows) {
createSlideShadows($slideEl, progress, params);
}
const transform = `translate3d(${tx}px, ${ty}px, 0px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.flipEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.flipEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function EffectCoverflow(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
coverflowEffect: {
rotate: 50,
stretch: 0,
depth: 100,
scale: 1,
modifier: 1,
slideShadows: true,
transformEl: null
}
});
const setTranslate = () => {
const {
width: swiperWidth,
height: swiperHeight,
slides,
slidesSizesGrid
} = swiper;
const params = swiper.params.coverflowEffect;
const isHorizontal = swiper.isHorizontal();
const transform = swiper.translate;
const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
const rotate = isHorizontal ? params.rotate : -params.rotate;
const translate = params.depth; // Each slide offset from center
for (let i = 0, length = slides.length; i < length; i += 1) {
const $slideEl = slides.eq(i);
const slideSize = slidesSizesGrid[i];
const slideOffset = $slideEl[0].swiperSlideOffset;
const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0
let translateZ = -translate * Math.abs(offsetMultiplier);
let stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders
if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
stretch = parseFloat(params.stretch) / 100 * slideSize;
}
let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values
if (Math.abs(translateX) < 0.001) translateX = 0;
if (Math.abs(translateY) < 0.001) translateY = 0;
if (Math.abs(translateZ) < 0.001) translateZ = 0;
if (Math.abs(rotateY) < 0.001) rotateY = 0;
if (Math.abs(rotateX) < 0.001) rotateX = 0;
if (Math.abs(scale) < 0.001) scale = 0;
const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(slideTransform);
$slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
if (params.slideShadows) {
// Set shadows
let $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if ($shadowBeforeEl.length === 0) {
$shadowBeforeEl = createShadow(params, $slideEl, isHorizontal ? 'left' : 'top');
}
if ($shadowAfterEl.length === 0) {
$shadowAfterEl = createShadow(params, $slideEl, isHorizontal ? 'right' : 'bottom');
}
if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
}
}
};
const setTransition = duration => {
const {
transformEl
} = swiper.params.coverflowEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
};
effectInit({
effect: 'coverflow',
swiper,
on,
setTranslate,
setTransition,
perspective: () => true,
overwriteParams: () => ({
watchSlidesProgress: true
})
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | EffectCoverflow | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
width: swiperWidth,
height: swiperHeight,
slides,
slidesSizesGrid
} = swiper;
const params = swiper.params.coverflowEffect;
const isHorizontal = swiper.isHorizontal();
const transform = swiper.translate;
const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
const rotate = isHorizontal ? params.rotate : -params.rotate;
const translate = params.depth; // Each slide offset from center
for (let i = 0, length = slides.length; i < length; i += 1) {
const $slideEl = slides.eq(i);
const slideSize = slidesSizesGrid[i];
const slideOffset = $slideEl[0].swiperSlideOffset;
const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0
let translateZ = -translate * Math.abs(offsetMultiplier);
let stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders
if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
stretch = parseFloat(params.stretch) / 100 * slideSize;
}
let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values
if (Math.abs(translateX) < 0.001) translateX = 0;
if (Math.abs(translateY) < 0.001) translateY = 0;
if (Math.abs(translateZ) < 0.001) translateZ = 0;
if (Math.abs(rotateY) < 0.001) rotateY = 0;
if (Math.abs(rotateX) < 0.001) rotateX = 0;
if (Math.abs(scale) < 0.001) scale = 0;
const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(slideTransform);
$slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
if (params.slideShadows) {
// Set shadows
let $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if ($shadowBeforeEl.length === 0) {
$shadowBeforeEl = createShadow(params, $slideEl, isHorizontal ? 'left' : 'top');
}
if ($shadowAfterEl.length === 0) {
$shadowAfterEl = createShadow(params, $slideEl, isHorizontal ? 'right' : 'bottom');
}
if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
}
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
width: swiperWidth,
height: swiperHeight,
slides,
slidesSizesGrid
} = swiper;
const params = swiper.params.coverflowEffect;
const isHorizontal = swiper.isHorizontal();
const transform = swiper.translate;
const center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
const rotate = isHorizontal ? params.rotate : -params.rotate;
const translate = params.depth; // Each slide offset from center
for (let i = 0, length = slides.length; i < length; i += 1) {
const $slideEl = slides.eq(i);
const slideSize = slidesSizesGrid[i];
const slideOffset = $slideEl[0].swiperSlideOffset;
const centerOffset = (center - slideOffset - slideSize / 2) / slideSize;
const offsetMultiplier = typeof params.modifier === 'function' ? params.modifier(centerOffset) : centerOffset * params.modifier;
let rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
let rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; // var rotateZ = 0
let translateZ = -translate * Math.abs(offsetMultiplier);
let stretch = params.stretch; // Allow percentage to make a relative stretch for responsive sliders
if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
stretch = parseFloat(params.stretch) / 100 * slideSize;
}
let translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
let translateX = isHorizontal ? stretch * offsetMultiplier : 0;
let scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier); // Fix for ultra small values
if (Math.abs(translateX) < 0.001) translateX = 0;
if (Math.abs(translateY) < 0.001) translateY = 0;
if (Math.abs(translateZ) < 0.001) translateZ = 0;
if (Math.abs(rotateY) < 0.001) rotateY = 0;
if (Math.abs(rotateX) < 0.001) rotateX = 0;
if (Math.abs(scale) < 0.001) scale = 0;
const slideTransform = `translate3d(${translateX}px,${translateY}px,${translateZ}px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(${scale})`;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(slideTransform);
$slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
if (params.slideShadows) {
// Set shadows
let $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
let $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
if ($shadowBeforeEl.length === 0) {
$shadowBeforeEl = createShadow(params, $slideEl, isHorizontal ? 'left' : 'top');
}
if ($shadowAfterEl.length === 0) {
$shadowAfterEl = createShadow(params, $slideEl, isHorizontal ? 'right' : 'bottom');
}
if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
}
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.coverflowEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.coverflowEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function EffectCreative(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
creativeEffect: {
transformEl: null,
limitProgress: 1,
shadowPerProgress: false,
progressMultiplier: 1,
perspective: true,
prev: {
translate: [0, 0, 0],
rotate: [0, 0, 0],
opacity: 1,
scale: 1
},
next: {
translate: [0, 0, 0],
rotate: [0, 0, 0],
opacity: 1,
scale: 1
}
}
});
const getTranslateValue = value => {
if (typeof value === 'string') return value;
return `${value}px`;
};
const setTranslate = () => {
const {
slides,
$wrapperEl,
slidesSizesGrid
} = swiper;
const params = swiper.params.creativeEffect;
const {
progressMultiplier: multiplier
} = params;
const isCenteredSlides = swiper.params.centeredSlides;
if (isCenteredSlides) {
const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
$wrapperEl.transform(`translateX(calc(50% - ${margin}px))`);
}
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
const progress = Math.min(Math.max($slideEl[0].progress, -params.limitProgress), params.limitProgress);
let originalProgress = progress;
if (!isCenteredSlides) {
originalProgress = Math.min(Math.max($slideEl[0].originalProgress, -params.limitProgress), params.limitProgress);
}
const offset = $slideEl[0].swiperSlideOffset;
const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
const r = [0, 0, 0];
let custom = false;
if (!swiper.isHorizontal()) {
t[1] = t[0];
t[0] = 0;
}
let data = {
translate: [0, 0, 0],
rotate: [0, 0, 0],
scale: 1,
opacity: 1
};
if (progress < 0) {
data = params.next;
custom = true;
} else if (progress > 0) {
data = params.prev;
custom = true;
} // set translate
t.forEach((value, index) => {
t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
}); // set rotates
r.forEach((value, index) => {
r[index] = data.rotate[index] * Math.abs(progress * multiplier);
});
$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
const translateString = t.join(', ');
const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`;
const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`; // Set shadows
if (custom && data.shadow || !custom) {
let $shadowEl = $slideEl.children('.swiper-slide-shadow');
if ($shadowEl.length === 0 && data.shadow) {
$shadowEl = createShadow(params, $slideEl);
}
if ($shadowEl.length) {
const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
$shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
}
}
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform).css({
opacity: opacityString
});
if (data.origin) {
$targetEl.css('transform-origin', data.origin);
}
}
};
const setTransition = duration => {
const {
transformEl
} = swiper.params.creativeEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl,
allSlides: true
});
};
effectInit({
effect: 'creative',
swiper,
on,
setTranslate,
setTransition,
perspective: () => swiper.params.creativeEffect.perspective,
overwriteParams: () => ({
watchSlidesProgress: true,
virtualTranslate: !swiper.params.cssMode
})
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | EffectCreative | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
getTranslateValue = value => {
if (typeof value === 'string') return value;
return `${value}px`;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getTranslateValue | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
getTranslateValue = value => {
if (typeof value === 'string') return value;
return `${value}px`;
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | getTranslateValue | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides,
$wrapperEl,
slidesSizesGrid
} = swiper;
const params = swiper.params.creativeEffect;
const {
progressMultiplier: multiplier
} = params;
const isCenteredSlides = swiper.params.centeredSlides;
if (isCenteredSlides) {
const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
$wrapperEl.transform(`translateX(calc(50% - ${margin}px))`);
}
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
const progress = Math.min(Math.max($slideEl[0].progress, -params.limitProgress), params.limitProgress);
let originalProgress = progress;
if (!isCenteredSlides) {
originalProgress = Math.min(Math.max($slideEl[0].originalProgress, -params.limitProgress), params.limitProgress);
}
const offset = $slideEl[0].swiperSlideOffset;
const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
const r = [0, 0, 0];
let custom = false;
if (!swiper.isHorizontal()) {
t[1] = t[0];
t[0] = 0;
}
let data = {
translate: [0, 0, 0],
rotate: [0, 0, 0],
scale: 1,
opacity: 1
};
if (progress < 0) {
data = params.next;
custom = true;
} else if (progress > 0) {
data = params.prev;
custom = true;
} // set translate
t.forEach((value, index) => {
t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
}); // set rotates
r.forEach((value, index) => {
r[index] = data.rotate[index] * Math.abs(progress * multiplier);
});
$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
const translateString = t.join(', ');
const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`;
const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`; // Set shadows
if (custom && data.shadow || !custom) {
let $shadowEl = $slideEl.children('.swiper-slide-shadow');
if ($shadowEl.length === 0 && data.shadow) {
$shadowEl = createShadow(params, $slideEl);
}
if ($shadowEl.length) {
const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
$shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
}
}
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform).css({
opacity: opacityString
});
if (data.origin) {
$targetEl.css('transform-origin', data.origin);
}
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides,
$wrapperEl,
slidesSizesGrid
} = swiper;
const params = swiper.params.creativeEffect;
const {
progressMultiplier: multiplier
} = params;
const isCenteredSlides = swiper.params.centeredSlides;
if (isCenteredSlides) {
const margin = slidesSizesGrid[0] / 2 - swiper.params.slidesOffsetBefore || 0;
$wrapperEl.transform(`translateX(calc(50% - ${margin}px))`);
}
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
const progress = Math.min(Math.max($slideEl[0].progress, -params.limitProgress), params.limitProgress);
let originalProgress = progress;
if (!isCenteredSlides) {
originalProgress = Math.min(Math.max($slideEl[0].originalProgress, -params.limitProgress), params.limitProgress);
}
const offset = $slideEl[0].swiperSlideOffset;
const t = [swiper.params.cssMode ? -offset - swiper.translate : -offset, 0, 0];
const r = [0, 0, 0];
let custom = false;
if (!swiper.isHorizontal()) {
t[1] = t[0];
t[0] = 0;
}
let data = {
translate: [0, 0, 0],
rotate: [0, 0, 0],
scale: 1,
opacity: 1
};
if (progress < 0) {
data = params.next;
custom = true;
} else if (progress > 0) {
data = params.prev;
custom = true;
} // set translate
t.forEach((value, index) => {
t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(progress * multiplier)}))`;
}); // set rotates
r.forEach((value, index) => {
r[index] = data.rotate[index] * Math.abs(progress * multiplier);
});
$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
const translateString = t.join(', ');
const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`;
const scaleString = originalProgress < 0 ? `scale(${1 + (1 - data.scale) * originalProgress * multiplier})` : `scale(${1 - (1 - data.scale) * originalProgress * multiplier})`;
const opacityString = originalProgress < 0 ? 1 + (1 - data.opacity) * originalProgress * multiplier : 1 - (1 - data.opacity) * originalProgress * multiplier;
const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`; // Set shadows
if (custom && data.shadow || !custom) {
let $shadowEl = $slideEl.children('.swiper-slide-shadow');
if ($shadowEl.length === 0 && data.shadow) {
$shadowEl = createShadow(params, $slideEl);
}
if ($shadowEl.length) {
const shadowOpacity = params.shadowPerProgress ? progress * (1 / params.limitProgress) : progress;
$shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
}
}
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform).css({
opacity: opacityString
});
if (data.origin) {
$targetEl.css('transform-origin', data.origin);
}
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.creativeEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl,
allSlides: true
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.creativeEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl,
allSlides: true
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
function EffectCards(_ref) {
let {
swiper,
extendParams,
on
} = _ref;
extendParams({
cardsEffect: {
slideShadows: true,
transformEl: null,
rotate: true,
perSlideRotate: 2,
perSlideOffset: 8
}
});
const setTranslate = () => {
const {
slides,
activeIndex
} = swiper;
const params = swiper.params.cardsEffect;
const {
startTranslate,
isTouched
} = swiper.touchEventsData;
const currentTranslate = swiper.translate;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
const progress = Math.min(Math.max(slideProgress, -4), 4);
let offset = $slideEl[0].swiperSlideOffset;
if (swiper.params.centeredSlides && !swiper.params.cssMode) {
swiper.$wrapperEl.transform(`translateX(${swiper.minTranslate()}px)`);
}
if (swiper.params.centeredSlides && swiper.params.cssMode) {
offset -= slides[0].swiperSlideOffset;
}
let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
let tY = 0;
const tZ = -100 * Math.abs(progress);
let scale = 1;
let rotate = -params.perSlideRotate * progress;
let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
if (isSwipeToNext || isSwipeToPrev) {
const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
rotate += -28 * progress * subProgress;
scale += -0.5 * subProgress;
tXAdd += 96 * subProgress;
tY = `${-25 * subProgress * Math.abs(progress)}%`;
}
if (progress < 0) {
// next
tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
} else if (progress > 0) {
// prev
tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`;
} else {
tX = `${tX}px`;
}
if (!swiper.isHorizontal()) {
const prevY = tY;
tY = tX;
tX = prevY;
}
const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
const transform = `
translate3d(${tX}, ${tY}, ${tZ}px)
rotateZ(${params.rotate ? rotate : 0}deg)
scale(${scaleString})
`;
if (params.slideShadows) {
// Set shadows
let $shadowEl = $slideEl.find('.swiper-slide-shadow');
if ($shadowEl.length === 0) {
$shadowEl = createShadow(params, $slideEl);
}
if ($shadowEl.length) $shadowEl[0].style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
}
$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform);
}
};
const setTransition = duration => {
const {
transformEl
} = swiper.params.cardsEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl
});
};
effectInit({
effect: 'cards',
swiper,
on,
setTranslate,
setTransition,
perspective: () => true,
overwriteParams: () => ({
watchSlidesProgress: true,
virtualTranslate: !swiper.params.cssMode
})
});
} | Determines whether the `index` argument is a valid `number`
after being converted from the `string` type.
@type {boolean} | EffectCards | javascript | cabloy/cabloy | src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides,
activeIndex
} = swiper;
const params = swiper.params.cardsEffect;
const {
startTranslate,
isTouched
} = swiper.touchEventsData;
const currentTranslate = swiper.translate;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
const progress = Math.min(Math.max(slideProgress, -4), 4);
let offset = $slideEl[0].swiperSlideOffset;
if (swiper.params.centeredSlides && !swiper.params.cssMode) {
swiper.$wrapperEl.transform(`translateX(${swiper.minTranslate()}px)`);
}
if (swiper.params.centeredSlides && swiper.params.cssMode) {
offset -= slides[0].swiperSlideOffset;
}
let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
let tY = 0;
const tZ = -100 * Math.abs(progress);
let scale = 1;
let rotate = -params.perSlideRotate * progress;
let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
if (isSwipeToNext || isSwipeToPrev) {
const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
rotate += -28 * progress * subProgress;
scale += -0.5 * subProgress;
tXAdd += 96 * subProgress;
tY = `${-25 * subProgress * Math.abs(progress)}%`;
}
if (progress < 0) {
// next
tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
} else if (progress > 0) {
// prev
tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`;
} else {
tX = `${tX}px`;
}
if (!swiper.isHorizontal()) {
const prevY = tY;
tY = tX;
tX = prevY;
}
const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
const transform = `
translate3d(${tX}, ${tY}, ${tZ}px)
rotateZ(${params.rotate ? rotate : 0}deg)
scale(${scaleString})
`;
if (params.slideShadows) {
// Set shadows
let $shadowEl = $slideEl.find('.swiper-slide-shadow');
if ($shadowEl.length === 0) {
$shadowEl = createShadow(params, $slideEl);
}
if ($shadowEl.length) $shadowEl[0].style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
}
$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTranslate = () => {
const {
slides,
activeIndex
} = swiper;
const params = swiper.params.cardsEffect;
const {
startTranslate,
isTouched
} = swiper.touchEventsData;
const currentTranslate = swiper.translate;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
const progress = Math.min(Math.max(slideProgress, -4), 4);
let offset = $slideEl[0].swiperSlideOffset;
if (swiper.params.centeredSlides && !swiper.params.cssMode) {
swiper.$wrapperEl.transform(`translateX(${swiper.minTranslate()}px)`);
}
if (swiper.params.centeredSlides && swiper.params.cssMode) {
offset -= slides[0].swiperSlideOffset;
}
let tX = swiper.params.cssMode ? -offset - swiper.translate : -offset;
let tY = 0;
const tZ = -100 * Math.abs(progress);
let scale = 1;
let rotate = -params.perSlideRotate * progress;
let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;
const slideIndex = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
const isSwipeToNext = (slideIndex === activeIndex || slideIndex === activeIndex - 1) && progress > 0 && progress < 1 && (isTouched || swiper.params.cssMode) && currentTranslate < startTranslate;
const isSwipeToPrev = (slideIndex === activeIndex || slideIndex === activeIndex + 1) && progress < 0 && progress > -1 && (isTouched || swiper.params.cssMode) && currentTranslate > startTranslate;
if (isSwipeToNext || isSwipeToPrev) {
const subProgress = (1 - Math.abs((Math.abs(progress) - 0.5) / 0.5)) ** 0.5;
rotate += -28 * progress * subProgress;
scale += -0.5 * subProgress;
tXAdd += 96 * subProgress;
tY = `${-25 * subProgress * Math.abs(progress)}%`;
}
if (progress < 0) {
// next
tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
} else if (progress > 0) {
// prev
tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`;
} else {
tX = `${tX}px`;
}
if (!swiper.isHorizontal()) {
const prevY = tY;
tY = tX;
tX = prevY;
}
const scaleString = progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;
const transform = `
translate3d(${tX}, ${tY}, ${tZ}px)
rotateZ(${params.rotate ? rotate : 0}deg)
scale(${scaleString})
`;
if (params.slideShadows) {
// Set shadows
let $shadowEl = $slideEl.find('.swiper-slide-shadow');
if ($shadowEl.length === 0) {
$shadowEl = createShadow(params, $slideEl);
}
if ($shadowEl.length) $shadowEl[0].style.opacity = Math.min(Math.max((Math.abs(progress) - 0.5) / 0.5, 0), 1);
}
$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
const $targetEl = effectTarget(params, $slideEl);
$targetEl.transform(transform);
}
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.cardsEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
setTransition = duration => {
const {
transformEl
} = swiper.params.cardsEffect;
const $transitionElements = transformEl ? swiper.slides.find(transformEl) : swiper.slides;
$transitionElements.transition(duration).find('.swiper-slide-shadow').transition(duration);
effectVirtualTransitionEnd({
swiper,
duration,
transformEl
});
} | 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.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/a-swiper/dist/staticBackend/vendor/swiper/8.4.5/swiper-bundle.js | MIT |
notTextOrCommentNode = function notTextOrCommentNode () {
return this.nodeType !== 3 && this.nodeType !== 8;
} | handles the actual loading of a node. Used only internally.
@private
@name _load_node(obj [, callback])
@param {mixed} obj
@param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status
@return {Boolean} | notTextOrCommentNode | javascript | cabloy/cabloy | src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | MIT |
func = function (data, undefined) {
if(data.data) { data = data.data; }
var dat = data.dat,
par = data.par,
chd = [],
dpc = [],
add = [],
df = data.df,
t_id = data.t_id,
t_cnt = data.t_cnt,
m = data.m,
p = m[par],
sel = data.sel,
tmp, i, j, rslt,
parse_flat = function (d, p, ps) {
if(!ps) { ps = []; }
else { ps = ps.concat(); }
if(p) { ps.unshift(p); }
var tid = d.id.toString(),
i, j, c, e,
tmp = {
id : tid,
text : d.text || '',
icon : d.icon !== undefined ? d.icon : true,
parent : p,
parents : ps,
children : d.children || [],
children_d : d.children_d || [],
data : d.data,
state : { },
li_attr : { id : false },
a_attr : { href : '#' },
original : false
};
for(i in df) {
if(df.hasOwnProperty(i)) {
tmp.state[i] = df[i];
}
}
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
tmp.icon = d.data.jstree.icon;
}
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
tmp.icon = true;
}
if(d && d.data) {
tmp.data = d.data;
if(d.data.jstree) {
for(i in d.data.jstree) {
if(d.data.jstree.hasOwnProperty(i)) {
tmp.state[i] = d.data.jstree[i];
}
}
}
}
if(d && typeof d.state === 'object') {
for (i in d.state) {
if(d.state.hasOwnProperty(i)) {
tmp.state[i] = d.state[i];
}
}
}
if(d && typeof d.li_attr === 'object') {
for (i in d.li_attr) {
if(d.li_attr.hasOwnProperty(i)) {
tmp.li_attr[i] = d.li_attr[i];
}
}
}
if(!tmp.li_attr.id) {
tmp.li_attr.id = tid;
}
if(d && typeof d.a_attr === 'object') {
for (i in d.a_attr) {
if(d.a_attr.hasOwnProperty(i)) {
tmp.a_attr[i] = d.a_attr[i];
}
}
}
if(d && d.children && d.children === true) {
tmp.state.loaded = false;
tmp.children = [];
tmp.children_d = [];
}
m[tmp.id] = tmp;
for(i = 0, j = tmp.children.length; i < j; i++) {
c = parse_flat(m[tmp.children[i]], tmp.id, ps);
e = m[c];
tmp.children_d.push(c);
if(e.children_d.length) {
tmp.children_d = tmp.children_d.concat(e.children_d);
}
}
delete d.data;
delete d.children;
m[tmp.id].original = d;
if(tmp.state.selected) {
add.push(tmp.id);
}
return tmp.id;
},
parse_nest = function (d, p, ps) {
if(!ps) { ps = []; }
else { ps = ps.concat(); }
if(p) { ps.unshift(p); }
var tid = false, i, j, c, e, tmp;
do {
tid = 'j' + t_id + '_' + (++t_cnt);
} while(m[tid]);
tmp = {
id : false,
text : typeof d === 'string' ? d : '',
icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
parent : p,
parents : ps,
children : [],
children_d : [],
data : null,
state : { },
li_attr : { id : false },
a_attr : { href : '#' },
original : false
};
for(i in df) {
if(df.hasOwnProperty(i)) {
tmp.state[i] = df[i];
}
}
if(d && d.id) { tmp.id = d.id.toString(); }
if(d && d.text) { tmp.text = d.text; }
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
tmp.icon = d.data.jstree.icon;
}
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
tmp.icon = true;
}
if(d && d.data) {
tmp.data = d.data;
if(d.data.jstree) {
for(i in d.data.jstree) {
if(d.data.jstree.hasOwnProperty(i)) {
tmp.state[i] = d.data.jstree[i];
}
}
}
}
if(d && typeof d.state === 'object') {
for (i in d.state) {
if(d.state.hasOwnProperty(i)) {
tmp.state[i] = d.state[i];
}
}
}
if(d && typeof d.li_attr === 'object') {
for (i in d.li_attr) {
if(d.li_attr.hasOwnProperty(i)) {
tmp.li_attr[i] = d.li_attr[i];
}
}
}
if(tmp.li_attr.id && !tmp.id) {
tmp.id = tmp.li_attr.id.toString();
}
if(!tmp.id) {
tmp.id = tid;
}
if(!tmp.li_attr.id) {
tmp.li_attr.id = tmp.id;
}
if(d && typeof d.a_attr === 'object') {
for (i in d.a_attr) {
if(d.a_attr.hasOwnProperty(i)) {
tmp.a_attr[i] = d.a_attr[i];
}
}
}
if(d && d.children && d.children.length) {
for(i = 0, j = d.children.length; i < j; i++) {
c = parse_nest(d.children[i], tmp.id, ps);
e = m[c];
tmp.children.push(c);
if(e.children_d.length) {
tmp.children_d = tmp.children_d.concat(e.children_d);
}
}
tmp.children_d = tmp.children_d.concat(tmp.children);
}
if(d && d.children && d.children === true) {
tmp.state.loaded = false;
tmp.children = [];
tmp.children_d = [];
}
delete d.data;
delete d.children;
tmp.original = d;
m[tmp.id] = tmp;
if(tmp.state.selected) {
add.push(tmp.id);
}
return tmp.id;
};
if(dat.length && dat[0].id !== undefined && dat[0].parent !== undefined) {
// Flat JSON support (for easy import from DB):
// 1) convert to object (foreach)
for(i = 0, j = dat.length; i < j; i++) {
if(!dat[i].children) {
dat[i].children = [];
}
if(!dat[i].state) {
dat[i].state = {};
}
m[dat[i].id.toString()] = dat[i];
}
// 2) populate children (foreach)
for(i = 0, j = dat.length; i < j; i++) {
if (!m[dat[i].parent.toString()]) {
if (typeof inst !== "undefined") {
inst._data.core.last_error = { 'error' : 'parse', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Node with invalid parent', 'data' : JSON.stringify({ 'id' : dat[i].id.toString(), 'parent' : dat[i].parent.toString() }) };
inst.settings.core.error.call(inst, inst._data.core.last_error);
}
continue;
}
m[dat[i].parent.toString()].children.push(dat[i].id.toString());
// populate parent.children_d
p.children_d.push(dat[i].id.toString());
}
// 3) normalize && populate parents and children_d with recursion
for(i = 0, j = p.children.length; i < j; i++) {
tmp = parse_flat(m[p.children[i]], par, p.parents.concat());
dpc.push(tmp);
if(m[tmp].children_d.length) {
dpc = dpc.concat(m[tmp].children_d);
}
}
for(i = 0, j = p.parents.length; i < j; i++) {
m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
}
// ?) three_state selection - p.state.selected && t - (if three_state foreach(dat => ch) -> foreach(parents) if(parent.selected) child.selected = true;
rslt = {
'cnt' : t_cnt,
'mod' : m,
'sel' : sel,
'par' : par,
'dpc' : dpc,
'add' : add
};
}
else {
for(i = 0, j = dat.length; i < j; i++) {
tmp = parse_nest(dat[i], par, p.parents.concat());
if(tmp) {
chd.push(tmp);
dpc.push(tmp);
if(m[tmp].children_d.length) {
dpc = dpc.concat(m[tmp].children_d);
}
}
}
p.children = chd;
p.children_d = dpc;
for(i = 0, j = p.parents.length; i < j; i++) {
m[p.parents[i]].children_d = m[p.parents[i]].children_d.concat(dpc);
}
rslt = {
'cnt' : t_cnt,
'mod' : m,
'sel' : sel,
'par' : par,
'dpc' : dpc,
'add' : add
};
}
if(typeof window === 'undefined' || typeof window.document === 'undefined') {
postMessage(rslt);
}
else {
return rslt;
}
} | appends JSON content to the tree. Used internally.
@private
@name _append_json_data(obj, data)
@param {mixed} obj the node to append to
@param {String} data the JSON object to parse and append
@param {Boolean} force_processing internal param - do not set
@trigger model.jstree, changed.jstree | func | javascript | cabloy/cabloy | src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | MIT |
parse_flat = function (d, p, ps) {
if(!ps) { ps = []; }
else { ps = ps.concat(); }
if(p) { ps.unshift(p); }
var tid = d.id.toString(),
i, j, c, e,
tmp = {
id : tid,
text : d.text || '',
icon : d.icon !== undefined ? d.icon : true,
parent : p,
parents : ps,
children : d.children || [],
children_d : d.children_d || [],
data : d.data,
state : { },
li_attr : { id : false },
a_attr : { href : '#' },
original : false
};
for(i in df) {
if(df.hasOwnProperty(i)) {
tmp.state[i] = df[i];
}
}
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
tmp.icon = d.data.jstree.icon;
}
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
tmp.icon = true;
}
if(d && d.data) {
tmp.data = d.data;
if(d.data.jstree) {
for(i in d.data.jstree) {
if(d.data.jstree.hasOwnProperty(i)) {
tmp.state[i] = d.data.jstree[i];
}
}
}
}
if(d && typeof d.state === 'object') {
for (i in d.state) {
if(d.state.hasOwnProperty(i)) {
tmp.state[i] = d.state[i];
}
}
}
if(d && typeof d.li_attr === 'object') {
for (i in d.li_attr) {
if(d.li_attr.hasOwnProperty(i)) {
tmp.li_attr[i] = d.li_attr[i];
}
}
}
if(!tmp.li_attr.id) {
tmp.li_attr.id = tid;
}
if(d && typeof d.a_attr === 'object') {
for (i in d.a_attr) {
if(d.a_attr.hasOwnProperty(i)) {
tmp.a_attr[i] = d.a_attr[i];
}
}
}
if(d && d.children && d.children === true) {
tmp.state.loaded = false;
tmp.children = [];
tmp.children_d = [];
}
m[tmp.id] = tmp;
for(i = 0, j = tmp.children.length; i < j; i++) {
c = parse_flat(m[tmp.children[i]], tmp.id, ps);
e = m[c];
tmp.children_d.push(c);
if(e.children_d.length) {
tmp.children_d = tmp.children_d.concat(e.children_d);
}
}
delete d.data;
delete d.children;
m[tmp.id].original = d;
if(tmp.state.selected) {
add.push(tmp.id);
}
return tmp.id;
} | appends JSON content to the tree. Used internally.
@private
@name _append_json_data(obj, data)
@param {mixed} obj the node to append to
@param {String} data the JSON object to parse and append
@param {Boolean} force_processing internal param - do not set
@trigger model.jstree, changed.jstree | parse_flat | javascript | cabloy/cabloy | src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | MIT |
parse_nest = function (d, p, ps) {
if(!ps) { ps = []; }
else { ps = ps.concat(); }
if(p) { ps.unshift(p); }
var tid = false, i, j, c, e, tmp;
do {
tid = 'j' + t_id + '_' + (++t_cnt);
} while(m[tid]);
tmp = {
id : false,
text : typeof d === 'string' ? d : '',
icon : typeof d === 'object' && d.icon !== undefined ? d.icon : true,
parent : p,
parents : ps,
children : [],
children_d : [],
data : null,
state : { },
li_attr : { id : false },
a_attr : { href : '#' },
original : false
};
for(i in df) {
if(df.hasOwnProperty(i)) {
tmp.state[i] = df[i];
}
}
if(d && d.id) { tmp.id = d.id.toString(); }
if(d && d.text) { tmp.text = d.text; }
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
tmp.icon = d.data.jstree.icon;
}
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
tmp.icon = true;
}
if(d && d.data) {
tmp.data = d.data;
if(d.data.jstree) {
for(i in d.data.jstree) {
if(d.data.jstree.hasOwnProperty(i)) {
tmp.state[i] = d.data.jstree[i];
}
}
}
}
if(d && typeof d.state === 'object') {
for (i in d.state) {
if(d.state.hasOwnProperty(i)) {
tmp.state[i] = d.state[i];
}
}
}
if(d && typeof d.li_attr === 'object') {
for (i in d.li_attr) {
if(d.li_attr.hasOwnProperty(i)) {
tmp.li_attr[i] = d.li_attr[i];
}
}
}
if(tmp.li_attr.id && !tmp.id) {
tmp.id = tmp.li_attr.id.toString();
}
if(!tmp.id) {
tmp.id = tid;
}
if(!tmp.li_attr.id) {
tmp.li_attr.id = tmp.id;
}
if(d && typeof d.a_attr === 'object') {
for (i in d.a_attr) {
if(d.a_attr.hasOwnProperty(i)) {
tmp.a_attr[i] = d.a_attr[i];
}
}
}
if(d && d.children && d.children.length) {
for(i = 0, j = d.children.length; i < j; i++) {
c = parse_nest(d.children[i], tmp.id, ps);
e = m[c];
tmp.children.push(c);
if(e.children_d.length) {
tmp.children_d = tmp.children_d.concat(e.children_d);
}
}
tmp.children_d = tmp.children_d.concat(tmp.children);
}
if(d && d.children && d.children === true) {
tmp.state.loaded = false;
tmp.children = [];
tmp.children_d = [];
}
delete d.data;
delete d.children;
tmp.original = d;
m[tmp.id] = tmp;
if(tmp.state.selected) {
add.push(tmp.id);
}
return tmp.id;
} | appends JSON content to the tree. Used internally.
@private
@name _append_json_data(obj, data)
@param {mixed} obj the node to append to
@param {String} data the JSON object to parse and append
@param {Boolean} force_processing internal param - do not set
@trigger model.jstree, changed.jstree | parse_nest | javascript | cabloy/cabloy | src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | MIT |
rslt = function (rslt, worker) {
if(this.element === null) { return; }
this._cnt = rslt.cnt;
var i, m = this._model.data;
for (i in m) {
if (m.hasOwnProperty(i) && m[i].state && m[i].state.loading && rslt.mod[i]) {
rslt.mod[i].state.loading = true;
}
}
this._model.data = rslt.mod; // breaks the reference in load_node - careful
if(worker) {
var j, a = rslt.add, r = rslt.sel, s = this._data.core.selected.slice();
m = this._model.data;
// if selection was changed while calculating in worker
if(r.length !== s.length || $.vakata.array_unique(r.concat(s)).length !== r.length) {
// deselect nodes that are no longer selected
for(i = 0, j = r.length; i < j; i++) {
if($.inArray(r[i], a) === -1 && $.inArray(r[i], s) === -1) {
m[r[i]].state.selected = false;
}
}
// select nodes that were selected in the mean time
for(i = 0, j = s.length; i < j; i++) {
if($.inArray(s[i], r) === -1) {
m[s[i]].state.selected = true;
}
}
}
}
if(rslt.add.length) {
this._data.core.selected = this._data.core.selected.concat(rslt.add);
}
this.trigger('model', { "nodes" : rslt.dpc, 'parent' : rslt.par });
if(rslt.par !== $.jstree.root) {
this._node_changed(rslt.par);
this.redraw();
}
else {
// this.get_container_ul().children('.jstree-initial-node').remove();
this.redraw(true);
}
if(rslt.add.length) {
this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected });
}
// If no worker, try to mimic worker behavioour, by invoking cb asynchronously
if (!worker && setImmediate) {
setImmediate(function(){
cb.call(inst, true);
});
}
else {
cb.call(inst, true);
}
} | appends JSON content to the tree. Used internally.
@private
@name _append_json_data(obj, data)
@param {mixed} obj the node to append to
@param {String} data the JSON object to parse and append
@param {Boolean} force_processing internal param - do not set
@trigger model.jstree, changed.jstree | rslt | javascript | cabloy/cabloy | src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | https://github.com/cabloy/cabloy/blob/master/src/module-system/cms-themedocs/backend/cms/theme/assets/lib/tree/jstree.js | MIT |
function toBeInstanceOf(actual, expected) {
if (!(actual instanceof expected)) {
throw new AssertionError({
message: 'Expected value to be instance:',
operator: 'instanceOf',
actual,
expected,
stackStartFn: toBeInstanceOf,
})
}
} | Tests that the actual object is an instance of the expected class. | toBeInstanceOf | javascript | stitchesjs/stitches | .task/internal/expect.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/expect.js | MIT |
function toNotBeInstanceOf(actual, expected) {
if (actual instanceof expected) {
throw new AssertionError({
message: 'Expected value to be instance:',
operator: 'instanceOf',
actual,
expected,
stackStartFn: toNotBeInstanceOf,
})
}
} | Tests that the actual object is not an instance of the expected class. | toNotBeInstanceOf | javascript | stitchesjs/stitches | .task/internal/expect.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/expect.js | MIT |
async function toThrow(actualFunction, expected) {
let actual = undefined
try {
actual = await actualFunction()
} catch (error) {
// do nothing and continue
return
}
throw new AssertionError({
message: 'Expected exception:',
operator: 'throws',
stackStartFn: toThrow,
actual,
expected,
})
} | Tests that the actual function does throw when it is called. | toThrow | javascript | stitchesjs/stitches | .task/internal/expect.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/expect.js | MIT |
async function toNotThrow(actualFunction, expected) {
let actual = undefined
try {
actual = await actualFunction()
// do nothing and continue
return
} catch (error) {
throw new AssertionError({
message: 'Unexpected exception:',
operator: 'doesNotThrow',
stackStartFn: toThrow,
actual,
expected,
})
}
} | Tests that the actual function does not throw when it is called. | toNotThrow | javascript | stitchesjs/stitches | .task/internal/expect.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/expect.js | MIT |
copydir = async function copydir(src, dst) {
let copydir = async (src, dst) => {
await mkdir(dst, { recursive: true })
for (const dirent of await readdir(src, { withFileTypes: true })) {
await (dirent.isDirectory() ? copydir : copyFile)(
src.dir.to(dirent.name),
dst.dir.to(dirent.name)
)
}
}
copydir(URL.from(src), URL.from(dst))
} | Asynchronously copies dir to dest. By default, dest is overwritten if it already exists. | copydir | javascript | stitchesjs/stitches | .task/internal/fs.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/fs.js | MIT |
copydir = async function copydir(src, dst) {
let copydir = async (src, dst) => {
await mkdir(dst, { recursive: true })
for (const dirent of await readdir(src, { withFileTypes: true })) {
await (dirent.isDirectory() ? copydir : copyFile)(
src.dir.to(dirent.name),
dst.dir.to(dirent.name)
)
}
}
copydir(URL.from(src), URL.from(dst))
} | Asynchronously copies dir to dest. By default, dest is overwritten if it already exists. | copydir | javascript | stitchesjs/stitches | .task/internal/fs.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/fs.js | MIT |
copydir = async (src, dst) => {
await mkdir(dst, { recursive: true })
for (const dirent of await readdir(src, { withFileTypes: true })) {
await (dirent.isDirectory() ? copydir : copyFile)(
src.dir.to(dirent.name),
dst.dir.to(dirent.name)
)
}
} | Asynchronously copies dir to dest. By default, dest is overwritten if it already exists. | copydir | javascript | stitchesjs/stitches | .task/internal/fs.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/fs.js | MIT |
copydir = async (src, dst) => {
await mkdir(dst, { recursive: true })
for (const dirent of await readdir(src, { withFileTypes: true })) {
await (dirent.isDirectory() ? copydir : copyFile)(
src.dir.to(dirent.name),
dst.dir.to(dirent.name)
)
}
} | Asynchronously copies dir to dest. By default, dest is overwritten if it already exists. | copydir | javascript | stitchesjs/stitches | .task/internal/fs.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/fs.js | MIT |
async readFileJson(/** @type {import('fs').PathLike | fs.FileHandle} */ path) {
const json = await fs.readFile(path, 'utf8')
/** @type {JSONValue} */
const data = JSON.parse(json)
return data
} | Asynchronously reads a file as parsed JSON. | readFileJson | javascript | stitchesjs/stitches | .task/internal/fs.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/fs.js | MIT |
getProcessArgOf = (name) => {
const lead = argv.indexOf('--' + name) + 1
const tail = lead ? argv.slice(lead).findIndex((arg) => arg.startsWith('--')) : 0
const vals = lead ? argv.slice(lead, ~tail ? lead + tail : argv.length) : []
return lead ? (vals.length ? vals : [true]) : vals
} | Returns the values for a given process argument. | getProcessArgOf | javascript | stitchesjs/stitches | .task/internal/process.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/process.js | MIT |
getProcessArgOf = (name) => {
const lead = argv.indexOf('--' + name) + 1
const tail = lead ? argv.slice(lead).findIndex((arg) => arg.startsWith('--')) : 0
const vals = lead ? argv.slice(lead, ~tail ? lead + tail : argv.length) : []
return lead ? (vals.length ? vals : [true]) : vals
} | Returns the values for a given process argument. | getProcessArgOf | javascript | stitchesjs/stitches | .task/internal/process.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/process.js | MIT |
question = (
/** @type {string} */ query,
/** @type {import('events').Abortable} */
opts = undefined
) => new Promise(resolver => {
query = String(query).replace(/[^\s]$/, '$& ')
opts = Object(opts)
const int = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
int.question(query, opts, answer => {
int.close()
resolver(answer)
})
}) | Displays the query, awaits user input, and returns the provided input. | question | javascript | stitchesjs/stitches | .task/internal/readline.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/readline.js | MIT |
question = (
/** @type {string} */ query,
/** @type {import('events').Abortable} */
opts = undefined
) => new Promise(resolver => {
query = String(query).replace(/[^\s]$/, '$& ')
opts = Object(opts)
const int = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
int.question(query, opts, answer => {
int.close()
resolver(answer)
})
}) | Displays the query, awaits user input, and returns the provided input. | question | javascript | stitchesjs/stitches | .task/internal/readline.js | https://github.com/stitchesjs/stitches/blob/master/.task/internal/readline.js | MIT |
toString = () => {
const { cssRules } = groupSheet.sheet
return [].map
.call(cssRules, (cssRule, cssRuleIndex) => {
const { cssText } = cssRule
let lastRuleCssText = ''
if (cssText.startsWith('--sxs')) return ''
if (cssRules[cssRuleIndex - 1] && (lastRuleCssText = cssRules[cssRuleIndex - 1].cssText).startsWith('--sxs')) {
if (!cssRule.cssRules.length) return ''
for (const name in groupSheet.rules) {
if (groupSheet.rules[name].group === cssRule) {
return `--sxs{--sxs:${[...groupSheet.rules[name].cache].join(' ')}}${cssText}`
}
}
return cssRule.cssRules.length ? `${lastRuleCssText}${cssText}` : ''
}
return cssText
})
.join('')
} | @type {SheetGroup} Object hosting the hydrated stylesheet. | toString | javascript | stitchesjs/stitches | packages/core/src/sheet.js | https://github.com/stitchesjs/stitches/blob/master/packages/core/src/sheet.js | MIT |
toString = () => {
const { cssRules } = groupSheet.sheet
return [].map
.call(cssRules, (cssRule, cssRuleIndex) => {
const { cssText } = cssRule
let lastRuleCssText = ''
if (cssText.startsWith('--sxs')) return ''
if (cssRules[cssRuleIndex - 1] && (lastRuleCssText = cssRules[cssRuleIndex - 1].cssText).startsWith('--sxs')) {
if (!cssRule.cssRules.length) return ''
for (const name in groupSheet.rules) {
if (groupSheet.rules[name].group === cssRule) {
return `--sxs{--sxs:${[...groupSheet.rules[name].cache].join(' ')}}${cssText}`
}
}
return cssRule.cssRules.length ? `${lastRuleCssText}${cssText}` : ''
}
return cssText
})
.join('')
} | @type {SheetGroup} Object hosting the hydrated stylesheet. | toString | javascript | stitchesjs/stitches | packages/core/src/sheet.js | https://github.com/stitchesjs/stitches/blob/master/packages/core/src/sheet.js | MIT |
reset = () => {
if (groupSheet) {
const { rules, sheet } = groupSheet
if (!sheet.deleteRule) {
while (Object(Object(sheet.cssRules)[0]).type === 3) sheet.cssRules.splice(0, 1)
sheet.cssRules = []
}
for (const groupName in rules) {
delete rules[groupName]
}
}
/** @type {StyleSheetList} */
const sheets = Object(root).styleSheets || []
// iterate all stylesheets until a hydratable stylesheet is found
for (const sheet of sheets) {
if (!isSheetAccessible(sheet)) continue
for (let index = 0, rules = sheet.cssRules; rules[index]; ++index) {
/** @type {CSSStyleRule} Possible indicator rule. */
const check = Object(rules[index])
// a hydratable set of rules will start with a style rule (type: 1), ignore all others
if (check.type !== 1) continue
/** @type {CSSMediaRule} Possible styling group. */
const group = Object(rules[index + 1])
// a hydratable set of rules will follow with a media rule (type: 4), ignore all others
if (group.type !== 4) continue
++index
const { cssText } = check
// a hydratable style rule will have a selector of `--sxs`, ignore all others
if (!cssText.startsWith('--sxs')) continue
const cache = cssText.slice(14, -3).trim().split(/\s+/)
/** @type {GroupName} Name of the group. */
const groupName = names[cache[0]]
// a hydratable style rule will have a parsable group, ignore all others
if (!groupName) continue
// create a group sheet if one does not already exist
if (!groupSheet) groupSheet = { sheet, reset, rules: {}, toString }
// add the group to the group sheet
groupSheet.rules[groupName] = { group, index, cache: new Set(cache) }
}
// if a hydratable stylesheet is found, stop looking
if (groupSheet) break
}
// if no hydratable stylesheet is found
if (!groupSheet) {
const createCSSMediaRule = (/** @type {string} */ sourceCssText, type) => {
return /** @type {CSSMediaRule} */ ({
type,
cssRules: [],
insertRule(cssText, index) {
this.cssRules.splice(index, 0, createCSSMediaRule(cssText, {
import: 3,
undefined: 1
}[(cssText.toLowerCase().match(/^@([a-z]+)/) || [])[1]] || 4))
},
get cssText() {
return sourceCssText === '@media{}' ? `@media{${[].map.call(this.cssRules, (cssRule) => cssRule.cssText).join('')}}` : sourceCssText
},
})
}
const createSheet = () => {
if (!root) {
return createCSSMediaRule('', 'text/css')
}
const styleEl = document.createElement('style')
const nonce = getNonce()
if (nonce) {
styleEl.setAttribute('nonce', nonce)
}
return (root.head || root).appendChild(styleEl).sheet
}
groupSheet = {
sheet: createSheet(),
rules: {},
reset,
toString,
}
}
const { sheet, rules } = groupSheet
for (let i = names.length - 1; i >= 0; --i) {
// name of group on current index
const name = names[i]
if (!rules[name]) {
// name of prev group
const prevName = names[i + 1]
// get the index of that prev group or else get the length of the whole sheet
const index = rules[prevName] ? rules[prevName].index : sheet.cssRules.length
// insert the grouping & the sxs rule
sheet.insertRule('@media{}', index)
sheet.insertRule(`--sxs{--sxs:${i}}`, index)
// add the group to the group sheet
rules[name] = { group: sheet.cssRules[index + 1], index, cache: new Set([i]) }
}
addApplyToGroup(rules[name])
}
} | @type {SheetGroup} Object hosting the hydrated stylesheet. | reset | javascript | stitchesjs/stitches | packages/core/src/sheet.js | https://github.com/stitchesjs/stitches/blob/master/packages/core/src/sheet.js | MIT |
reset = () => {
if (groupSheet) {
const { rules, sheet } = groupSheet
if (!sheet.deleteRule) {
while (Object(Object(sheet.cssRules)[0]).type === 3) sheet.cssRules.splice(0, 1)
sheet.cssRules = []
}
for (const groupName in rules) {
delete rules[groupName]
}
}
/** @type {StyleSheetList} */
const sheets = Object(root).styleSheets || []
// iterate all stylesheets until a hydratable stylesheet is found
for (const sheet of sheets) {
if (!isSheetAccessible(sheet)) continue
for (let index = 0, rules = sheet.cssRules; rules[index]; ++index) {
/** @type {CSSStyleRule} Possible indicator rule. */
const check = Object(rules[index])
// a hydratable set of rules will start with a style rule (type: 1), ignore all others
if (check.type !== 1) continue
/** @type {CSSMediaRule} Possible styling group. */
const group = Object(rules[index + 1])
// a hydratable set of rules will follow with a media rule (type: 4), ignore all others
if (group.type !== 4) continue
++index
const { cssText } = check
// a hydratable style rule will have a selector of `--sxs`, ignore all others
if (!cssText.startsWith('--sxs')) continue
const cache = cssText.slice(14, -3).trim().split(/\s+/)
/** @type {GroupName} Name of the group. */
const groupName = names[cache[0]]
// a hydratable style rule will have a parsable group, ignore all others
if (!groupName) continue
// create a group sheet if one does not already exist
if (!groupSheet) groupSheet = { sheet, reset, rules: {}, toString }
// add the group to the group sheet
groupSheet.rules[groupName] = { group, index, cache: new Set(cache) }
}
// if a hydratable stylesheet is found, stop looking
if (groupSheet) break
}
// if no hydratable stylesheet is found
if (!groupSheet) {
const createCSSMediaRule = (/** @type {string} */ sourceCssText, type) => {
return /** @type {CSSMediaRule} */ ({
type,
cssRules: [],
insertRule(cssText, index) {
this.cssRules.splice(index, 0, createCSSMediaRule(cssText, {
import: 3,
undefined: 1
}[(cssText.toLowerCase().match(/^@([a-z]+)/) || [])[1]] || 4))
},
get cssText() {
return sourceCssText === '@media{}' ? `@media{${[].map.call(this.cssRules, (cssRule) => cssRule.cssText).join('')}}` : sourceCssText
},
})
}
const createSheet = () => {
if (!root) {
return createCSSMediaRule('', 'text/css')
}
const styleEl = document.createElement('style')
const nonce = getNonce()
if (nonce) {
styleEl.setAttribute('nonce', nonce)
}
return (root.head || root).appendChild(styleEl).sheet
}
groupSheet = {
sheet: createSheet(),
rules: {},
reset,
toString,
}
}
const { sheet, rules } = groupSheet
for (let i = names.length - 1; i >= 0; --i) {
// name of group on current index
const name = names[i]
if (!rules[name]) {
// name of prev group
const prevName = names[i + 1]
// get the index of that prev group or else get the length of the whole sheet
const index = rules[prevName] ? rules[prevName].index : sheet.cssRules.length
// insert the grouping & the sxs rule
sheet.insertRule('@media{}', index)
sheet.insertRule(`--sxs{--sxs:${i}}`, index)
// add the group to the group sheet
rules[name] = { group: sheet.cssRules[index + 1], index, cache: new Set([i]) }
}
addApplyToGroup(rules[name])
}
} | @type {SheetGroup} Object hosting the hydrated stylesheet. | reset | javascript | stitchesjs/stitches | packages/core/src/sheet.js | https://github.com/stitchesjs/stitches/blob/master/packages/core/src/sheet.js | MIT |
createCSSMediaRule = (/** @type {string} */ sourceCssText, type) => {
return /** @type {CSSMediaRule} */ ({
type,
cssRules: [],
insertRule(cssText, index) {
this.cssRules.splice(index, 0, createCSSMediaRule(cssText, {
import: 3,
undefined: 1
}[(cssText.toLowerCase().match(/^@([a-z]+)/) || [])[1]] || 4))
},
get cssText() {
return sourceCssText === '@media{}' ? `@media{${[].map.call(this.cssRules, (cssRule) => cssRule.cssText).join('')}}` : sourceCssText
},
})
} | @type {GroupName} Name of the group. | createCSSMediaRule | javascript | stitchesjs/stitches | packages/core/src/sheet.js | https://github.com/stitchesjs/stitches/blob/master/packages/core/src/sheet.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.