Forum Discussion
storyline get user click position
At breakfast i quickly checked this last one on my mobile and did notice Touchevents were not registered...so it didnot work on Mobile devices.
Fixed that now.
https://360.articulate.com/review/content/a1280461-dbb1-44ee-b644-14a2cde6f8c3/review
Added a function in the code that checks for Touch or Clickevents and then uses the proper syntax to return the clicked position.
clientX = getOffsetPosition(e,document.querySelector('body')).x;
clientY = getOffsetPosition(e,document.querySelector('body')).y;
function getOffsetPosition(e, parent){
let position = {
x: (e.targetTouches) ? e.targetTouches[0].pageX : e.clientX,
y: (e.targetTouches) ? e.targetTouches[0].pageY : e.clientY
};
while(parent.offsetParent){
position.x -= parent.offsetLeft - parent.scrollLeft;
position.y -= parent.offsetTop - parent.scrollTop;
parent = parent.offsetParent;
}
return position;
}
Now it works nicely on both desktops and mobile devices.
Here is the file...