Javascript Resize和Drag类,基于jQuery
2010-09-14 13:41:25 来源:WEB开发网下面是setDirection方法:
method -- setDirection
setDirection : function(direction) {
switch(direction) {
case 'west' :this.vector = {x:-1,y: 0};break;
case 'east' :this.vector = {x: 1,y: 0};break;
case 'north':this.vector = {x: 0,y:-1};break;
case 'south':this.vector = {x: 0,y: 1};break;
case 'north-west':this.vector = {x:-1,y:-1};break;
case 'south-west':this.vector = {x:-1,y: 1};break;
case 'north-east':this.vector = {x: 1,y:-1};break;
case 'south-east':this.vector = {x: 1,y: 1};break;
default:return false;
}
return true;
}
下面是onResizing事件:
onResizing Event
onResizing: function(e){
// 修正X,Y
var x = Math.max(Math.min(e.pageX, this.option.boundRight), this.option.boundLeft);
var y = Math.max(Math.min(e.pageY, this.option.boundBottom), this.option.boundTop);
// 依次为向西,东,北,南方向调整
if(this.vector.x === -1) this.oPos.x = Math.min(x, this.iPos.x - this.option.minWidth);
if(this.vector.x === 1) this.iPos.x = Math.max(x, this.oPos.x + this.option.minWidth);
if(this.vector.y === -1) this.oPos.y = Math.min(y, this.iPos.y - this.option.minHeight);
if(this.vector.y === 1) this.iPos.y = Math.max(y, this.oPos.y + this.option.minHeight);
this.resize(this.oPos.x - this.parentOffset.left, this.oPos.y-this.parentOffset.top, this.iPos.x - this.oPos.x, this.iPos.y - this.oPos.y);
return false;
}
Tags:Javascript Resize Drag
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接