有没有人有任何想法会导致滚动不能在safari上工作但是在chrome上工作?这两个都在OSX上。
在我的控制台中,我记录了delta,出于某种原因,对于弱滚动,它总是记录3或-3。如果我连续滚动了很多次,那么它最终会向下或向上滚动。这是视差滚动。这是我的代码:
function parallaxScroll(evt) {
console.log("what about this")
if (isFirefox) {
//Set delta for Firefox
delta = evt.detail * (-120);
} else if (isIe) {
//Set delta for IE
delta = -evt.deltaY;
} else {
//Set delta for all other browsers
delta = evt.wheelDelta;
console.log(delta)
}
if (ticking != true){
if (delta <= -scrollSensitivitySetting) {
//Down scroll
ticking = true;
if (currentSlideNumber !== (totalSlideNumber - 1)) {
currentSlideNumber++;
nextItem();
}
slideDurationTimeout(slideDurationSetting);
}
if (delta >= scrollSensitivitySetting) {
//Up scroll
ticking = true;
if (currentSlideNumber !== 0) {
currentSlideNumber--;
previousItem();
}
slideDurationTimeout(slideDurationSetting);
}
}
}
.background {
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
overflow: auto;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 100;
will-change: transform;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
height: 130vh;
position: fixed;
text-shadow: black 2px 2px 2px;
width: 100%;
-webkit-transition: all 1.2s cubic-bezier(0.22, 0.44, 0, 1);
transition: all 1.2s cubic-bezier(0.22, 0.44, 0, 1);
color: #fff;
}
.background:first-child {
background-color: rgba(156, 146, 137, 1);
-webkit-transform: translate3d(0, -15vh, 0);
}
.background:first-child .content-wrapper {
-webkit-transform: translate3d(0, 15vh, 0);
}
.background:nth-child(2) {
background-image: url(2.jpg);
}
.background:nth-child(3) {
background-image: url(3.jpg);
}
.background:nth-child(1) {
z-index: 3;
}
.background:nth-child(2) {
z-index: 2;
}
.background:nth-child(3) {
z-index: 1;
}
.background:nth-child(n+2):before {
content: "";
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: -moz-linear-gradient(left, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.5) 20%, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.5) 80%, rgba(0,0,0,0.1) 100%);
background: -webkit-linear-gradient(left, rgba(0,0,0,0.1) 0%,rgba(0,0,0,0.5) 20%,rgba(0,0,0,0.5) 50%,rgba(0,0,0,0.5) 80%,rgba(0,0,0,0.1) 100%);
background: linear-gradient(to right, rgba(0,0,0,0.1) 0%,rgba(0,0,0,0.5) 20%,rgba(0,0,0,0.5) 50%,rgba(0,0,0,0.5) 80%,rgba(0,0,0,0.1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1a000000', endColorstr='#1a000000',GradientType=1 );
}
答案 0 :(得分:0)
所以问题似乎没有变换:translate3d和我的webkit转换以及溢出设置为auto。设置溢出到隐藏并添加转换:translate3d到处都使用webkit-transform修复了我的问题。