A platform for community discussion. Free, open, simple.
UX: Extend Safari scrolling fix to work in iPad PWA (#30894)
David Taylor5ac308fe85cc
diff --git a/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs b/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjsindex be18abe84cd..3c690da5393 100644--- a/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs+++ b/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs@@ -96,15 +96,23 @@ export default class GlimmerSiteHeader extends Component {document.documentElement.getBoundingClientRect().top);- const headerWrapTop =- this._headerWrap.getBoundingClientRect().top - overscrollPx;+ // Tends to be zero, but is set higher when on iPad PWA with the 'footer-navigation' at top of screen+ const headerCssTop = parseInt(+ window.getComputedStyle(this._headerWrap).getPropertyValue("top"),+ 10+ );+let headerWrapBottom =this._headerWrap.getBoundingClientRect().bottom - overscrollPx;- // While scrolling on iOS, an element fixed to the top of the screen can have a `top` which fluctuates- // between -1 and 1. To avoid that fluctuation affecting the header offset, we subtract that tiny fluctuation from the bottom value.- if (Math.abs(headerWrapTop) < 1) {- headerWrapBottom -= headerWrapTop;+ // While scrolling on iOS, fixed elements can have a viewport position which fluctuates between -1 and 1.+ // To avoid that fluctuation affecting the header offset, we subtract that tiny fluctuation from the header-offset.+ const headerWrapTopDiff =+ this._headerWrap.getBoundingClientRect().top -+ overscrollPx -+ headerCssTop;+ if (Math.abs(headerWrapTopDiff) < 1) {+ headerWrapBottom -= headerWrapTopDiff;}let mainOutletOffsetTop = Math.max(