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