However, I just noticed that on Android (specifically using the stock browser on a Google Galaxy Nexus), if the user tries to use the soft keyboard, it resizes the viewport, thus firing the callback function. This is behaviour I would like to eliminate.
The solutions I've seen so far have to do mainly with Android App Development and I'm not sure they apply in my case.
Ok, well after some fiddling around I've found out a solution to my problem.
So what happens when the soft keyboard is shown/hidden?! In my test, the
viewport width remains constant. However, the
viewport height changes size [
((current - previous)/previous)*100] when the soft keyboard is shown by
43% (in portrait) and by
58%(in landscape); and when the soft keyboard is hidden by
73%(in portrait) and
139%(in landscape) respectively.
So what I did was disable the callback function when the following conditions are all true:
Since mobile device browsers do not have resize handles like on the desktop, I do not believe there will arise a situation where a user will mimic the above conditions in a natural way.
You can see a sample of the code here: https://github.com/obihill/restive.js/blob/master/restive.js#L4403. Unfortunately, it's part of a bigger codeset, but you should be able to glean the basic idea based on the conditionals.