fix: backend: make scrollToAnchor() robust against late layout shifts#6555
Conversation
redaxo#6490 Verbesserung für JavaScript scrollToAnchor() im Backend
| block: "start", | ||
| behavior: "smooth" | ||
| }); | ||
| }, 200); |
There was a problem hiding this comment.
250 ms liefert noch ein besseres Ergebnis, ich weiss nur nicht wie ich hier den PR noch ändern kann :)
There was a problem hiding this comment.
Du musst den Wert nur in deinem branch ändern
Use scrollIntoView() (which honors the CSS scroll-padding-top, so the sticky navbar offset no longer needs manual correction) and defer the initial scroll via requestAnimationFrame instead of a guessed setTimeout. Re-scroll when still-loading images in the pjax container finish, since they shift the layout and push the anchor out of position; stop as soon as the user scrolls manually.
|
Mich störte die fixe Timeout-Zahl, es zeigte sich ja schon in den Tests, dass nicht klar ist, welcher Wert nun benötigt wird (200ms vs 250ms etc.). Daher habe ich Claude um Hilfe gebeten. Die Variante ist deutlich länger, aber wohl robuster. @aeberhard @ynamite @skerbis Könnt ihr einschätzen, ob die neue Variante taugt? Und bei euch mal testen? Liegt hier im PR jetzt (kann sie sonst aber auch wieder entfernen, wenn sie nicht taugt). Hier noch eine Meldung von Claude:
|
|
Also in meinen ersten Tests funktioniert das sehr sauber, danke @gharlan |
|
Meine Tests sind auch erfolgreich! Sehr gut @gharlan Danke! |
#6490 Verbesserung für JavaScript scrollToAnchor() im Backend