Double Click and Resize on an Ipad
- by Luke
Thanks to the great post at OranLooney.com I was able to get a java/icefaces web-app to resize nicely on the ipad, however the code provided for double click doesn't seem to work without further customization.
Has anybody had any experience with getting this to work? there seems to be little documentation on google.
the donnothing(); in the window.orientationchange is there as it seems sometimes without it the resize will (sometimes) not work
// a function to parse the user agent string; useful for
// detecting lots of browsers, not just the iPad.
function checkUserAgent(vs) {
var pattern = new RegExp(vs, 'i');
return !!pattern.test(navigator.userAgent);
}
if ( checkUserAgent('iPad') ) {
// iPad specific stuff here
window.onorientationchange = function() {
donnothing();
};
document.body.addEventListener('touchstart', function(e) {
touch = e.touches[0];
if ( !touch ) return;
var me = document.createEvent("MouseEvents");
me.initMouseEvent('dblclick', true, true, window,
1, // detail / mouse click count
touch.screenX,
touch.screenY,
touch.clientX,
touch.clientY,
false, false, false, false, // key modifiers
0, // primary mouse button
null // related target not used for dblclick event
);
touch.target.dispatchEvent(me);
});
}