How can I set an Event type for 'layerX' and 'layerY'

江枫思渺然 提交于 2021-02-10 06:34:09

问题


I'm making a dropdown menu having an absolute position. It gets x, y coordiation from mouse event.

container.addEventListener(
  'contextmenu',
    (e: MouseEvent) => {
      drawingMenuX = e.layerX + 15; // chartiq basic padding is 15
      drawingMenuY = e.layerY + 15;
    },
    false,
);

But it show error "Property 'layerX' does not exist on type 'MouseEvent'.ts(2339)". How can I set a correct event type instead of MouseEvent?


回答1:


As above @Daniel A.White said, it because layerX and layerY are non-standard. The alternative option is offsetX and offsetY.



来源:https://stackoverflow.com/questions/59340676/how-can-i-set-an-event-type-for-layerx-and-layery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!