问题
Im using phonegap to build an ios app, so that you cant move the window phonegap uses document.addEventListener("touchmove", preventBehavior, false);
which is fine... but it also prevent me from using the css overflow:scroll
on a section of text.
Is there a work arround that i can get both of these to still work ? is there a way i could load in the section of css after the js so that it overrides it ? or can i just apply the document.addEventListener("touchmove", preventBehavior, false);
to the body but not its content ?
回答1:
Found a phonegap / cordova only work around that dosnt require you to use document.addEventListener("touchmove", preventBehavior, false);
in the first place - go into your xcode project.. porject file > supporting files > cordova.plist then at the top change 'UIWebViewBounce' to NO.
from here
回答2:
I think you can detect the target element when "touchmove":
document.addEventListener("touchmove", function(event) {
if (event.target.tagName != "TEXTAREA") { // Element that you don't want to be prevented default event.
event.preventDefault();
}
});
回答3:
To capture all the scrolling pixels you can write
document.addEventListener("touchStart",<method>,true/false)
document.addEventListener("touchMove",<method>,true/false)
document.addEventListener("touchEnd",<method>,true/false)
Have you added touchEventListener in body load function ? If you write event.preventDefault(); It will kill the event behavior that is the reason why your overflow:scroll property is not working.
回答4:
In the last version cordova.plist changed by config.xml, then set
"UIWebViewBounce" value="false"
来源:https://stackoverflow.com/questions/10814838/document-addeventlistenertouchmove-preventbehavior-false-prevents-me-us