Initial release
Some checks failed
My Build All / build_windows (push) Has been cancelled
My Build All / build_linux_portable (push) Has been cancelled
My Build All / build_linux_appimage (push) Has been cancelled
My Build All / build_macos (push) Has been cancelled
My Build All / Publish release assets (push) Has been cancelled
Shellcheck / Shellcheck (push) Has been cancelled
Some checks failed
My Build All / build_windows (push) Has been cancelled
My Build All / build_linux_portable (push) Has been cancelled
My Build All / build_linux_appimage (push) Has been cancelled
My Build All / build_macos (push) Has been cancelled
My Build All / Publish release assets (push) Has been cancelled
Shellcheck / Shellcheck (push) Has been cancelled
This commit is contained in:
commit
c661ddc2eb
16967 changed files with 4075897 additions and 0 deletions
46
resources/web/guide/swiper/react/get-children.js
Normal file
46
resources/web/guide/swiper/react/get-children.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import React from 'react';
|
||||
|
||||
function processChildren(c) {
|
||||
const slides = [];
|
||||
React.Children.toArray(c).forEach(child => {
|
||||
if (child.type && child.type.displayName === 'SwiperSlide') {
|
||||
slides.push(child);
|
||||
} else if (child.props && child.props.children) {
|
||||
processChildren(child.props.children).forEach(slide => slides.push(slide));
|
||||
}
|
||||
});
|
||||
return slides;
|
||||
}
|
||||
|
||||
function getChildren(c) {
|
||||
const slides = [];
|
||||
const slots = {
|
||||
'container-start': [],
|
||||
'container-end': [],
|
||||
'wrapper-start': [],
|
||||
'wrapper-end': []
|
||||
};
|
||||
React.Children.toArray(c).forEach(child => {
|
||||
if (child.type && child.type.displayName === 'SwiperSlide') {
|
||||
slides.push(child);
|
||||
} else if (child.props && child.props.slot && slots[child.props.slot]) {
|
||||
slots[child.props.slot].push(child);
|
||||
} else if (child.props && child.props.children) {
|
||||
const foundSlides = processChildren(child.props.children);
|
||||
|
||||
if (foundSlides.length > 0) {
|
||||
foundSlides.forEach(slide => slides.push(slide));
|
||||
} else {
|
||||
slots['container-end'].push(child);
|
||||
}
|
||||
} else {
|
||||
slots['container-end'].push(child);
|
||||
}
|
||||
});
|
||||
return {
|
||||
slides,
|
||||
slots
|
||||
};
|
||||
}
|
||||
|
||||
export { getChildren };
|
||||
Loading…
Add table
Add a link
Reference in a new issue