最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于jquery的3d效果實現(xiàn)代碼

 更新時間:2011年03月23日 22:20:16   作者:  
基于jquery的3d效果實現(xiàn)代碼,需要的朋友可以參考下。
復制代碼 代碼如下:

<html>
<head>
<script type="text/javascript" src="http://demo.jb51.net/jslib/jquery/jquery-1.4.2.min.js"></script><style>
.s_c{
position:relative;
width:800px;
height:300px;
border:1px solid #000;
overflow:hidden;
}
</style>
<script type="text/javascript">
var Sl=Sl||{};
(function(){
var undefined;
function box(o){
var d=$.extend({},{
'w':40,
'h':30,
'secne':null,
'data':''
},o);
if(d.secne==null||!d.secne) return;
this.div=$("<div></div>").css({'position': 'absolute','border':'1px solid #cde','left':'0px','top':'0px'}).html(d.data);
this.w(d.w);
this.h(d.h);
this._ow=this.w();
this._oh=this.h();
$(d.secne).append(this.div);
return this;
}
box.prototype.zoomw=function(v){
if(v==undefined){
this._zw=this._zw||1;
return this._zw;
}
this.w(this.ow()*v,false);
this._zw=v;
return this;
}
box.prototype.zoomh=function(v){
if(v==undefined){
this._zh==this._zh||1;
return this._zh;
}
this.h(this.oh()*v,false);
this._zh=v;
return this;
}
box.prototype.x=function(x){
if(x==undefined){
this._x=this._x||0;
return this._x;
}
this.div.css({
left:x-(this.w())/2
})
this._x=x;
return this;
}
box.prototype.y=function(y){
if(y==undefined){
this._y=this._y||0;
return this._y;
}
this.div.css({
top:y-(this.h())/2
})
this._y=y;
return this;
}
box.prototype.ow=function(){
return this._ow||0;
}
box.prototype.oh=function(){
return this._oh||0;
}
box.prototype.w=function(w,rs){
if(w==undefined){
w=this.div.css('width');
w=w=='auto'?this.div.width():w;
return parseInt(w);
}
if(rs!==false)
this._ow=w;
this.mx(-(w-this.w())/2);
this.div.css({'width':w});
return this;
}
box.prototype.h=function(h,rs){
if(h==undefined){
h=this.div.css('height');
h=h=='auto'?this.div.height():h;
return parseInt(h);
}
if(rs!==false)
this._oh=h;
this.my(-(h-this.h())/2);
this.div.css({'height':h});
return this;
}
box.prototype.mx=function(x){
var div=this.div;
div.css({'left': parseInt(div.css('left'))+x});
}
box.prototype.my=function(y){
var div=this.div;
div.css({'top':parseInt(div.css('top'))+y});
}
box.prototype.z=function(z){
if(z==undefined)
return this.div.css('z-index');
this.div.css("z-index",z);
return this;
}



//3d box
function box3d(o){
if(!$(o.secne))return;
secne=o.secne;
var secne=this.secne=$(secne);
this.vx= parseInt(secne.css('width')=='auto'?secne.width():secne.css('width'))/2;
this.vy= parseInt(secne.css('height')=='auto'?secne.height():secne.css('height'))/2;
this.fl=o.fl||250;
this.box=new box(o).z(0);
this._set3d();
return this;
}
box3d.prototype.x=function(x){
if(x==undefined)
return this._x||0;
this._x=x||0;
this._set3d();
return this;
}
box3d.prototype.y=function(y){
if(y==undefined)
return this._y||0;
this._y=y||0;
this._set3d();
return this;
}
box3d.prototype.z=function(z){
if(z==undefined)
return this._z||0;
this._z=z||0;
this._set3d();
return this;
}
box3d.prototype._set3d=function(){
var boxo=this.box;
var fl=this.fl;
var zomx=fl/(fl+this.z());
var x=this.vx+zomx*this.x();
var y=this.vy+zomx*this.y();
boxo.zoomw(zomx).zoomh(zomx);
boxo.x(x);
boxo.y(y);
}


//
function slide(o){
var d=$.extend({},{
'z':100,
'secne':null
},o);
if(d.secne==null||!$(d.secne))return;
this.cecne=d.secne;
this.z=d.z;
this.sleep=0.02;
var k={'secne':d.secne,'w':80,'h':50,fl:1000};
this.box=[];
var c=8;
for(var i=0;i<c;i++){
var t= parseInt(i-c/2);
var a=$('<div></div>').css({
width:'100%',
height:'100%',
background:'#777'
})

k.data=a;
var ubox=new box3d(k).z(300);
this.r(ubox,t/2);
this.box.push(ubox);
}
this.re_index();
}
slide.prototype._moveaction=function(){
var _this=this;
var s=this.sleep;
for(var i=0;i<this.box.length;i++){
this.r(this.box[i],s);
}
this.re_index();
}
slide.prototype.r=function(rbox,s){
if(!(rbox instanceof box3d))
return;
var X=rbox.x();
var Y=rbox.y()
var Z=rbox.z();
var New_X = X*Math.cos(s) - Z*Math.sin(s);
var New_Z = X*Math.sin(s) + Z*Math.cos(s);
var New_Y = Y;
rbox.x(New_X);
rbox.y(New_Y);
rbox.z(New_Z);
}
slide.prototype.re_index=function(){
var arr=this.box;
var s=arr.length;
for(var j=0;j<s-1;j++){
for(var i=0;i<s-j-1;i++){
if(arr[i].z()<arr[i+1].z()){
var c=arr[i];
arr[i]=arr[i+1];
arr[i+1]=c;
}
}
}
for(var i=0;i<arr.length;i++){
arr[i].box.z(i)
}
}
slide.prototype.start=function(){
this.run=1;
this._move();
}
slide.prototype.stop=function(){
this.run=0;
}
slide.prototype._move=function(s){
var _this=this;
setTimeout(function(){
if(!_this.run){
return;
}
_this._moveaction();
_this._move();
},50)
}
Sl.slide=slide;
})()
$(function(){
var s=new Sl.slide({secne:'.s_c'});
$('#start').click(function(){s.start()})
$('#stop').click(function(){s.stop()})
})
</script>
</head>
<body>
<div class='s_c'></div>
<button id="start">start</button>
<button id="stop">stop</button>
</body>
</html>

相關文章

  • jQuery Ajax使用 全解析

    jQuery Ajax使用 全解析

    jQuery確實是一個挺好的輕量級的JS框架,能幫助我們快速的開發(fā)JS應用,并在一定程度上改變了我們寫JavaScript代碼的習慣。
    2010-12-12
  • Jquery 過濾器(first,last,not,even,odd)的使用

    Jquery 過濾器(first,last,not,even,odd)的使用

    Jquery 過濾器,顧名思義就是過濾一些不需要的元素,主要有first,last,not,even,odd等等,下面有個使用示例,大家可以感受下
    2014-01-01
  • jquery的$().each和$.each的區(qū)別

    jquery的$().each和$.each的區(qū)別

    今天小編就為大家分享一篇關于jquery的$().each和$.each的區(qū)別,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • jQuery獲取同級元素的簡單代碼

    jQuery獲取同級元素的簡單代碼

    下面小編就為大家?guī)硪黄猨Query獲取同級元素的簡單代碼。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-07-07
  • jQuery原型屬性和原型方法詳解

    jQuery原型屬性和原型方法詳解

    這邊文章主要給大家介紹了jQuery原型屬性constructor,selector,length,jquery和原型方法size,get,toArray,十分的詳細,有需要的小伙伴可以參考下。
    2015-07-07
  • CSS3 media queries結合jQuery實現(xiàn)響應式導航

    CSS3 media queries結合jQuery實現(xiàn)響應式導航

    這篇文章主要為大家詳細介紹了CSS3 media queries結合jQuery實現(xiàn)響應式導航,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • JQuery記住用戶名密碼實現(xiàn)下次自動登錄功能

    JQuery記住用戶名密碼實現(xiàn)下次自動登錄功能

    這篇文章主要介紹了JQuery記住用戶名密碼實現(xiàn)下次自動登錄功能,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下
    2015-04-04
  • jquery實現(xiàn)的可隱藏重現(xiàn)的靠邊懸浮層實例代碼

    jquery實現(xiàn)的可隱藏重現(xiàn)的靠邊懸浮層實例代碼

    本實例使用jquery操作div的CSS實現(xiàn)了可隱藏重現(xiàn)的靠邊懸浮層,具體實現(xiàn)代碼如下,感興趣的朋友可以參考下哈
    2013-05-05
  • jQuery實用小技巧_輸入框文字獲取和失去焦點的簡單實例

    jQuery實用小技巧_輸入框文字獲取和失去焦點的簡單實例

    下面小編就為大家?guī)硪黄猨Query實用小技巧_輸入框文字獲取和失去焦點的簡單實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-08-08
  • jQuery實現(xiàn)的導航動畫效果(附demo源碼)

    jQuery實現(xiàn)的導航動畫效果(附demo源碼)

    這篇文章主要介紹了jQuery實現(xiàn)的導航動畫效果,可實現(xiàn)導航條的底部橫條隨鼠標移動的效果,涉及jQuery針對鼠標事件的響應及頁面元素樣式動態(tài)變換的相關技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下
    2016-04-04

最新評論

灵台县| 桂平市| 全南县| 鱼台县| 蒙自县| 钟祥市| 瑞丽市| 上虞市| 乌拉特后旗| 清原| 南城县| 策勒县| 普兰店市| 永州市| 仁化县| 涟水县| 浦城县| 武乡县| 桐城市| 普兰店市| 彰化市| 双江| 景泰县| 图木舒克市| 德州市| 双江| 阜宁县| 成都市| 深水埗区| 黄石市| 昌吉市| 白银市| 保定市| 楚雄市| 平凉市| 称多县| 沂南县| 泰州市| 临邑县| 吕梁市| 平谷区|