feat: Add comprehensive documentation suite and reorganize project structure
- Created complete documentation in docs/ directory - Added PROJECT_OVERVIEW.md with feature highlights and getting started guide - Added ARCHITECTURE.md with system design and technical details - Added SECURITY.md with comprehensive security implementation guide - Added DEVELOPMENT.md with development workflows and best practices - Added DEPLOYMENT.md with production deployment instructions - Added API.md with complete REST API documentation - Added CONTRIBUTING.md with contribution guidelines - Added CHANGELOG.md with version history and migration notes - Reorganized all documentation files into docs/ directory for better organization - Updated README.md with proper documentation links and quick navigation - Enhanced project structure with professional documentation standards
This commit is contained in:
38
f_scripts/shared/swiper/react/virtual.js
Normal file
38
f_scripts/shared/swiper/react/virtual.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
function renderVirtual(swiper, slides, virtualData) {
|
||||
if (!virtualData) return null;
|
||||
const getSlideIndex = index => {
|
||||
let slideIndex = index;
|
||||
if (index < 0) {
|
||||
slideIndex = slides.length + index;
|
||||
} else if (slideIndex >= slides.length) {
|
||||
// eslint-disable-next-line
|
||||
slideIndex = slideIndex - slides.length;
|
||||
}
|
||||
return slideIndex;
|
||||
};
|
||||
const style = swiper.isHorizontal() ? {
|
||||
[swiper.rtlTranslate ? 'right' : 'left']: `${virtualData.offset}px`
|
||||
} : {
|
||||
top: `${virtualData.offset}px`
|
||||
};
|
||||
const {
|
||||
from,
|
||||
to
|
||||
} = virtualData;
|
||||
const loopFrom = swiper.params.loop ? -slides.length : 0;
|
||||
const loopTo = swiper.params.loop ? slides.length * 2 : slides.length;
|
||||
const slidesToRender = [];
|
||||
for (let i = loopFrom; i < loopTo; i += 1) {
|
||||
if (i >= from && i <= to) {
|
||||
slidesToRender.push(slides[getSlideIndex(i)]);
|
||||
}
|
||||
}
|
||||
return slidesToRender.map(child => {
|
||||
return /*#__PURE__*/React.cloneElement(child, {
|
||||
swiper,
|
||||
style
|
||||
});
|
||||
});
|
||||
}
|
||||
export { renderVirtual };
|
||||
Reference in New Issue
Block a user