zrender icon indicating copy to clipboard operation
zrender copied to clipboard

feat: let dispatchEvent work. issues#17638

Open jianqi-jin opened this issue 2 years ago • 0 comments

fixed: #17638

usage:

When we want to dispatch an event. For example, a Wheel event.

step 1 Capture a wheel event and create a new wheel event base that event.

const event = new WheelEvent('wheel', e); // e is that wheel event that we captured.

step 2 Set the dispatchedOffsetX and dispatchedOffsetY attributes of the event.

event.dispatchedOffsetX = e.offsetX;
event.dispatchedOffsetY = e.offsetY;

step 3 PreventDefault and trigger/dispatch the event on Zrender.

e.preventDefault();
chart.getZr().handler.proxy.dom.dispatchEvent(event); // I just use the Echarts instance for example.

jianqi-jin avatar Sep 10 '22 05:09 jianqi-jin