posRelative

returns the pointer position relative to the object firing the event

object posRelative(Event ev);
evEventa native HTML event
objectthe position object

Example

<div id="mydiv" style="width:100px; height:100px;border: 1px solid #781351;"></div>
var elem = document.getElementById("mydiv");
 
elem.onclick = function (e){
    var posRel = webix.html.posRelative(e||event);
    var pos = webix.html.pos(e||event);
 
    console.log(pos);    // returns {x:20,y:501}
    console.log(posRel); // returns {x:20,y:21}
}

Details
  • WebKit-based browsers - the method retrieves the pointer position relative to the object firing the event.
  • Firefox - the method the pointer position relative to the last positioned ancestor element.
See also
Back to top