fixed last of scroll position view in portrait mode to remember & display user's last line at bottom of applet viewport
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Disco DeDisco
2026-03-24 19:11:27 -04:00
parent 8bab26e003
commit 11c85d56d1

View File

@@ -7,21 +7,24 @@
var scroll = document.getElementById('id_drama_scroll');
if (!scroll) return;
// Push buffer so its top aligns with the bottom of the aperture when all
// events fit within the viewport (no natural scrolling). For longer scrolls
// the buffer top naturally appears at the aperture bottom when the last event
// clears the top of the visible area.
var buffer = scroll.querySelector('.scroll-buffer');
if (buffer) {
var eventsHeight = scroll.scrollHeight - buffer.offsetHeight;
var gap = scroll.clientHeight - eventsHeight;
if (gap > 0) {
buffer.style.marginTop = gap + 'px';
// Defer dimension-dependent work until after flex layout resolves.
// Inline scripts can run before nested flex heights are computed, producing
// wrong scrollHeight/clientHeight values (symptom: incorrect marginTop on mobile).
requestAnimationFrame(function() {
// Push buffer so its top aligns with the bottom of the aperture when all
// events fit within the viewport (no natural scrolling).
var buffer = scroll.querySelector('.scroll-buffer');
if (buffer) {
var eventsHeight = scroll.scrollHeight - buffer.offsetHeight;
var gap = scroll.clientHeight - eventsHeight;
if (gap > 0) {
buffer.style.marginTop = gap + 'px';
}
}
}
// Restore: position stored is bottom-of-viewport; subtract clientHeight to align it
scroll.scrollTop = Math.max(0, {{ scroll_position }} - scroll.clientHeight);
// Restore: position stored is bottom-of-viewport; subtract clientHeight to align it
scroll.scrollTop = Math.max(0, {{ scroll_position }} - scroll.clientHeight);
});
// Animate "What happens next. . . ?" buffer dots — 4th span shows '?'
var dotsWrap = scroll.querySelector('.scroll-buffer-dots');