@@ -128,6 +128,7 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
128128 __selectedItemId : null ,
129129 __startHint : null ,
130130 __dropHint : null ,
131+ __panning : null ,
131132
132133 _addItemsToLayout : function ( ) {
133134 this . __addInputNodesLayout ( ) ;
@@ -148,7 +149,7 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
148149 } ) ;
149150
150151 const workbenchLayoutScroll = this . _workbenchLayoutScroll = new qx . ui . container . Scroll ( ) ;
151- osparc . utils . Utils . setIdToWidget ( workbenchLayoutScroll , "hithere " ) ;
152+ osparc . utils . Utils . setIdToWidget ( workbenchLayoutScroll , "WorkbenchUI-scroll " ) ;
152153 const workbenchLayout = this . __workbenchLayout = new qx . ui . container . Composite ( new qx . ui . layout . Canvas ( ) ) ;
153154 workbenchLayoutScroll . add ( workbenchLayout ) ;
154155 workbenchLayer . add ( workbenchLayoutScroll , {
@@ -1097,6 +1098,39 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
10971098 } ;
10981099 } ,
10991100
1101+ __mouseDown : function ( e ) {
1102+ if ( e . isMiddlePressed ( ) ) {
1103+ this . __panning = true ;
1104+ this . __pointerPos = this . __pointerEventToWorkbenchPos ( e , true ) ;
1105+ this . set ( {
1106+ cursor : "move"
1107+ } ) ;
1108+ }
1109+ } ,
1110+
1111+ __mouseMove : function ( e ) {
1112+ if ( this . __panning && e . isMiddlePressed ( ) ) {
1113+ const oldPos = this . __pointerPos ;
1114+ const newPos = this . __pointerPos = this . __pointerEventToWorkbenchPos ( e , true ) ;
1115+ const moveX = parseInt ( ( oldPos . x - newPos . x ) * this . getScale ( ) ) ;
1116+ const moveY = parseInt ( ( oldPos . y - newPos . y ) * this . getScale ( ) ) ;
1117+ this . _workbenchLayoutScroll . scrollToX ( this . _workbenchLayoutScroll . getScrollX ( ) + moveX ) ;
1118+ this . _workbenchLayoutScroll . scrollToY ( this . _workbenchLayoutScroll . getScrollY ( ) + moveY ) ;
1119+ this . set ( {
1120+ cursor : "move"
1121+ } ) ;
1122+ }
1123+ } ,
1124+
1125+ __mouseUp : function ( ) {
1126+ if ( this . __panning ) {
1127+ this . __panning = false ;
1128+ this . set ( {
1129+ cursor : "auto"
1130+ } ) ;
1131+ }
1132+ } ,
1133+
11001134 __mouseWheel : function ( e ) {
11011135 this . __pointerPos = this . __pointerEventToWorkbenchPos ( e , false ) ;
11021136 const zoomIn = e . getWheelDelta ( ) < 0 ;
@@ -1218,6 +1252,9 @@ qx.Class.define("osparc.component.workbench.WorkbenchUI", {
12181252 domEl . addEventListener ( "drop" , this . __drop . bind ( this ) , false ) ;
12191253
12201254 this . addListener ( "mousewheel" , this . __mouseWheel , this ) ;
1255+ this . addListener ( "mousedown" , this . __mouseDown , this ) ;
1256+ this . addListener ( "mousemove" , this . __mouseMove , this ) ;
1257+ this . addListener ( "mouseup" , this . __mouseUp , this ) ;
12211258
12221259 commandDel . setEnabled ( true ) ;
12231260 commandEsc . setEnabled ( true ) ;
0 commit comments