viewportChange event question

According to the documentation, the viewportChange event is fired for due to scrolling, editing or any other factor. Is there a way to tell whether the viewportChange is because of scrolling Or editing.

In case of editing, I would like to x & y operations
In case of scrolling, I would like to do just y operation.

thanks,
–srini

No, there isn’t. But there are "scroll" and "change" events that can tell you when those things happen.

Thanks Martin.

I looked at “change” and “scroll” events.

When I type (say “a”) in the editor, I get “change” event
When I scroll the editor (either through keyboard navigation or using scrollbar), I get “scroll” event.
When I type “a” and hit enter (say, the editor shows 1 to 20 lines, put cursor at line 10 and hit enter), I was expecting to get both “change” and “scroll” event. But I got the “change” event, but not the “scroll” event.

“scroll” event says “fires when the editor is scrolled”…if the scrollbar is changing & editor content is shifted down (when I hit return)…shouldn’t that trigger scroll event? May be I misunderstood the doc?

thanks,

–srini

1 Like

"scroll" is fired when the scrollTop of the viewport changes. Content being shifted down does not cause it to fire. (But you can easily inspect the content of a change event object to see whether the amount of lines in the editor changed: change.to.line - change.from.line != change.text.length - 1 should do it).

1 Like