码迷,mamicode.com
首页 > 其他好文 > 详细

scroll

时间:2016-05-11 15:16:19      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

var fScrollTopHeight = function(){
return document.documentElement&&document.documentElement.scrollTop || document.body && document.body.scrollTop || 0;
};
var fClientHeight = function(){
var clientHeight=0;
if(document.body.clientHeight&&document.documentElement.clientHeight){
clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
}else{
clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
}
return clientHeight;
};
var fBodyHeight = function(){
return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
};
$(function(){
var fixedbar = document.getElementById("fixedbar");
// jScShow = $(‘<div style="position:fixed;bottom:100px;right:0;z-index:999;background:red;width:120px;height:100px;">5555</div>‘).appendTo(‘body‘);
$(document).on(‘scroll‘, function(){
// alert(1);
// jScShow.html([fScrollTopHeight(), fClientHeight(), fBodyHeight()].join(‘<BR /><BR />‘) + ‘<BR />‘);

// if(fScrollTopHeight()+fClientHeight()- fBodyHeight() >= -10){//最底部

// }


var items = $("#wrapper").find(‘.ui-coll-list‘);
var currentText = "";
items.each(function(){
var m = $(this);
if (fScrollTopHeight() > m.offset().top - 86) {
currentText = m.find(‘.head‘).text();
}else{
return false
}
});
if (currentText) {
fixedbar.innerHTML = currentText;
};

if (fScrollTopHeight() > 5) {
fixedbar.style.display="block";
}else{
fixedbar.style.display="none";
}
});
})

scroll

标签:

原文地址:http://www.cnblogs.com/nuoyiamy/p/5481674.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!