我有以下代碼淡化固定到底部的按鈕,當用戶滾動並淡出時,用戶滾動到頂部的移動...作品在桌面上以響應模式進行測試時效果很好,但是在iOS上,它會在瞬間延遲後立即啓動,但在滾動回頂端時會淡化,因此應如何阻止它捕捉?JQuery淡入淡出滾動在iOS上不能正常工作
CSS
.cta {
background-color: rgba(75, 113, 252, 0.9);
display: none;
position: fixed;
bottom: 0;
left: 0;
text-align: center;
line-height: 50px;
color: #fff;
height: 50px;
width: 100%;
opacity: 1;
z-index: 999;
}
JS
$(window).scroll(function() {
if ($(this).scrollTop()> 150) {
$('.cta').fadeIn();
} else {
$('.cta').fadeOut();
}
});
IOS移動有不同的方式來 「讀」 的scrollTop的價值就只喜歡讀當你停止滾動,而不是當你實際上滾動...她是一個解決方法http://stackoverflow.com/questions/18753367/jquery-live-scroll-event-on-mobile-work-around – DaniP
也許我在做有什麼不對(新的t或者js),但是周圍的工作並不能阻止淡入淡出,而不是輕輕的淡入淡出。 –