in client/src/components/translation-selector/translation-selector.ts [78:97]
onSelectedWordChanged(ev: {index: number, word: WordTranslation|null}) {
if (this.audioState !== AudioState.Stopped) {
this.audioState = AudioState.Stopped;
const audioPlayer = this.audioPlayer ? this.audioPlayer.nativeElement as HTMLAudioElement : null;
if (audioPlayer) {
audioPlayer.pause();
audioPlayer.currentTime = 0;
}
}
// will be fired immediately after "translations" is set, so need to delay changing
// state again by a frame to avoid "expression changed after it was checked" error
setTimeout(() => {
this.selectedWordVisible = !!ev.word;
// don't set selectedWord to null - we don't want to immediately hide translation, but transition out
if (ev.word) {
this.selectedWord = ev.word;
}
}, 1);
this.selectedWordChanged.emit(ev);
}