(selector: string)
| 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 |
nothing calls this directly
no test coverage detected