Invalid mobile window.onscroll

<script>
    

    
    var stickyEl = document.querySelector(".pannle-label");
    
    
    function fixed() {
        var u = navigator.userAgent;
        var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; 
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //
        if(isAndroid) {
                console.log("isAndroid")
                window.onscroll = function() {
                console.log(2222);
                var scrollT = document.documentElement.scrollTop||document.body.scrollTop;                
                if (scrollT > 160) {
                    $(stickyEl).addClass("fixed-top");
                }else {
                    $(stickyEl).removeClass("fixed-top");
                }
                };
                
        }else if(isiOS) {
            console.log("isiOS");
            $(stickyEl).addClass("sticky");
            
        }
    }
    fixed();

        
    
    </script>

as shown in the code above, there are effects on ios, but if there are problems on Android, let me make a list of questions and take a look at

  1. the console didn"t output 2222 when I was scrolling
  2. I also see that there seems to be a problem with overflow with css, but I don"t know exactly
  3. css is it possible that the display:none; of the scroll bar is this problem

solve!

Mar.30,2021

I can use Chrome to simulate ios and Android devices. Android devices can print isAndroid and 2222 , ios print isIOS , I directly use < div style= "width: auto; height: 7000px;" class= "panel-label" > < / div >


looks like an attractive menu effect
guess is that the browser kernel optimizes the action while scrolling, causing the onscroll to be suspended during scrolling.

ps:
this code, if iOS executes the Android part, there seems to be a problem.
this computer side cannot be simulated by chrome.
you can see that JD.com and Taobao on mobile phones all use this effect. If you execute it in their client, you will get the same result as their effect

.

General solution: this layout is not used (2333) because of compatibility issues. Position:sticky Android in the
CSS attribute can also be used, but even with the-webkit prefix, some browser kernels do not support
or block the browser's default behavior under the onscroll method. Use a tool like js, like iscroll instead, but in this case, you need to implement the scrolling effect yourself, and the performance will be much worse.

Menu