devexpress-richedit
Version:
DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.
44 lines (43 loc) • 1.38 kB
JavaScript
import { EventDispatcher } from '../utils/event-dispatcher';
import { BatchUpdatableObject } from '@devexpress/utils/lib/class/batch-updatable';
export class ScrollFormatter extends BatchUpdatableObject {
scrollManager;
layout;
onScrollLayoutChanged = new EventDispatcher();
canvasState;
constructor(scrollManager, layout) {
super();
this.scrollManager = scrollManager;
this.layout = layout;
}
NotifyPagesReady(_pageChanges) {
this.process();
}
NotifyFullyFormatted(_pageCount) {
this.process();
}
;
NotifyScrollChanged() {
this.process();
}
onUpdateUnlocked(_occurredEvents) {
this.process();
}
process() {
const modelState = this.scrollManager.state;
if (modelState) {
this.canvasState = modelState.getCanvasState(this.layout);
if (this.canvasState || this.layout.isFullyFormatted)
this.scrollManager.init();
}
if (this.isUpdateLocked())
return;
if (this.canvasState) {
this.raiseScrollChanged();
this.canvasState = null;
}
}
raiseScrollChanged() {
this.onScrollLayoutChanged.listeners.forEach(listener => listener.NotifyScrollPositionChanged(this.canvasState));
}
}