Mobile: page scroll sticks / stops as if the end was reached (Header Builder + responsive overflow-x
Betheme: 29.0.7 (also seen on 28.5.x and 29.0.2.1 on other sites). Header Builder (mfn-header-template), WooCommerce 11, Theme Options - Responsive - "Overflow-x hidden on mobile" enabled.
PROBLEM
On phones (iOS Safari and Android Chrome) the page often stops scrolling in the middle of a swipe. It bounces as if the end of the page was reached, and you need 2-3 swipes before it scrolls again. It happens most while the page is still loading, and when scrolling up from the footer. We reproduced it on several Betheme sites.
CAUSES WE FOUND
1) js/scripts.js: topBarTopPosition() (around line 414, called from document ready around line 3978)
If the page is already scrolled, it calls window.scrollTo(0,0) and $(window).scrollTop(0), then scrolls back, to measure #Top_bar. With the Header Builder #Top_bar does not exist, so the measurement does nothing, but the double jump interrupts the momentum scroll of a user who started swiping before document ready.
Suggestion: return early when #Top_bar is missing, e.g. if ( ! $('#Top_bar').length ) return;
2) css/responsive.min.css: html{overflow-x:hidden} and body.responsive-overflow-x-mobile{overflow-x:hidden}
By the CSS spec, overflow-x:hidden forces overflow-y:auto, so body becomes its own scroll container inside the html scroller. Any element that sticks out 1px below body (for example WooCommerce's hidden .widget_shopping_cart_live_region.screen-reader-text) makes body scrollable by 1px. The touch gesture latches onto body, scrolls 1px and stops. On some phones a thin scrollbar is even visible on body.
The same happens with css/be.min.css: .mfn-footer{overflow-x:hidden}, which makes the builder footer a scroll container too.
Suggestion: use overflow-x: clip (clips horizontally without creating a scroll container, supported in all current browsers), with hidden as fallback:
@supports (overflow-x: clip) { body.responsive-overflow-x-mobile, body.responsive-overflow-x-tablet, .mfn-footer { overflow-x: clip; } }
3) (minor) The Theme Options Custom JS is printed in the same inline script as other wp_add_inline_script( 'mfn-scripts', ..., 'after' ) code, so one runtime error in the user's custom JS stops every other inline script attached to mfn-scripts. Printing Custom JS in its own handle (or wrapping it in try/catch) would isolate it.
WORKAROUND
In the child theme we use the CSS above plus a guard that ignores window.scrollTo until Betheme's document-ready handler has run when #Top_bar is absent. With it the scroll no longer sticks. We would be glad to see this fixed in the theme itself so it survives updates.
Thank you!
Comments
Hi,
I have passed it on to the dev team, and we will correct that in upcoming updates.
Thanks for reporting.
Best regards