UNPKG

988 BJavaScriptView Raw
1import React from 'react';
2
3function updateOnVirtualData(swiper) {
4 if (!swiper || swiper.destroyed || !swiper.params.virtual || swiper.params.virtual && !swiper.params.virtual.enabled) return;
5 swiper.updateSlides();
6 swiper.updateProgress();
7 swiper.updateSlidesClasses();
8
9 if (swiper.lazy && swiper.params.lazy.enabled) {
10 swiper.lazy.load();
11 }
12
13 if (swiper.parallax && swiper.params.parallax && swiper.params.parallax.enabled) {
14 swiper.parallax.setTranslate();
15 }
16}
17
18function renderVirtual(swiper, slides, virtualData) {
19 if (!virtualData) return null;
20 const style = swiper.isHorizontal() ? {
21 [swiper.rtlTranslate ? 'right' : 'left']: `${virtualData.offset}px`
22 } : {
23 top: `${virtualData.offset}px`
24 };
25 return slides.filter((child, index) => index >= virtualData.from && index <= virtualData.to).map(child => {
26 return /*#__PURE__*/React.cloneElement(child, {
27 swiper,
28 style
29 });
30 });
31}
32
33export { renderVirtual, updateOnVirtualData };
\No newline at end of file