On iPhone/iPad/android, can use the follow replacements for mouse events:
mousedown -> touchstart
mousemove -> touchmove
mouseup -> touchend
In mouse/touch events, obtain page location by:
me.vSelectCanvas.addEventListener('mousedown', function(e) {
if (e.which == 3) { return; } // do nothing for right mouse button.
var mouse_x = e.pageX - this.offsetLeft,
mouse_y = e.pageY - this.offsetTop;
// ...
}, false);
me.vSelectCanvas.addEventListener('touchstart', function(e) {
if (e.touches.length == 1) {
var mouse_x = e.touches[0].pageX - this.offsetLeft,
mouse_y = e.touches[0].pageY - this.offsetTop;
// ...
}
}, false);
To detect browser agent type (regular browser or smart phone) and reset window size:
var D=navigator.userAgent.toLowerCase();(See code here)
var x=(D.indexOf("android")!=-1)||(D.indexOf("iphone")!=-1)||(D.indexOf("ipad")!=-1);
var d=x?window.innerWidth:900;
var B=x?window.innerHeight:550;
And here's information on How to get iPad/iPhone screen dimensions in javascript.
1 comment:
That’s a great site you folks have been carrying out there.
ipad 32gb
Post a Comment