Google Chrome and drag to scroll

会有一股神秘感。 提交于 2019-12-02 16:11:44

问题


I am developing a website: http://www.techniquetolife.com It's basically a div 5x as big as the window inside window sized div, with other divs within the large div, using the overscroll and scrollTo plugins to navigate.

The website works perfectly fine in Safari and Firefox for OS/X. But I am having serious trouble making it work in Chrome. I'm not sure if it's an Chrome OS/X only problem, but whenever I scroll over one of the inner divs within the large div, the whole browser slows down, this only happens in Chrome...

If I disable overscroll and use the scrollbars it works 100% fine, but I really want to use the overscroll drag to scroll plugin.

I am no good at coding so any help would be greatly appreciated.

All of the plugins / browsers are on the latest version.


回答1:


Okay, well I posted an answer to a similar question that I think this might be related too. I could be wrong though, but you could test it.

See the full question and my full answer here: Chrome slow scrolling with fixed position elements

Problem and How to Monitor It

The reason for this is because Chrome for some reasons decides it needs to redecode and resize any images when a fixed panel goes over it. You can see this particularly well with

► Right Click Page -> Inspect Element -> Timeline -> Frames

► Hit Record on bottom

► Go back to the page and drag scrollbar up and down

This seems to just be a problem with the method Chrome is using to determine if a lower element needs to be repainted.

To make matters worse, you can't even get around the issue by creating a div above a scrollable div to avoid using the position:fixed attribute. This will actually cause the same effect. Pretty much Chrome says if anything on the page has to be drawn over an image (even in an iframe, div or whatever it might be), repaint that image. So despite what div/frame you are scrolling it, the problem persists.

The Easy Hack Solution

But I did find one hack to get around this issue that seems to have no downside as of now. By adding

-webkit-transform: translateZ(0); 

To your fixed panel, putting that div in its own compositing layer.



来源:https://stackoverflow.com/questions/14829022/google-chrome-and-drag-to-scroll

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