javascript - event.target not changed during touchmove in chrome -


i have div child elements. in touch move, need target element. target element remains same in chrome

fiddle link: https://jsfiddle.net/660rdys9/1/

var parent = document.getelementbyid("parent");  var textbox = document.getelementbyid("textbox");  parent.ontouchmove = function(e){  	textbox.value = e.target.id;  }
div > div{    border:2px solid;  }
<div id="parent" style="width:500px;height:300px;">  <div style="width:500px;height:200px;" id="first">first span</div>  <div style="width:500px;height:200px;" id="second">second span</div>  </div>  <input type="text" id="textbox"/>

replication procedure:

1) goto fiddle in above link using chrome

2) touch 1 of black rectangle(first div) , move finger rectangle(second child div)

3) can see id displayed in text box remains same

is behavior of touch move event? not possible correct target element during touch move?

note: event.target correct during mouse move

as per answer in question how find out actual event.target of touchmove javascript event?, can use document.elementfrompoint method workaround

example code:

var parent = document.getelementbyid("parent");  var textbox = document.getelementbyid("textbox");  parent.ontouchmove = function(e){      var target = document.elementfrompoint(e.originalevent.changedtouches[0].clientx, e.originalevent.changedtouches[0].clienty);  	textbox.value = target.id;  }
div > div{    border:2px solid;  }
<div id="parent" style="width:500px;height:300px;">  <div style="width:500px;height:200px;" id="first">first span</div>  <div style="width:500px;height:200px;" id="second">second span</div>  </div>  <input type="text" id="textbox"/>


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -