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

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.