Panning

Hi ,

I want to make a vertical panning when the user press Shift and mousewheel.
Actually is horizontal.

  myFullDiagram.toolManager.doMouseWheel = function () {
                             // swap the InputEvent.control and .shift properties
                             var e = myFullDiagram.lastInput;
                        
                             if (e.alt) e.modifiers = 4;
                             else if (e.shift) {
                                 myFullDiagram.toolManager.panningTool.doActivate();
                             }
                             else if (e.control) e.modifiers = 1;
                           
                             // now call the base method
                             go.ToolManager.prototype.doMouseWheel.call(myFullDiagram.toolManager);
                         };

Thanks

I don’t see why you would want to call doActivate on the PanningTool each time the user turns the wheel a bit. Normally ToolManager.doMouseWheel just calls standardMouseWheel to implement the standard behavior. Here’s how that is defined:

Tool.prototype.standardMouseWheel = function() { var diagram = this.diagram; if (diagram === null) return; var e = diagram.lastInput; var delta = e.delta; if (delta === 0) return; if (!diagram.documentBounds.isReal()) return; var cmd = diagram.commandHandler; var wheelBehavior = diagram.toolManager.mouseWheelBehavior; if (((wheelBehavior === ToolManager.WheelZoom && !e.shift) || (wheelBehavior === ToolManager.WheelScroll && e.control)) && (delta > 0 ? cmd.canIncreaseZoom() : cmd.canDecreaseZoom())) { // zoom in or out at current mouse point var oldzoom = diagram.zoomPoint; diagram.zoomPoint = e.viewPoint; if (delta > 0) cmd.increaseZoom(); else cmd.decreaseZoom(); diagram.zoomPoint = oldzoom; e.bubbles = false; } else if ((wheelBehavior === ToolManager.WheelZoom && e.shift) || (wheelBehavior === ToolManager.WheelScroll && !e.control)) { var oldpos = diagram.position.copy(); var total = (delta > 0) ? delta : -delta; // 48 pixels is normal (3 lines, 16*3) // 120 is the normal delta if (!e.shift && diagram.allowVerticalScroll) { // scroll up or down var c = diagram.scrollVerticalLineChange total = (total / 40) * c; if (delta > 0) diagram.scroll('pixel', 'up', total); else diagram.scroll('pixel', 'down', total); } else if (e.shift && diagram.allowHorizontalScroll) { // scroll left or right var c = diagram.scrollHorizontalLineChange total = (total / 40) * c; if (delta > 0) diagram.scroll('pixel', 'left', total); else diagram.scroll('pixel', 'right', total); } if (!diagram.position.equals(oldpos)) { e.bubbles = false; } } };
I hope you can adapt the code for your own purposes.