lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
35 lines • 1.49 kB
JavaScript
import { UntargetableTricklingEvent } from './UntargetableTricklingEvent.js';
/**
* An auto-scroll {@link UntargetableTricklingEvent}. Dispatched when a widget
* (or part of a widget) wants to be visible to the user, such as the current
* caret position when typing a character.
*
* This event is not static. As the event propagates in the UI tree, it will be
* updated so that the wanted bounds are up-to-date.
*
* Note that this event is handled via {@link Widget#dispatchEvent} in a special
* case; widgets will auto-capture the event if they are
* {@link AutoScrollEvent#originallyRelativeTo}. The event must be re-captured
* by scrollable containers if a child of those containers captured the event,
* and {@link AutoScrollEvent#bounds} must be updated accordingly. See
* {@link ScrollableViewportWidget#handleEvent} for an example of this.
*
* @category Event
*/
export class AutoScrollEvent extends UntargetableTricklingEvent {
constructor(originallyRelativeTo, bounds) {
super();
this.type = AutoScrollEvent.type;
this.focusType = null;
this.needsFocus = false;
this.userCapturable = true;
this.originallyRelativeTo = originallyRelativeTo;
this.bounds = [...bounds];
}
cloneWithTarget(target) {
super.warnUntargetable(target);
return new AutoScrollEvent(this.originallyRelativeTo, this.bounds);
}
}
AutoScrollEvent.type = 'auto-scroll';
//# sourceMappingURL=AutoScrollEvent.js.map