code: function getCanvasClickRelativeXCoordinate(canvasElement, event) {
    let x;
    if (event.pageX) {
      x = event.pageX;
    } else {
      x = event.clientX + document.body.scrollLeft +
          document.documentElement.scrollLeft;
    }
    x -= canvasElement.offsetLeft;
    return x / canvasElement.width;
  }
docs: Get the relative x-coordinate of a click event in a canvas.
  
  @param {HTMLCanvasElement} canvasElement The canvas in which the click
  event happened.
  @param {Event} event The click event object.
  @return {number} The relative x-coordinate: a `number` between 0 and 1.