MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / bind

Method bind

src/actions/Dialog.ts:91–116  ·  view source on GitHub ↗
(selector: string)

Source from the content-addressed store, hash-verified

89 }
90
91 static override async bind(selector: string): Promise<void> {
92 // Add listener for the text speed setting (TypeWriter reads from preference directly)
93 const engine = this.engine;
94 const clamp = (num: number, min: number, max: number): number => Math.min(Math.max(num, min), max);
95 $_(`${selector} [data-action="set-text-speed"]`).on('change mouseover', function (this: HTMLInputElement) {
96 const textbox = engine.element().find('[data-component="text-box"] [data-component="type-writer"]').get(0) as TypeWriter | undefined;
97 const maxTextSpeed = engine.setting('maxTextSpeed') as number;
98 const minPlaySpeed = engine.setting('minTextSpeed') as number;
99 const value = clamp(parseInt(this.value), minPlaySpeed, maxTextSpeed);
100
101 engine.preference('TextSpeed', value);
102 textbox?.setState({ config: { typeSpeed: value } });
103 });
104
105 // Detect scroll on the text element to remove the unread class used when
106 // there's text not being shown in NVL mode.
107 $_(`${selector} [data-component="text-box"] [data-content="text"]`).on('scroll', () => {
108 const text_box = this.engine.element().find('[data-component="text-box"]');
109 if (text_box.exists()) {
110 const element = text_box.get(0) as any;
111 if (typeof element.checkUnread === 'function') {
112 element.checkUnread();
113 }
114 }
115 });
116 }
117
118 static override async init(selector: string): Promise<void> {
119 // Remove the Text Speed setting if the type animation was disabled

Callers

nothing calls this directly

Calls 6

settingMethod · 0.80
preferenceMethod · 0.80
checkUnreadMethod · 0.80
onMethod · 0.65
getMethod · 0.65
elementMethod · 0.45

Tested by

no test coverage detected