Single finger Scrolling for inner contents (div/iframes) in iPhone Mobile Safari

自闭症网瘾萝莉.ら 提交于 2019-11-28 22:56:35

问题


Sub: iPhone mobile safari web application

I need to keep some parts of a web page visible even when a user scrolls. The CSS property position:fixed does not work as expected. Using the overflow:auto property on or needs two-finger scrolling which is not what I want.

Is there any way to provide single finger scrolling on the inner 'div' or 'iframes' contents using javascript or iphone safari Touch API (touchMove event)?


回答1:


In CSS (for iOS 5):

-webkit-overflow-scrolling: touch;



回答2:


Natively it is not possible, either with a div or iframe, so it must be solved with javascript listening for the touch events. I'm researching this same problem for a project and at the moment I have found a couple javascript libraries that are solving this problem.

I'm looking into this one at the moment, but I haven't commited to it yet.

http://cubiq.org/iscroll-4

Joe Hewitt of Three20 fame has recently started dev on solution for this as well, but he's really early in dev process where as the other one has been around for a couple years now.

http://joehewitt.github.com/scrollability/




回答3:


You can use just One finger, but you have to provide style.height of the inner DIV

<div id="container-div" style="overflow:hidden">
   <div id="inner-div" style="overflow-y:auto; height:1024px"> 
   <!-- IMPORTANT!! you must specify the height of the inner div to make it scrollable -->


来源:https://stackoverflow.com/questions/5921688/single-finger-scrolling-for-inner-contents-div-iframes-in-iphone-mobile-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!