开发学院网页设计JavaScript Javascript Resize和Drag类,基于jQuery 阅读

Javascript Resize和Drag类,基于jQuery

 2010-09-14 13:41:25 来源:WEB开发网   
核心提示: 下面是setDirection方法:method -- setDirectionsetDirection:function(direction){switch(direction){case'west':this.vector={x:-1,y:0};break;case&#

下面是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;
    }

上一页  1 2 3 4  下一页

Tags:Javascript Resize Drag

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接