Overflow:auto from overflow:hidden in firefox is triggering a scroll event

雨燕双飞 提交于 2019-12-11 04:09:53

问题


Open the html with shared code in Chrome and try to scroll on the content.An alert will be generated for scroll.

After Pressing OK click hover on the div and there will be no issue.

Now open the same code in Firefox.Scroll once and there will be alert shown. Press on ok.

Hover over the div now and you will see scroll event getting called even on hover where we are setting overflow:auto from overflow:hidden

Sharing the code below:-

<!DOCTYPE html>
    <html>`enter code here`
    <head>`enter code here`
    <style>
    div {
        background: yellow;
        border: 1px solid black;
        padding: 10px;
    }
    
    #myDIV {
        border: 1px solid black;
        width: 200px;
        height: 100px;
        overflow: hidden;
    }
    
    #myDIV:hover {
    	overflow-x: hidden;
        overflow-y: auto;
    }
    </style>
    </head>
    <body>
    
    <div id="myDIV">
    In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
    <br><br>
    'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'
    </div>
    
    <script>
    
    document.getElementById("myDIV").addEventListener("scroll", myFunction1);
    
    function myFunction1() {
        console.log("Scroll is called");
    }
    
    
    </script>
    
    </body>
    </html>

来源:https://stackoverflow.com/questions/53608738/overflowauto-from-overflowhidden-in-firefox-is-triggering-a-scroll-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!