First upload
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
|
||||
function processChildren(c) {
|
||||
var slides = [];
|
||||
React.Children.toArray(c).forEach(function (child) {
|
||||
if (child.type && child.type.displayName === 'SwiperSlide') {
|
||||
slides.push(child);
|
||||
} else if (child.props && child.props.children) {
|
||||
processChildren(child.props.children).forEach(function (slide) {
|
||||
return slides.push(slide);
|
||||
});
|
||||
}
|
||||
});
|
||||
return slides;
|
||||
}
|
||||
|
||||
function getChildren(c) {
|
||||
var slides = [];
|
||||
var slots = {
|
||||
'container-start': [],
|
||||
'container-end': [],
|
||||
'wrapper-start': [],
|
||||
'wrapper-end': []
|
||||
};
|
||||
React.Children.toArray(c).forEach(function (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) {
|
||||
var foundSlides = processChildren(child.props.children);
|
||||
|
||||
if (foundSlides.length > 0) {
|
||||
foundSlides.forEach(function (slide) {
|
||||
return slides.push(slide);
|
||||
});
|
||||
} else {
|
||||
slots['container-end'].push(child);
|
||||
}
|
||||
} else {
|
||||
slots['container-end'].push(child);
|
||||
}
|
||||
});
|
||||
return {
|
||||
slides: slides,
|
||||
slots: slots
|
||||
};
|
||||
}
|
||||
|
||||
export { getChildren };
|
||||
Reference in New Issue
Block a user