javascript - jquery event handler on mobile devices- imitate drawing action -
i got grid contains picture (see fiddle below), want imitate drawing action.
i made work on personal computer, reasen dosen't wort on mobile. gues there different handling event mobilr devices.
as can see use mouseenter event. question how make work on mobile?
this code: js
createloop(); $('.b').bind('mouseenter', startdragselect); function createloop() { var length = 30; var text = ""; var demo = $("#demo") ( = 0; < length; i++) { var rowelement = $('<div class="a"></div>'); demo.append(rowelement); (var x = 0; x < length; x++) { creategriditem(rowelement, i, x); } } } function creategriditem(rootelement, i, x) { var pix = 10; var curritem = $('<div class="b" id="a' + + x + '" style="top:' + * pix + 'px; left: ' + x * pix + 'px; background-position-x: -' + x * pix + 'px ; background-position-y:-' + * pix + 'px";"></div>'); $(rootelement).append(curritem); } var gridsize = length * length; var letter = getparameterbyname("letter"); function startdragselect(obj) { obj = obj.currenttarget; if (obj.classname == "selected") { obj.classname = "b"; } else { obj.classname = "selected"; } $(obj).css({ "background-image" : "url('http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg')" }); } this fiddle
any great! tnx
there no such event mouseenteron mobile devices. have operate touchstart touchmove , touchend imitate somehow mouseenter event on mobile devices.
here touch events on mobile devices:
https://developer.mozilla.org/en-us/docs/web/api/touch_events
for real use case might check source pen did: http://codepen.io/esimov/pen/kefql/
Comments
Post a Comment