Chrome 中出现了 请问怎么解决啊。。。。。。Cannot read property 'style' of undefined
Chrome 中出现了 请问怎么解决啊。。。。。。Cannot read property 'style' of undefined
Chrome 中出现了 请问怎么解决啊。。。。。。Cannot read property 'style' of undefined
2015-05-20
//5.排序海报
function rsort(n){
var _photo=g('.photo');
var photos=[];
for(var s=0;s<_photo.length;s++){
// _photo[s].className=_photo[s].className.replace(/\s*photo_center\s*/,' ');
photos.push(_photo[s]);
}
var photo_center=g('#photo_'+n);
photo_center.className += ' photo_center ';
photo_center=photos.splice(n,1)[0];
//把海报分为左右两部分
console.log(photos.length)
var photos_left=photos.splice(0,Math.ceil(photos.length/2));
console.log(photos_left.length)
var photos_right=photos;
console.log(photos_right.length);
var ranges=range();
for(var s=0;s<photos_left.length;s++){
var photo=photos_left[s];
photo.style.left=random(ranges.left.x)+ 'px ';
photo.style.top =random(ranges.left.y)+ 'px ';
}
for(s in photos_left){
var photo=photos_right[s];
photo.style.left=random(ranges.right.x)+'px ';
photo.style.top =random(ranges.right.y)+'px ';
}
}
//计算左右分区的范围 left:{x:[min ,max],y:[min,max] right:x:[min ,max],y:[min,max]
function range(){
var range={left:{x:[],y:[]}, right:{x:[],y:[]}} ;
var wrap={
w:g('#wrap').clientWidth,
h:g('#wrap').clientHeight,
}
var photo={
// w:g('.photo')[2].clientWidth,
// h:g('.photo')[2].clientHeight,
w:260,
h:320,
}
range.wrap=wrap;
range.photo=photo;
range.left.x=[0-photo.w,wrap.w/2-photo.w/2];
range.left.y=[0-photo.h,wrap.h];
range.right.x=[wrap.w/2+photo.w/2,wrap.w+photo.w];
range.right.y=[0-photo.h,wrap.h];
return range;
}
举报