The vertical scroll bar of the browser is moved up to the top automatically

Hi

I have a question , my page is divend into 2 section the first is the top is shown GoJS Diagram and the last is bottom is shown the description diagram (it’s same as your example such as http://gojs.net/latest/samples/stateChart.html) but when we scroll vertical bar of the browser to bottom a little bit in order to read description and when I click the node on diagram, the vertical scroll bar of the browser is moved up to the top automatically. Did you have any solution to fix this?

Have you seen Canvas shift on palette drop ?

Thank you walter :),

I have seen the code as like this.

myDiagram.doFocus = function() {
  // sometimes, maybe when a flag is set, disallow focus
  if (/* some condition that you set */) return;

  // otherwise do the default focus behavior:
  go.Diagram.prototype.doFocus.call(this);
}

but I have one question, if I want to delete or edit the selected node how to apply this code? I have seen “doFocus” is called before “ObjectSingleClicked” or “ObjectDoubleClicked” that why I cannot mark any flag in the if condition.

:)

Hi walter

I have fixed by using this code

myDiagram.doFocus = function() {    		 
		 go.Diagram.prototype.doFocus.call(this);
		 window.scrollTo(0,_top);
}

This code is ok, the node on diagram can be copied or deleted using keypress but I think this solution it’s not good. Did u have any suggestion?

thx :)

What’s the problem with what you wrote, as far as your application is concerned?

For 1.7 and after, try:

myDiagram.doFocus = function() {
  var x = window.scrollX || window.pageXOffset;
  var y = window.scrollY || window.pageYOffset;
  go.Diagram.prototype.doFocus.call(this);
  window.scrollTo(x, y);
}

This will let it focus, but stop the scrolling. It seems to work on Chrome, Firefox, IE11, and iOS Safari

Hi walter, simon

Thank you for your support, Actually I don’t know about “go.Diagram.prototype.doFocus” function too much but I just wonder about Synchronous function of the “go.Diagram.prototype.doFocus” (maybe occurred in the future).

Is it possible that be occurs in this case when the program execute “go.Diagram.prototype.doFocus.call(this)” the vertical scroll bar is moved up first and then execute “window.scrollTo(0,_top)” the vertical scroll bar is moved down. something like this.

Thank you. :)

I’m not sure what you mean. Does Simon’s suggested override of Diagram.doFocus not have the results that you want?

Hi walter

My problem is fixed already. Thank you very much