Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Change cursor if scrolling is enabled

$
0
0

@AlexLvovsky wrote:

I’m using GoJS 1.7.5
I have a diagram with TreeLayout, on some outer interaction, the model of my diagram is changed.
My goal is to change cursor:
If diagram has any of the scrolls, then the cursor should be ‘drag’, otherwise ‘auto’

I’ve made some implementation with this

this.myDiagram.addDiagramListener('ViewportBoundsChanged', () => {
  // allow scroll bar when documentBounds bigger than view space.
  this.myDiagram.allowHorizontalScroll = this.myDiagram.documentBounds.width > this.myDiagram.viewportBounds.width;
  this.myDiagram.hasHorizontalScrollbar = this.myDiagram.allowHorizontalScroll;
  this.myDiagram.allowVerticalScroll = this.myDiagram.documentBounds.height > this.myDiagram.viewportBounds.height;
  this.myDiagram.hasVerticalScrollbar = this.myDiagram.allowVerticalScroll;
  this.myDiagram.defaultCursor = this.myDiagram.hasHorizontalScrollbar || this.myDiagram.hasVerticalScrollbar ? 'drag' : 'auto';
  this.myDiagram.currentCursor = this.myDiagram.hasHorizontalScrollbar || this.myDiagram.hasVerticalScrollbar ? 'drag' : 'auto';
  this.myDiagram.contentAlignment = go.Spot.Center;
   // when drag scroll bar the pop up do not lost focus.So set the focus by code.
  this.myDiagram.focus();
});

But the thing is, when I load a new model, and my diagram has any of the scroll, the cursor is still ‘auto’, only after I start to drag, the cursor becomes ‘drag’ and doesn’t change back.
In opposite way, it works perfect, when I load model, that no scroll is needed, the cursor is ‘auto’ at the beginning.
How can I achieve it for the ‘drag’ cursor?

Here is what I did

You can click on “Switch model” to see the differences

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles