JavaScript 动画之上下滑动的侧边栏
来源:互联网 发布:淘宝自己的评价怎么看 编辑:程序博客网 时间:2024/05/21 10:49
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style>#div1 {width:100px; height:100px; background:red; position:absolute; right:0;}</style><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">window.onscroll=function (){ var oDiv=document.getElementById('div1'); var scrollTop=document.documentElement.scrollTop||document.body.scrollTop; //oDiv.style.top=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2+'px'; var t=scrollTop+(document.documentElement.clientHeight-oDiv.offsetHeight)/2; startMove(parseInt(t));}var timer=null;function startMove(iTarget){ var oDiv=document.getElementById('div1'); clearInterval(timer); timer=setInterval(function (){ var iSpeed=(iTarget-oDiv.offsetTop)/8; iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed); if(oDiv.offsetTop==iTarget) { clearInterval(timer); } else { oDiv.style.top=oDiv.offsetTop+iSpeed+'px'; } txt1.value=oDiv.offsetTop+',目标:'+iTarget; }, 30);}</script></head><body style="height:2000px;"><input id="txt1" type="text" style="position:fixed; top:20px;" /><div id="div1"></div></body></html>
参考:JavaScript
阅读全文
0 0
- JavaScript 动画之上下滑动的侧边栏
- Android之上下滑动的引导页
- Android 端天气预报APP的实现(一)天气显示界面之上下滑动
- 38、JavaScript的运动----分享到侧边栏
- javascript实现一个简单的隐藏式侧边栏
- 动画特效十一:侧边栏效果
- Side Menu侧边栏动画效果
- sidebarEffects.js 网页侧边栏过渡动画
- 简单的侧边栏
- 侧边栏的实现
- JavaScript封装缓动动画函数
- 缓动动画的实现
- JavaScript动画 —— 弹动动画 (未测试)
- Android界面动画初探之--探索侧边栏折叠效果的实现
- JavaScript 运动之侧边分享栏
- 安卓解决高德地图在scrollview的嵌套下滑动出现黑影
- RecyclerView和StaggeredGridLayoutManager实现瀑布流向下滑动item跳动、留白的问题
- 侧边栏的实现----网易新闻的侧边栏效果
- 【raspberry pi】树莓派的机器人制作
- Groovy脚本基础全攻略
- Activity has leaked window DecorView@ab38a0a[] that was originally added here
- 神奇的兔子
- 记Selenium HTMLTestRunner 无法生成测试报告的总结
- JavaScript 动画之上下滑动的侧边栏
- Sentry--错误日志收集框架
- vue2.0组件之间如何通信
- animate cc在ios上点击canvas闪黑以及在安卓微信里巨卡的解决方案
- 曾被雷军点赞的00后CEO回国融资:没钱发工资!和贾跃亭不一样
- mybatis关于传递参数问题
- vue-cli搭建后如何加入新页面
- TensorFlow on Android:训练模型
- C++总结笔记