Saturday, 5 June 2010

Cross Platform development and scrolling



For me, the whole reason for working with mobile widgets is to get consistency across different handsets and manufacturers. J2ME used to be the big white hope for cross platform development, but although this got a long way, the nail in it's coffin was the release of the iPhone without J2ME support. Even Android based on Java does not usually have J2ME installed. So my opinion is that J2ME's days are numbered even though today it is still the most consistent cross platform development environment. For me, the future for cross platform development is using Mobile Widgets. Still it's early days for widgets and there are some gotchas around for those trying to do use the same code and indeed ui design across all the platforms. The biggest issue I have faced is scrolling; the problem is that iPhone and Android use a different approach to scrolling than other phones or indeed other standard browsers. iPhone and Android usually ignore any scrolling directive in the document and scroll the whole document. The standard technique to having a no scrolling region is to use the CSS directive "position:fixed". This creates a region which does not scroll and then using z-index it enables a scrolling region to go underneath this non scrolling region. This works on all desktop browsers including Apple's Safari desktop, but on the iPhone, iPad and Android phones this directive is ignored. So on the iPhone there is a solution which involves adding an additional javascript file often called fixed.js and giving specific class names to DIVs. This file changes the event processing of a website so that certain DIVs can be scrolled and others not scrolled. The problem with this approach is that the javascript needs to re-implement the kinetic scrolling of the original device.... this turns out quite difficult and it results in slightly jerky scrolling in some cases. For Android I've yet to find anyone that has done a similar approach - in fact the current Android browser is very poor; although I fully expect that all the issue will get resolved within 12 months - Android is catching up but its still behind the capabilities of its competitors browsers such as Nokia, Opera and iPhone.

More mobile widget information tomorrow...

No comments:

Post a Comment