JavaScript DOM changes in touchmove delayed until scroll ends on mobile Safari

后端 未结 3 1850
执笔经年
执笔经年 2020-12-07 23:26

In mobile safari, in the course of handling touchmove for an element, I change the className of that element. Unfortunately, the visual change does

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 00:04

    I actually built that site, and yes the way to get around this limitation is to not scroll the site using the built in browser functionality but fake it. The JS listens to scroll wheel and keyboard events and tweens the css top property of the main container to its own 'scrollTop'. The scrollbar on the right is of course a custom JS one. In this case its synced to the same internal 'scrollTop' value.

    The whole site is just one big tween really, with the main timeline being its scrollTop position, and all the sub animations being triggered at certain times. The JS isn't minified so take a look in the ScrollAnimator.js file, its all there.

提交回复
热议问题