scrollFixed('.scroll_fixed',$('#comment'),0);
define(function(require, exports, module) {
/*
*name:在页面固定
*range:about,test_center,test_group,test_center_inner,test_group_inner
*impotant_parameter:
{
sObj:固定的对象
sParent:抵达的DOME位置
}
*/
exports.scrollGo = scroll_go;
exports.scrollFixed = scroll_fixed;
//chenxi
function scroll_fixed(sObj,sParent,num){
var version = navigator.userAgent;
if( version.indexOf('MSIE 6.')==-1 ){
var This = $(sObj);
var iHeight = This.height();
//chenxi add
var iTop = This.offset().top+num
//chenxi add 结束
var iOrangeTop;
var iStartT;//从哪开始固定
var Parent = $(sParent);
var iParentH;
var iParentT;
var iEndT
function fn(){
iOrangeTop = Math.max(iHeight - document.documentElement.clientHeight,0);
if( sParent ){
iParentH = Parent.height();
iParentT = Parent.offset().top;
iEndT = (iParentH + iParentT) - (iHeight - iOrangeTop);//底部边界
}else{
iEndT = 1000000;//无线高 代表无底线
}
iHeight = This.height();
//如果滚动条高度 大于参考物,则取消固定
if( iParentH+iParentT < iHeight ){
This.css({
zIndex:'',
position:'',
top:''
})
return;
}
iStartT = iTop + iOrangeTop;
var iDocT = $(this).scrollTop();
if( iDocT > iEndT ){
This.css({
zIndex:999999,
position:'fixed',
top:iEndT - iDocT - iOrangeTop+'px'
})
}else if( iDocT > iStartT ){
This.css({
zIndex:999999,
position:'fixed',
top:-iOrangeTop+'px'
})
}else if( iDocT < iStartT ){
This.css({
zIndex:'',
position:'',
top:''
})
}
}
fn();
$(window).scroll(fn).resize(fn);
}
}