缓冲运动[实例--上下滑动客服
来源:互联网 发布:梦幻西游淘宝网 编辑:程序博客网 时间:2024/05/16 12:38
******************缓冲运动[实例--上下滑动客服1*************************
<!DOCTYPE html>
<html><head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{width:100px;height:200px;position: absolute;top:0;right:0;background:yellow;}
</style>
<script type="text/javascript">
window.onload=function(){
var oDiv=document.getElementsByTagName("div")[0];
var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
oDiv.style.top=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2+"px";//////慎记,需要添加px
window.onscroll=function()
{
// var oDiv=document.getElementsByTagName("div")[0];
var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
oDiv.style.top=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2+"px";//////慎记,需要添加px
}
}
</script>
</head>
<body style="height:3000px">
<div></div>
</body>
</html>
************************缓冲运动[实例--上下滑动客服2**************************************
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
div{width:100px;height:200px;position: absolute;top:0;right:0;background:yellow;}
</style>
<script type="text/javascript">
window.onload=function(){
var oDiv=document.getElementsByTagName("div")[0];
var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
oDiv.style.top=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2+"px";//////慎记,需要添加px
window.onscroll=function()
{
// var oDiv=document.getElementsByTagName("div")[0];
var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;
// oDiv.style.top=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2+"px";//////慎记,需要添加px
var t=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2;
startMove(parseInt(t));//这里必须取整,小数会出问题
}
};
var timer=null;
function startMove(iTarget)
{
var oDiv=document.getElementsByTagName("div")[0];
clearInterval(timer);
timer=setInterval(function(){
var Speed=(iTarget-oDiv.offsetTop)/10;
Speed=Speed>0?Math.ceil(Speed):Math.floor(Speed);
if(oDiv.offsetTop==iTarget){clearInterval(timer)}
else
{
oDiv.style.top=oDiv.offsetTop+Speed+"px";
document.getElementsByTagName("input")[0].value=oDiv.offsetTop+"目标:"+iTarget;
}
},30)
}
</script>
</head>
<body style="height:3000px">
<div></div>
<input type="text" style="position: fixed;top:20px;"/>
</body>
</html>
- 缓冲运动[实例--上下滑动客服
- h5实例-上下滑动页面
- JS实例-图片上下滑动
- 运动框架(js)—上下滑动的侧边栏
- 缓冲运动
- 缓冲运动
- 缓冲运动 //缓冲运动 (目标值
- js运动-运动缓冲
- 缓冲运动之框架开始一级简单框架实例
- 缓冲运动与弹性运动
- JaveScript 运动之缓冲运动
- js运动(2)----缓冲运动
- JavaScript运动之缓冲运动
- js运动技术--缓冲运动
- js缓冲运动、弹性运动、碰撞运动
- JS的缓冲运动
- 缓冲运动框架
- 层的缓冲运动
- 用php做消息推送
- C_二维数组, 字符串数组, 及多维数组
- 判断要导入课程是否存在
- TestNG的组测试和组中组测试
- hdoj 1025 Constructing Roads In JGShining's Kingdom 【最长递增子序列】
- 缓冲运动[实例--上下滑动客服
- 新型营销模式CP2C
- 软件方法笔记-4业务序列
- Ambari-整体介绍
- 大连海鲜美食素材提供者~大连海缘新品上市~~~大海虾
- 跟我一起学extjs5(41--增加一个自定义模块(源码下载)[2销售合同加入菜单和模块展示])
- 神兵利器——Alfred
- 自己动手编译hsdis
- linux 文件系统简介