2012-08-07 2 views
0

먼저이 이미에 대한 질문/답이있다 : Constrain position of Dojo FloatingPane http://jsfiddle.net/phusick/3vTXW/모든 도장에서 이동 객체를 구속

나는 이동 창을 만들 수 위의를 사용하고 먼저 작업을했다. 그런 다음 객체가있는 모듈을 만들었고 구속이 더 이상 작동하지 않으면 객체를 창 밖으로 이동할 수 있습니다. 심지어 외부, 내가 원하는 목적지 나는 창을 이동할 수 있습니다, 다시

 require(["dojo/dnd/move", "dojox/layout/FloatingPane", "dashboardFloatingPane", "dojo/domReady!"], 
     function(move, FloatingPane, dashboardFloatingPane) { 

      var widgetNode1 = dojo.byId("widget1"); 

      var floatingPane = new dashboardFloatingPane({ 
       title: "A floating pane", 
       resizable: true, 
       dockable: false, 
       style: "position:absolute;top:40px;left:40px;width:160px;height:100px;"  
       }, widgetNode1); 

      floatingPane.startup(); 
     }); 

그러나 :

define(["dojo/_base/declare", "dojo/dnd/move", "dojox/layout/FloatingPane"],  function(declare, move, FloatingPane){ 
return declare("dashboardFloatingPane", FloatingPane, { 

constructor: function() { 
     this.inherited(arguments); 
     this.moveable = new dojo.dnd.move.boxConstrainedMoveable(
      this.domNode, { 
       handle: this.focusNode, 
       constraints: { 
         l: 0, 
         t: 20, 
         w: 500, 
         h: 500        
        }, 
       within: true 
      } 
     );        
    } 
}); 
}); 

그럼 내가 여기 객체를 생성합니다

나는 별도의 모듈에 다음 코드를 배치 상자가 설정되었습니다. 어떤 아이디어라도 제발?

답변

1

dojox/layout/FloatingPane 클래스의 contructor이 아닌 postCreate 메서드를 재정의해야합니다.

이유는 원래 클래스가 자신의 이동 가능 유형으로 this.moveable을 설정했기 때문입니다. 따라서이를 재정의하려면 이후에 제약 조건이있는 이동 가능 유형에 다시 할당해야합니다.

이 시도 :

define(["dojo/_base/declare", "dojo/dnd/move", "dojox/layout/FloatingPane"], function(declare, move, FloatingPane){ 
    return declare("dashboardFloatingPane", FloatingPane, { 

    postCreate: function() { 
     this.inherited(arguments); 
     this.moveable = new dojo.dnd.move.boxConstrainedMoveable(
     // snip... 
    ); 
    } 
    }); 
}); 
+0

감사합니다, 그것은 완벽한 이해하게하고 지금 일하고있어 :). – L4zl0w

관련 문제