Creating a “sticky” fixed-position item that works on iOS Safari

后端 未结 5 1810
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 08:40

On iOS safari, one-finger panning doesn’t generate any events until the user stops panning. An onscroll event is only generated when the page stops moving and redrawn.

相关标签:
5条回答
  • 2020-12-08 09:01

    Answering my own question. iOS7 now support position:sticky Demo: http://html5-demos.appspot.com/static/css/sticky.html

    0 讨论(0)
  • 2020-12-08 09:02

    I've recently spent many hours trying to come up with a practical solution for the same problem. There's no right way to do this, although there are a few decent hacks (most of them mentioned already). The problem is that JavaScript is paused while the user is scrolling. It makes sense when you consider the implications, but it makes it damn hard to implement fixed positioned element.

    The best thing that I've been able to find is this wonderful post by the folks at Google. You can check out http://gmail.com in mobile safari to see it in action.

    https://developers.google.com/mobile/articles/webapp_fixed_ui

    Hope this helps.

    0 讨论(0)
  • 2020-12-08 09:09

    If all you want is a sticky menu, you can save yourself some headaches by using an existing library. I've had success with iScroll:

    http://cubiq.org/iscroll

    At the very least, you can take a look at how this works and base your solution around that.

    Happy hacking!

    0 讨论(0)
  • 2020-12-08 09:13

    Old topic for sure, but I can see alot of visits here. If all you want, is a sticky menu, you can use fixed positioning. No need for iScroll there.

    0 讨论(0)
  • 2020-12-08 09:21

    I had a similar issue and bound handlers to touchstart/touchmove/touchend using jquery to detect the single finger scrolling and it worked perfectly. In my case I needed to move another element the same amount as the attempted move of another element and it updated nicely as the scroll was attempted so it ought to be suitable for your requirement.

    0 讨论(0)
提交回复
热议问题