简体   繁体   English

-webkit-overflow-scrolling:触摸导致jQuery动态更改不显示?

[英]-webkit-overflow-scrolling: touch causes jQuery dynamic changes to not show?

I have a bunch of divs within a parent div, where this parent div allows horizontal scrolling. 我在父div中有一堆div,该父div允许水平滚动。

I have some jQuery set up to update the appearance of these child divs whenever they are clicked. 我设置了一些jQuery,以在每次单击这些子div时更新它们的外观。 This works just fine for the first few divs that are visible on load (ie without scrolling). 对于在加载时可见的前几个div(即无需滚动)来说,它工作得很好。 However, on mobile, for the divs that require horizontal scrolling to see, I can tell that jQuery does recognise the clicks occuring, but the changes to the appearance is not visible (eg in the example code below, the span element's text doesn't appear to change). 但是,在移动设备上,对于需要水平滚动才能看到的div,我可以告诉jQuery确实可以识别单击的发生,但是外观的更改是不可见的(例如,在下面的示例代码中,span元素的文本不可见)似乎改变了)。 I've found that if I remove the "-webkit-overflow-scrolling: touch" property from the parent div, then it works fine (although then of course the scrolling experience isn't as nice, so ideally I'd like the best of both worlds) 我发现,如果我从父div删除“ -webkit-overflow-scrolling:touch”属性,则它可以正常工作(尽管当然,滚动体验不太好,所以理想情况下,我希望两全其美)

Indicative code below. 指示性代码如下。 The issue occurs on both mobile Chrome and Safari (on iOS). 移动Chrome和Safari(在iOS上)均会发生此问题。 Thanks for your help! 谢谢你的帮助!

<style>
 .hori-scroll {
        white-space: nowrap;
        overflow-x:auto;
        /*-webkit-overflow-scrolling: touch;*/
        -ms-overflow-style: -ms-autohiding-scrollbar;
    }
</style>

<div class='hori-scroll'>
    <div class='child'>
         <span class='grandchild'></span>
    </div>
</div>


<script>
   $('.child').click(function(){
       $(this).find('.grandchild').text('changed');
    });
</script>

Just found that applying this CSS to the child elements eliminates this problem: 刚刚发现将此CSS应用于子元素可以消除此问题:

-webkit-transform: translate3d(0,0,0) -webkit-transform:translation3d(0,0,0)

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

相关问题 iOS:-webkit-overflow-scrolling:触摸和滚动 - iOS: -webkit-overflow-scrolling:touch and scrollTop -webkit-overflow-scrolling:自动; 在触控装置上无法运作 - -webkit-overflow-scrolling: auto; not working on touch devices 移动网络:-webkit-overflow-scrolling:触摸与位置冲突:已修复 - Mobile web: -webkit-overflow-scrolling: touch conflicts with position:fixed scrollLeft通过-webkit-overflow-scrolling自动返回到旧位置: - scrollLeft automatically returning to old position with -webkit-overflow-scrolling: touch 任何方式应用&#39;webkit-overflow-scrolling:touch&#39;内嵌javascript? - Any way to apply 'webkit-overflow-scrolling: touch' inline with javascript? scrollTop不能与-webkit-overflow-scrolling一起使用:touch - scrollTop doesn't work with -webkit-overflow-scrolling: touch “-webkit-overflow-scrolling:touch” - 滚动的内容是隐藏的吗? - “-webkit-overflow-scrolling: touch” - scrolled content is hidden? -webkit-overflow-scrolling打破绝对定位 - -webkit-overflow-scrolling breaks absolute positioning 以编程方式停止-webkit-overflow-scrolling - Programmatically halt -webkit-overflow-scrolling 使用-webkit-overflow-scrolling时更改HTML滚动条颜色:触摸 - change HTML scrollbar color when using -webkit-overflow-scrolling: touch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM