Search code examples
cssgoogle-chromeskrollr

Skrollr Troubles With Chrome Browser


I'm learning how to use the Skrollr.js library. Awesome cool tool on using the scroll bar in the DOM to manipulate the appearance of a web site. It does have a bit of a steep learning curve to understand exactly how it works. I'm playing with a simple sample. I have an image that I want to stay on screen in the background for 500% of vertical height. I have other text items that I want to scroll in the foreground. I wanted to do a test and have one of the text items fade to zero.

helpful references: Classic Parallax Scrolling Example, and I Hate Tomatoes Example

I've got an image in a div loaded in a position: fixed; location, and a few divs in the scrolling area below <div id="skrollr-body"> I have a text header that I wanted to fade to zero as I use the scroll bar. Note: I started skrollr.init() without any arguments. Also, I am not using jQuery at all.

My problem is it works erratically on Chrome, and works just fine on Firefox browser. I'm at a loss to figure out why?

I've created a jsFiddle to exhibit the issue. http://jsfiddle.net/q3z3v6op/4/ Fiddle works the same as my test program; Flaky on Chrome, okay on Firefox. When looking in the Chrome dev tools, you can easily see that the red box text opacity value is changing correctly to zero as the box goes towards the top of the display, but the actual display doesn't fade most of the time. I can get it to work if I go to the Chrome Dev tools, open up the drawer (where the console / search / emulation / rendering tab is), then select 'rendering' and click on [ ] Enable Continuous Page Repainting.

Anybody else been here? Any ideas what's going on with this issue? Many thanks.


Solution

  • I updated your fiddle. This is a little bit of a different approach, but it should be more cross browser compatible. I guess Chrome does not like display: block and opacity: 0. This looks like a bug. I tested in on Safari (which is also WebKit) and it does not have a problem. By using inline-block I was able to fix the bug on Chrome.

    http://jsfiddle.net/christianjuth/q3z3v6op/5/

    Fixed code:

    .hsContent {
        display: inline-block;
        position: absolute;
        left: 50%;
        width: 400px;
        margin-left: calc(-200px - 8%);
        color: #ebebeb;
        padding: 0% 8%;
        text-align: center;
    }