js仿土豆视频滚动菜单
2008-05-07 00:00
239 查看
脚本之家 www.jb51.net 仿土豆视频滚动菜单
ul{margin:0;padding:0;list-style:none;width:100000px}
li{margin:0;padding:0;width:100px;height:100px;display:block;float:left;margin-right:5px;background:#009900}
#img_bag{width:640px;height:100px;background:#FF9900;margin:0 auto;}
#img_bag a{float:left;width:20px;display:block;height:20px;font-weight:bold;}
#img_bag #img{width:600px;height:100px;background:#ccc;overflow:hidden;float:left}
#scrollBar{width:600px;height:20px;background:#FF0000;margin:0 auto;position:relative}
#scroll{width:30px;height:20px;background:#000;cursor:pointer;position:absolute;}
<<
>>
function $(obj){return document.getElementById(obj)}
var maxWidth=$("img").getElementsByTagName("ul")[0].getElementsByTagName("li").length*105;
var isScroll=false;
var modiLeft;
$("scroll").onmousedown=function(evt){
isScroll=true;
evt=(evt)?evt:((window.event)?window.event:null);
if(evt.offsetX){
modiLeft=parseInt(evt.offsetX)
}
else{modiLeft=parseInt(evt.layerX)}
}
document.onmouseup=function(){
isScroll=false;
}
document.onmousemove=function(evt){
evt=(evt)?evt:((window.event)?window.event:null);
if(evt&&isScroll){
$("scroll").style.left=parseInt(evt.clientX)-parseInt($("scrollBar").offsetLeft)-modiLeft+"px";
if(parseInt($("scroll").style.left)570){$("scroll").style.left=570+"px"}
$("img").scrollLeft=parseInt($("scroll").style.left)*((maxWidth-600)/570);
}
}
var targetx = 200;//一次滚动距离
var dx;
var a=null;
function moveLeft(){
var le=parseInt($("img").scrollLeft);
if(le>200){
targetx=parseInt($("img").scrollLeft)-200;
}
else{targetx=parseInt($("img").scrollLeft)-le-1}
scLeft();
}
function scLeft(){
dx=parseInt($("img").scrollLeft)-targetx;
$("img").scrollLeft-=dx*.3;
$("scroll").style.left=parseInt($("img").scrollLeft)*(570/(maxWidth-600))+"px";
if(parseInt($("scroll").style.left)570){$("scroll").style.left=570+"px"}
clearScroll=setTimeout(scLeft,50);
if(dx*.3
ul{margin:0;padding:0;list-style:none;width:100000px}
li{margin:0;padding:0;width:100px;height:100px;display:block;float:left;margin-right:5px;background:#009900}
#img_bag{width:640px;height:100px;background:#FF9900;margin:0 auto;}
#img_bag a{float:left;width:20px;display:block;height:20px;font-weight:bold;}
#img_bag #img{width:600px;height:100px;background:#ccc;overflow:hidden;float:left}
#scrollBar{width:600px;height:20px;background:#FF0000;margin:0 auto;position:relative}
#scroll{width:30px;height:20px;background:#000;cursor:pointer;position:absolute;}
<<
>>
function $(obj){return document.getElementById(obj)}
var maxWidth=$("img").getElementsByTagName("ul")[0].getElementsByTagName("li").length*105;
var isScroll=false;
var modiLeft;
$("scroll").onmousedown=function(evt){
isScroll=true;
evt=(evt)?evt:((window.event)?window.event:null);
if(evt.offsetX){
modiLeft=parseInt(evt.offsetX)
}
else{modiLeft=parseInt(evt.layerX)}
}
document.onmouseup=function(){
isScroll=false;
}
document.onmousemove=function(evt){
evt=(evt)?evt:((window.event)?window.event:null);
if(evt&&isScroll){
$("scroll").style.left=parseInt(evt.clientX)-parseInt($("scrollBar").offsetLeft)-modiLeft+"px";
if(parseInt($("scroll").style.left)570){$("scroll").style.left=570+"px"}
$("img").scrollLeft=parseInt($("scroll").style.left)*((maxWidth-600)/570);
}
}
var targetx = 200;//一次滚动距离
var dx;
var a=null;
function moveLeft(){
var le=parseInt($("img").scrollLeft);
if(le>200){
targetx=parseInt($("img").scrollLeft)-200;
}
else{targetx=parseInt($("img").scrollLeft)-le-1}
scLeft();
}
function scLeft(){
dx=parseInt($("img").scrollLeft)-targetx;
$("img").scrollLeft-=dx*.3;
$("scroll").style.left=parseInt($("img").scrollLeft)*(570/(maxWidth-600))+"px";
if(parseInt($("scroll").style.left)570){$("scroll").style.left=570+"px"}
clearScroll=setTimeout(scLeft,50);
if(dx*.3
相关文章推荐
- js仿土豆视频滚动菜单
- js鼠标滚动到某个位置导航菜单显示
- js实例-滚动菜单
- js实现水平滚动菜单导航
- js 实现菜单左右滚动显示示例介绍
- js 实现菜单左右滚动显示
- js 实现菜单左右滚动显示示例介绍
- js创建滚动菜单
- 纯JS无间隙文字向上滚动代码
- JS+CSS实现类似QQ好友及黑名单效果的树型菜单
- 基于jquery的锚点滚动插件(百度百科效果) anchorScroll.js
- JS+CSS实现类似QQ好友及黑名单效果的树型菜单
- 爆炸式的JS圆形浮动菜单特效代码
- PHP+JS三级菜单联动菜单实现方法
- JS中文字横向滚动
- 不用marquee而使用JS控制图片纵向滚动,解决火狐不兼容
- Vue.js入门学习--选择菜单select的绑定(七)
- 很实用的JS+CSS多级树形展开菜单
- MSClass (Class Of Marquee Scroll通用不间断滚动JS封装类) Ver 1.65
- Js相册横向滚动效果