Refine line-based story scrolling

This commit is contained in:
2026-05-16 21:40:36 +02:00
parent b9ae7f71c5
commit e368d252ad
10 changed files with 1238 additions and 755 deletions
+16 -9
View File
@@ -21,6 +21,7 @@ class PlaybackCoordinatorModule extends BaseModule {
'calculateWordTimings',
'animateWords',
'waitForAudioStart',
'completeSentenceVisual',
'fastForward',
'stop'
]);
@@ -81,11 +82,25 @@ class PlaybackCoordinatorModule extends BaseModule {
console.error('PlaybackCoordinator: Error during playback:', error);
throw error;
} finally {
this.completeSentenceVisual(sentence);
this.isPlaying = false;
this.currentSentence = null;
}
}
completeSentenceVisual(sentence) {
if (!sentence?.element) return;
sentence.element.dataset.playbackComplete = 'true';
sentence.element.querySelectorAll('.word').forEach(word => {
word.style.transition = 'none';
word.style.animation = 'none';
word.style.visibility = 'visible';
word.style.opacity = '1';
word.style.transform = 'translateY(0)';
word.style.clipPath = 'inset(0 0 0 0)';
});
}
/**
* Play TTS audio for a sentence
* @param {Object} sentence - Sentence object with TTS data
@@ -307,15 +322,7 @@ class PlaybackCoordinatorModule extends BaseModule {
}
// Complete all word animations immediately
if (this.currentSentence.element) {
const wordElements = this.currentSentence.element.querySelectorAll('.word');
wordElements.forEach(word => {
word.style.animation = 'none';
word.style.opacity = '1';
word.style.transform = 'translateY(0)';
word.style.clipPath = 'inset(0 0 0 0)';
});
}
this.completeSentenceVisual(this.currentSentence);
}
/**