I am currently in the process of developing a mobile application that is compatible with Android 2.2+, Blackberry 9+, and iOS 4+. Our technology stack includes Phonegap, jQuery, and iScroll (among other tools).
One of the screens in our app resembles the layout described above - displayed on the Safari browser within the iOS 5 simulator.
This particular screen features a standard input form with a fixed header, and various block-level elements that extend across the full width of the device screen, while maintaining minimal padding.
As indicated earlier, our app utilizes iScroll. We have initialized it on this specific page using code derived from the iScroll 'forms' sample.
// ...
window.scroller = new iScroll(id, {
useTransform: false,
onBeforeScrollStart: function(e) {
var target = e.target;
while (target.nodeType != 1) target = target.parentNode;
if(target.tagName != 'select'
&& target.tagName != 'input'
&& target.tagName != 'textarea') {
e.preventDefault();
}
}
});
// Disable touch scrolling (Req'd for iScroll)
window.document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, false);
// ...
Upon observation, it has come to my attention that the content scrolls smoothly when the user interacts with the background area, but fails to respond when attempting to scroll by touching one of the input fields. This issue renders the screen practically unusable, prompting me to seek a solution.
During my investigation, I identified a line in iScroll that seems to be causing this behavior;
if (nodeName == "TEXTAREA" || nodeName == "INPUT" || nodeName == "SELECT" ) return;
(line 179 in iscroll.js), there is an ongoing issue regarding this bug, along with a proposed fix through a pull request. However, the referenced fixes do not seem to work for me on iOS 5.1 and Android 4.0.4 due to discrepancies in line numbers mentioned by the bug author.
Hence, my query - is there a way to enable scrolling (using iScroll) when interacting with an input element? If not, iScroll becomes impractical in such scenarios. Currently, I am exploring two options:
- Implementing the Overthrow shim which promises similar functionality to iScroll - although concerns about compatibility issues with Android pose a challenge.
- Abandoning iScroll altogether and losing the fixed header feature.
In this day and age of technological advancements, it is surprising that such basic functionality remains elusive on mobile browsers!