require('normalize.css/normalize.css');
require('styles/App.css');
import React from 'react';
// let yeomanImage = require('../images/yeoman.png');
var imageDatas = require('../data/imageDatas.json')
// 图片信息转成图片路径信息
imageDatas = (function(imageDatasArr) {
for (var i = 0; i < imageDatasArr.length; i++) {
var singeImageData = imageDatasArr[i];
singeImageData.imageURL = require('../images/'+singeImageData.filename);
singeImageData.key = require('../images/'+singeImageData.filename);
imageDatasArr[i] = singeImageData;
}
return imageDatasArr
})(imageDatas);
var ImgFigure = React.createClass({
render() {
return (
{this.props.data.title}
);
}
});
var AppComponent = React.createClass({
Canstant: {
centerPos:{
left:0,
top:0
},
hPosRange:{
leftSecX:[0,0],
rightSecX:[0,0],
y:[0,0]
},
vPosRange:{
x:[0,0],
topY:[0,0]
}
},
componentDidMount:function() {
var stageDom = React.findDOMNode(this.refs.stage),
stageW = stageDom.scrollWidth,
stageH = stageDom.scrollHeight,
halfStageW = Math.ceil(stageW/2),
halfStageH = Math.ceil(stageH/2);
var imgFigureDom = React.findDOMNode(this.refs.imgFigure0),
imgW = imgFigureDom.scrollWidth,
imgH = imgFigureDom.scrollHeight,
halfImgW = Math.ceil(imgW/2),
halfImgH = Math.ceil(imgH/2);
this.Canstant.centerPos = {
left:halfStageW-halfImgW,
top:halfStageH-halfImgH
}
this.Canstant.hPosRange.leftSecX[0] = -halfImgW;
this.Canstant.hPosRange.leftSecX[1] = halfStageW - halfImgW_3;
this.Canstant.hPosRange.rightSecX[0] = halfStageW - halfImgW;
this.Canstant.hPosRange.rightSecX[1] = stageW - halfImgW;
this.Canstant.hPosRange.y[0] = - halfImgH;
this.Canstant.hPosRange.y[1] = stageH - halfImgH;
this.Canstant.vPosRange.topY[0] = -halfImgH;
this.Canstant.vPosRange.topY[1] = halfStageH - halfImgH_3;
this.Canstant.vPosRange.x[0] = halfImgW - imgW;
this.Canstant.vPosRange.x[1] = halfImgW;
},
render:function() {
var controllerUnits = [],
imgFigures = [];
imageDatas.forEach(function(value,index) {
imgFigures.push(<ImgFigure data={value} key={'imgFigure'+index} ref={'imgFigure'+index}/>)
});
return (
);
}
});
AppComponent.defaultProps = {
};
export default AppComponent;