ViewportBoundsChanged Event


Is there anyway to workout from the ViewportBoundsChanged event whether the event was triggered by a diagram scroll or by setting the diagram.scale?

I initially thought I could use the event.subject.isScroll property, but this seems to be false in both cases for me.

I have the mousewheel behaviour set to WheelZoom - I don’t know if that makes a difference?


The “ViewportBoundsChanged” DiagramEvent will have a DiagramEvent.subject that is a JavaScript object whose scale property is the old Diagram.scale value and whose position property is the old Diagram.position value.

So for example if you want to see if the scale had changed:

  if (e.subject.scale !== e.diagram.scale) . . . 

Or if you want to know whether the position had changed:

  if (!e.subject.position.equals(e.diagram.position)) . . .

Note that when the Diagram.scale changes it is almost always the case that the Diagram.position will change.