javascript 实现自由落体的方块效果
你可以试着按下鼠标左键,然后拖拽出一个方块后释放,看效果
Simple xhtml page
div.container{
position:absolute;
border:1px solid #333;
font-size:0px;
filter: alpha(opacity=60);
opacity: 0.6;
}
=dc-dh){clearInterval(self.dropId);self.fade();}
self.node.style.top = Math.min(dt+(++self.dropCount*2-1)*5, dc-dh)+"px";
},50);
}
Draw.prototype.fade = function(){
var self = this;
self.node.style.backgroundColor = self.randomColor();
self.node.style.filter = "alpha(opacity=100)";
self.node.style.opacity = 1;
self.fadeId = window.setInterval(function(){
if(++self.fadeCount>100){clearInterval(self.fadeId);}
self.node.style.filter = "alpha(opacity="+(100-self.fadeCount)+")";
self.node.style.opacity = (100-self.fadeCount)/100;
},10);
}
document.onmousedown = function(event){
var drawObject = new Draw(event);
drawObject.createDiv();
document.onmousemove = function(event){
drawObject.resizeDiv(event);
}
document.onmouseup = function(){
document.onmousemove = null;
window.setTimeout(function(){drawObject.drop()}, 1000);
}
}
//-->
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]