| 351 | this.hidePreview(); |
| 352 | // Clear indicators when hiding to prevent showing stale data |
| 353 | const indicatorsContainer = document.getElementById('message-indicators'); |
| 354 | if (indicatorsContainer) { |
| 355 | indicatorsContainer.innerHTML = ''; |
| 356 | } |
| 357 | this.messages = []; |
| 358 | this.currentMessageIndex = 0; |
| 359 | this.clickedIndex = null; |
| 360 | this.awaitingScrollEnd = false; |
| 361 | clearTimeout(this.scrollEndTimer); |
| 362 | } |
| 363 | |
| 364 | // Track scroll position to update current message |
| 365 | handleScroll() { |
| 366 | if (!this.isVisible) return; |
| 367 | if (this.isNavigating) return; // Still in programmatic scroll |
| 368 | |
| 369 | // If waiting for scroll animation to end, use debounce to detect scroll stop |
| 370 | if (this.awaitingScrollEnd) { |
| 371 | clearTimeout(this.scrollEndTimer); |
| 372 | this.scrollEndTimer = setTimeout(() => { |