Hope you like this and don't hesitate to comment, Thanks. pageX, pageY, screenX, screenY, clientX and clientY returns a number which indicates the number of physical pixels a point is from the reference point. This should work on all browsers and devices, personally I tested it successfully on IE, Firefox, Google Chrome, Opera, Firefox for android, Chrome for android, Opera for android and iPhone.Ī full working example can be tested here. Android issues were found when checking AAR metadata: re:core:1.12.0-alpha01 and re:core-ktx:1.12. cancelable, view, clientX, clientY, screenX, screenY, detail, altKey. Just follow the same logic to wire other events (mouseover, click, dblclick. Because iOS devices are mouseless and keyboardless, the regular mouse and. MouseEvent.initMouseEvent(mouseEv, true, true, window, 1, theTouch.screenX, theTouch.screenY, theTouch.clientX, theTouch.clientY, false, false, false, false, 0, null) Var mouseEvent = document.createEvent("MouseEvent") The following function will initiate and fire mouse events ( event.initMouseEvent), for each touch events type we'll fire the equivalent mouse event :Īnd then we will cancel the original touch event using preventdefault :Ĭase "touchstart": mouseEv="mousedown" break Ĭase "touchend": mouseEv="mouseup" break Ĭase "touchmove": mouseEv="mousemove" break First we need to listen to touch events and call a function 'touch2Mouse' each time a touch event is fired:ĭocument.addEventListener("touchstart", touch2Mouse, true) ĭocument.addEventListener("touchmove", touch2Mouse, true) ĭocument.addEventListener("touchend", touch2Mouse, true) I dont know exactly what are the Opera Mobile platforms that suffer from this problem.May be the whole Android platform, or just Samsung Android devices. screenX/Y clientX/Y devicePixelRatio zoom, where zoom documentElement.clientWidth / window.innerWidth Many browsers make it the same as page or client Chrome makes it relative to the screen BUT IN CSS PIXELS, and for vertical measurements you have to subtract the toolbars as well. Maybe it would make sense to insert my fix as part of the normalization of events performed by jquery mobile.or maybe the only solution is just relying in the fix of similar bug. I submitted a bug report also to the Opera Team.but my question is: does jquery Mobile provide a re-normalization of event values or its only purpose is reformatting the values of the original event to fit the format of the virtual event? I made experiments printing the original touch event coordinates.and THEY ARE WRONG TOO!!! So the problem should be in the original event created by Opera Mobile itself in the Samsung Galaxy S2 and Galaxy Tab 2 platforms. Now if I copy ScreenX, and ScreenY on ClientX and ClientY.and I recompute PageX and PageY starting from these correct values.everything works fine. Values of PageX and PageY that are computed from ClientX, ClientY are also wrong.and this causes problems in some applications. Very Strange!!!! This means that Screen coordinates are returned in.no place. The values that should be returned by ClientX and ClientY are returned as value of ScreeenX and ScreenY instead. The value returned in virtual events for ClientX, ClientY, in Opera Mobile 12.1 on Samsung Galaxy S2 and Galaxy Tab 2 make asolutely no sense.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |