2018-01-04 20:00:38 +08:00
|
|
|
/* eslint no-undef: 0 */
|
|
|
|
import React from 'react';
|
|
|
|
import ScrollParallax from 'rc-scroll-anim/lib/ScrollParallax';
|
|
|
|
|
|
|
|
function ParallaxG(props) {
|
|
|
|
return <ScrollParallax component="g" {...props} />;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function svgBgToParallax(children, i = 0) {
|
|
|
|
const svgChildren = React.Children.toArray(children).map((child, ii) => (
|
|
|
|
<ParallaxG
|
|
|
|
key={ii.toString()}
|
|
|
|
location="page2"
|
|
|
|
animation={{
|
2018-12-07 16:17:45 +08:00
|
|
|
y: Math.random() * -200 - 30 - i * 20,
|
2018-01-04 20:00:38 +08:00
|
|
|
playScale: [0, Math.random() + 2],
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{child}
|
|
|
|
</ParallaxG>
|
|
|
|
));
|
|
|
|
return svgChildren;
|
|
|
|
}
|
|
|
|
|
2018-01-05 15:57:40 +08:00
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
// 图处预加载;
|
|
|
|
const div = document.createElement('div');
|
|
|
|
div.style.display = 'none';
|
|
|
|
document.body.appendChild(div);
|
|
|
|
[
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/DJWUmdpxcQakQHwhPjzf.png',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/DEaRdiYbAyVNRelJpwXx.png',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/cCmuVrmQIJYlrhFjiPDZ.png',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/TOElddMOrCWlgZvWTJna.png',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/FpKOqFadwoFFIZFExjaf.png',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/IauKICnGjGnotJBEyCRK.png',
|
2018-01-04 20:00:38 +08:00
|
|
|
|
2018-01-05 15:57:40 +08:00
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/URIeCOKLMAbRXaeXoNqN.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/qXncdwwUTTgUFnsbCNCE.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/YFXXZocxAgjReehpPNbX.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/VPuetGsvJuYBwoDkZWFW.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/eYNnmGagLWdrkdMHVUuA.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/EPaPtDVGnJhyqyBAUZMl.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/GobRAKexhfTSJdLFzDFY.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/slVtnOCcgeAcLEPwtewY.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/UtBesTOkoZsBUxPqfDlZ.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/VrADJaRPMnFjmtmIhObV.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/MnLEmwjipfhzPUmBJnJE.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/dyNuxLOZtvjoHSVisbhQ.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/qggKjIGNFlVmMpwDUXPU.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/dgjVqwkJvptQEtlfctvk.svg',
|
|
|
|
'https://gw.alipayobjects.com/zos/rmsportal/vUxYuDdsbBBcMDxSGmwc.svg',
|
2018-12-07 16:17:45 +08:00
|
|
|
].forEach(src => {
|
2018-01-05 15:57:40 +08:00
|
|
|
const img = new Image();
|
|
|
|
img.src = src;
|
|
|
|
div.appendChild(img);
|
|
|
|
});
|
|
|
|
}
|