javascript實(shí)現(xiàn)炫酷的拖動(dòng)分頁(yè)
javascript實(shí)現(xiàn)炫酷的拖動(dòng)分頁(yè)
js
<html>
<head>
<title>拖動(dòng)分頁(yè)</title>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<style>
body{
border:0px;
margin:0px;
overflow:hidden;
background-color:transparent;
}
.page{
position:absolute;
width:700px;
border:1px solid #999;
background-color:#000;
left:425px;
margin-left:-350px;
cursor:default;
z-index:0;
}
ul{
height:320px;
list-style:none;
margin:40px 50px 0px;
padding:0px;
}
li{
width:100%;
height:30px;
line-height:30px;
font-size:14px;
text-align:left;
border-bottom:1px dashed #999;
}
a{
text-decoration:none;
color:#999;
}
a:hover{
font-weight:bold;
}
li span{
float:right;
color:#999;
}
.tip{
display:block;
width:100%;
font-size:12px;
color:#999;
text-align:center;
margin:10px 0px 20px;
}
</style>
</head>
<body onselectstart="return false;">
<script>
function id(obj){
return document.getElementById(obj);
}
var page;
var lm,mx;
var md=false;
var sh=0;
var en=false;
window.onload=function(){
page=document.getElementsByTagName("div");
if(page.length>0){
page[0].style.zIndex=2;
}
for(i=0;i<page.length;i++){
page[i].className="page";
page[i].innerHTML+="<span class="tip">第 "+(i+1)+"/"+page.length+" 頁(yè) 提示:左右拖拽翻頁(yè)</span>";
page[i].id="page"+i;
page[i].i=i;
page[i].onmousedown=function(e){
if(!en){
if(!e){e=e||window.event;}
lm=this.offsetLeft;
mx=(e.pageX)?e.pageX:e.x;
this.style.cursor="w-resize";
md=true;
if(document.all){
this.setCapture();
}else{
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
}
}
page[i].onmousemove=function(e){
if(md){
en=true;
if(!e){e=e||window.event;}
var ex=(e.pageX)?e.pageX:e.x;
this.style.left=ex-(mx-lm)+350;
if(this.offsetLeft<75){
var cu=(this.i==0)?page.length-1:this.i-1;
page[sh].style.zIndex=0;
page[cu].style.zIndex=1;
this.style.zIndex=2;
sh=cu;
}
if(this.offsetLeft>75){
var cu=(this.i==page.length-1)?0:this.i+1;
page[sh].style.zIndex=0;
page[cu].style.zIndex=1;
this.style.zIndex=2;
sh=cu;
}
}
}
page[i].onmouseup=function(){
this.style.cursor="default";
md=false;
if(document.all){
this.releaseCapture();
}else{
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
}
flyout(this);
}
}
}
function flyout(obj){
if(obj.offsetLeft<75){
if( (obj.offsetLeft + 350 - 20) > -275 ){
obj.style.left=obj.offsetLeft + 350 - 20;
window.setTimeout("flyout(id('"+obj.id+"'));",0);
}else{
obj.style.left=-275;
obj.style.zIndex=0;
flyin(id(obj.id));
}
}
if(obj.offsetLeft>75){
if( (obj.offsetLeft + 350 + 20) < 1125 ){
obj.style.left=obj.offsetLeft + 350 + 20;
window.setTimeout("flyout(id('"+obj.id+"'));",0);
}else{
obj.style.left=1125;
obj.style.zIndex=0;
flyin(id(obj.id));
}
}
}
function flyin(obj){
if(obj.offsetLeft<75){
if( (obj.offsetLeft + 350 + 20) < 425 ){
obj.style.left=obj.offsetLeft + 350 + 20;
window.setTimeout("flyin(id('"+obj.id+"'));",0);
}else{
obj.style.left=425;
en=false;
}
}
if(obj.offsetLeft>75){
if( (obj.offsetLeft + 350 - 20) > 425 ){
obj.style.left=obj.offsetLeft + 350 - 20;
window.setTimeout("flyin(id('"+obj.id+"'));",0);
}else{
obj.style.left=425;
en=false;
}
}
}
</script>
html:
<div> <ul> <li><span>2009-4-29 02:16</span><a href=#>東方之珠</a></li> <li><span>2009-4-29 02:16</span><a href=#>??!愛(ài)人</a></li> <li><span>2009-4-29 02:16</span><a href=#>寧?kù)o溫泉</a></li> <li><span>2009-4-29 02:16</span><a href=#>你的樣子</a></li> <li><span>2009-4-29 02:16</span><a href=#>戀曲1980</a></li> <li><span>2009-4-29 02:16</span><a href=#>戀曲1980</a></li> <li><span>2009-4-29 02:16</span><a href=#>戀曲2000</a></li> <li><span>2009-4-29 02:16</span><a href=#>亞細(xì)亞的孤兒</a></li> <li><span>2009-4-29 02:16</span><a href=#>童年</a></li> </ul> </div> <div> <ul> <li><span>2009-4-29 02:16</span><a href=#>彈唱詞</a></li> <li><span>2009-4-29 02:16</span><a href=#>飛車</a></li> <li><span>2009-4-29 02:16</span><a href=#>東方之珠</a></li> <li><span>2009-4-29 02:16</span><a href=#>滾滾紅塵</a></li> <li><span>2009-4-29 02:16</span><a href=#>光陰的故事</a></li> <li><span>2009-4-29 02:16</span><a href=#>之乎者也</a></li> <li><span>2009-4-29 02:16</span><a href=#>現(xiàn)象七十二變</a></li> <li><span>2009-4-29 02:16</span><a href=#>鄉(xiāng)愁四韻</a></li> <li><span>2009-4-29 02:16</span><a href=#>穿過(guò)你的黑發(fā)我的手</a></li> </ul> </div> <div> <ul> <li><span>2009-4-29 02:16</span><a href=#>大兵歌</a></li> <li><span>2009-4-29 02:16</span><a href=#>黃色面孔</a></li> <li><span>2009-4-29 02:16</span><a href=#>臺(tái)北紅玫瑰</a></li> </ul> </div> </body> </html>
以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。
- javascript 新聞標(biāo)題靜態(tài)分頁(yè)代碼 (無(wú)刷新)
- Javascript靜態(tài)分頁(yè)(多個(gè)資料,靜態(tài)自動(dòng)分頁(yè))
- 純JavaScript實(shí)現(xiàn)的分頁(yè)插件實(shí)例
- JavaScript實(shí)現(xiàn)列表分頁(yè)功能特效
- JavaScript分頁(yè)功能的實(shí)現(xiàn)方法
- 分享一個(gè)自己寫(xiě)的簡(jiǎn)單的javascript分頁(yè)組件
- 原生javascript實(shí)現(xiàn)的分頁(yè)插件pagenav
- 超酷的鼠標(biāo)拖拽翻頁(yè)(分頁(yè))效果實(shí)現(xiàn)javascript代碼
- JavaScript仿靜態(tài)分頁(yè)實(shí)現(xiàn)方法
相關(guān)文章
Javascript的常規(guī)數(shù)組和關(guān)聯(lián)數(shù)組對(duì)比小結(jié)
關(guān)聯(lián)數(shù)組雖然可以用字符串作下標(biāo),但是這個(gè)下標(biāo)是不支持參數(shù)傳值的,換言之,你需要什么就取什么,聽(tīng)起來(lái)很智能,實(shí)際上你取值仍然需要你手動(dòng)去寫(xiě)下標(biāo)的2012-05-05
JavaScript中的property和attribute介紹
JavaScript中的property和attribute介紹,需要的朋友可以參考下。2011-12-12
使用swiper自定義分頁(yè)點(diǎn)擊跳轉(zhuǎn)指定頁(yè)面
這篇文章主要介紹了使用swiper自定義分頁(yè)點(diǎn)擊跳轉(zhuǎn)指定頁(yè)面方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04
JavaScript實(shí)現(xiàn)多維數(shù)組的方法
這篇文章主要介紹了JavaScript實(shí)現(xiàn)多維數(shù)組的方法,有需要的朋友可以參考一下2013-11-11
javascript 文件的同步加載與異步加載實(shí)現(xiàn)原理
本文將介紹javascript 文件的同步加載與異步加載實(shí)現(xiàn)原理,需要了解的朋友可以了解下2012-12-12
threejs太陽(yáng)光與陰影效果實(shí)例代碼
在Threejs中類似于我們現(xiàn)實(shí)世界,物體顯示的顏色是由物體本身的顏色及光照的顏色相互疊加而得到的,這篇文章主要給大家介紹了關(guān)于threejs太陽(yáng)光與陰影效果的相關(guān)資料,需要的朋友可以參考下2022-04-04
js在Firefox與IE中對(duì)DOM對(duì)像的引用的比較
直接用ID屬性進(jìn)行引用 直接用NAME屬性進(jìn)行引用 使用getElementById(),getElementsByName(),getElementsByTagName()進(jìn)行引用2009-06-06
純JS代碼實(shí)現(xiàn)隔行變色鼠標(biāo)移入高亮
這篇文章主要介紹了純JS代碼實(shí)現(xiàn)隔行變色鼠標(biāo)移入高亮的相關(guān)資料,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2016-11-11
淺談移動(dòng)端之js touch事件 手勢(shì)滑動(dòng)事件
這篇文章主要和大家聊一聊移動(dòng)端之js touch事件,即手指的滑動(dòng)事件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11

