简体   繁体   English

Skrollr,Safari,固定位置滞后

[英]Skrollr, Safari, fixed position lags

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: 和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 的jsfiddle

Everything seems okay in all browsers expect Safari (Desktop, iOS also okay) 在所有浏览器中,一切似乎都可以,期待Safari(桌面,iOS也可以)

Safari scroll animation is lagging pretty hard after I press "scroll" arrow. 按“滚动”箭头后,Safari滚动动画相当滞后。 I also noticed that scroll lags starts only if I use position: fixed; 我也注意到只有当我使用position:fixed时才会启动滚动滞后;

Maybe someone can give me any clue where I should dig? 也许有人可以给我任何线索,我应该挖?

Thank you. 谢谢。

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. 显然,这会激活Safari浏览器上的硬件加速,动画就像魅力一样。

I'm also using 我也在用

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

Props to Prinzhorn. 普林佐恩的道具。 Instead of top: 0; 而不是顶部:0; top: 100; 上:100;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM