react-grid-layout / react-draggable

React draggable component
MIT License
9.04k stars 1.03k forks source link

Property 'clientX' does not exist on type 'TouchEvent<HTMLElement | SVGElement>'. #723

Open priyanshusaini105 opened 1 year ago

priyanshusaini105 commented 1 year ago

Property 'clientX' does not exist on type 'DraggableEvent'. Property 'clientX' does not exist on type 'TouchEvent<HTMLElement | SVGElement>'.

how to mention the clientX for both touch and mouse event

const onLabelDragged:DraggableEventHandler = (e) => {
    const sliderEle = sliderRef.current;
    if (sliderEle) {
      const sliderRect = sliderRef.current?.getBoundingClientRect();
      let selectedStrikeIndex = Math.floor(
        (e.clientX - sliderRect.left + sliderEle.scrollLeft) / 24 <------
      ); 
     }
  };

I tried this too

((e.clientX || e.touches[0].clientX) - sliderRect.left + sliderEle.scrollLeft) / 24
danivalls commented 11 months ago

Same here, no updates on this problem?