Now, left-click anywhere on the diagram repeatedly and eventually (sometimes it takes awhile), you will see the flicker. It appears that the canvas tries to move to the top of the browser before re-adjusting to where it should be. It happens very quickly causing the browser to appear to flicker.
In our own more complex implementation with GoJS with many more nodes and groups, the flickering is more apparent and pretty annoying. I have no clue as to how to fix this. Any ideas? Or, if it is IE11 being IE11 ( a bug with it handling canvas), any idea on how to reduce the frequency of it?
Just tried that on a test page on my machine. The flickering issue stops, however, it scrolls the browser window down so the canvas is at the top. Anything above that, like a row of buttons, is now out of view.
Right, I got that. :-) I need it set to false to stop that behavior (and false is the default value I believe) so that content above the GoJS diagram remains in view. But, the flicker issue occurs in IE11. Chrome behaves just fine. Most of our customers are relegated to using IE11.
I was curious as to why it is necessary to call the scrollTo function in the “else” branch? I’m thinking this is causing the issue since IE11 seems to have various scrolling bugs, one being “smooth scrolling”. I disabled that on my end, but the issue still persists.
As far as implementing “GainedFocus” and “LostFocus” DiagramEvent listeners, I’m not sure what to do inside that code. Will it override Diagram.focus? We are trying to keep any hacks to a minimum. :-)
Well, out of curiosity, when I comment out the focus line in the else branch, the flickering issue stops. I don’t immediately see any adverse effects. Thoughts?
public focus(): void {
if (!this._canvas) return;
if (this.scrollsPageOnFocus) {
this._canvas.focus();
} else { // root is normally window
const x = root.scrollX || root.pageXOffset;
const y = root.scrollY || root.pageYOffset;
//this._canvas.focus();
root.scrollTo(x, y);
}
}
Note that the ._canvas property is not public, and in fact is minified.
But then the canvas element might not have focus! That’s the purpose of the Diagram.focus method, after all. And there would be no reason for calling scrollTo.