/**
* 对象悬浮
* listen_obj 监听的对象
* float_obj 需要悬浮的对象
* top 悬浮对象距离顶部的高度
* background 背景
*/
function objectFloat(listen_obj, float_obj, top, background){
var current_top = $(float_obj).offset().top;
var old_background = $(float_obj).css('background');
$(listen_obj).scroll(function() {
var sctop = $(this).scrollTop();
if(sctop > current_top){
var ty = sctop - current_top + top;
$(float_obj).css({'transform':'translateY('+ ty +'px)', 'z-index':'9999'});
if(background){
$(float_obj).css({'background':background});
}
} else{
var ty = current_top;
$(float_obj).css({'transform':'translateY(0px)', 'z-index':'9999'});
if(background){
$(float_obj).css({'background':old_background});
}
}
});
}