3

I'm playing with parallax at the moment and have an issue:

Here's the markup

<div class="welcome"></div>
<div class="welcome2" data-0="top: 100%;" data-1000="top: 0%;"></div>
<div class="weclome_text">
    <h3 data-0="color: rgb(82,98,130);" data-1000="color: rgb(255,255,255);">Hello World</h3>
    <div class="scroll-button" data-0="opacity: 1;" data-300="opacity: 0;"></div>
</div>

And CSS:

html,body { margin: 0; padding: 0; font-family: Sans-serif; }

body {
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.welcome { position: fixed; top: 0; width: 100%; height: 100%; background: url(http://justdade.com/t/bg1.png) no-repeat; background-size: cover; }
.welcome2 { position: fixed; top: 100%; width: 100%; height: 100%; background: url(http://justdade.com/t/bg2.png) no-repeat; background-size: cover; }

.weclome_text {
    position: fixed; position: fixed; top: 50%; left: 50%; margin-left: -60px; margin-top: -60px; width: 120px; height: 120px; color: #526282;
    text-align: center;
}
.scroll-button { background: url(http://justdade.com/t/scroll-button.png); width: 60px; height: 60px; cursor: pointer; margin: 0 auto; }

JSFiddle

Everything seems okay in all browsers expect Safari (Desktop, iOS also okay)

Safari scroll animation is lagging pretty hard after I press "scroll" arrow. I also noticed that scroll lags starts only if I use position: fixed;

Maybe someone can give me any clue where I should dig?

Thank you.

Wickd
  • 156
  • 2
  • 11

1 Answers1

3

Okay, so I'm not sure what the problem really was. But after doing lots of googling I found the solution. And it's:

div { -webkit-transform: translateZ(0);-webkit-backface-visibility: hidden;-webkit-perspective: 1000; }

I know It's not the best way. But it fits for me. Apparently this activates hardware acceleration on Safari browser and animation runs like a charm.

I'm also using

data-0="transform: translate(0%,0%)" data-1200="transform: translate(0%, -100%)"

Props to Prinzhorn. Instead of top: 0; top: 100;

Wickd
  • 156
  • 2
  • 11