CommandHandler scrollToPartPause

Hello,

while investigating a perceived performance problem when selecting the next similar node to the current selected one, I found a setter without documentation.
CommandHandler.scrollToPartPause. Setting this number didn’t have any visible impact as far as I could see. What does this do or is this a leftover?

I am also still wondering why scrollToPart() is very fast but delays diagram.select() that happens 1 line before that by around 100ms. This also only occurs when the scrollToPart() function needs to scroll the diagram.

That’s an undocumented property that controls how long the pause is between each time that the CommandHandler.scrollToPart command has to expand a tree or group. If the Part that you want to scroll to is already visible, then no such expansion automations are needed, so the property is not used.

I don’t know what you mean by “but delays diagram.select()”. You should be able to call Diagram.select at any time, assuming you have a reference to a Part.

However I can see why one would want to delay the automatic starting of text editing until after the scrolling is finished – it would be disconcerting if it tried to immediately start editing or whatever modal operation you want to conduct.

Thank you for explaining the undocumented setter. 👍

Our code does something like this: (pseudo code)

const similarItem= searchSimilarItem(diagram.selection);
if (similarItem) {
    diagram.select(similarItem);
    diagram.commandHandler.scrollToPart(similarItem);
}

You can always see the effect of the last line instantaneously but the selection sometimes takes around 100-200ms to actually change.
So far I seem to be able to reproduce it more often if scrollToPart() only wants to scroll less than 20px on the y axis only.

Edit: Changing the order of diagram.select and scrollToPart seems to fix the issue.