leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.48k stars 370 forks source link

Ranger selection does not trigger mousemove event. #935

Open lucianbaciu opened 1 month ago

lucianbaciu commented 1 month ago

In 1.6.21 this does not exist.

In the latest versions, while hovering a time selection, the position line event is not working.

The line is moving well when hovering outside of the blue selection

Screenshot_1526

leeoniya commented 1 month ago

this change was intentional to avoid triggering mouse events that uplot listens to while the user interacts with third-party dom elements that are added into .u-over (like an anchored tooltip). it was introduced in https://github.com/leeoniya/uPlot/commit/bab8c11a10f5c3e884f8f1d863826dd2996d1ed2

you should be able to restore the previous behavior by overriding cursor.bind.* with functions that dont do any event target filtering:

https://github.com/leeoniya/uPlot/commit/bab8c11a10f5c3e884f8f1d863826dd2996d1ed2#diff-ad6d196bc8d38207d186017fc5c2c52660db3a546ccfdfe167fd7ad0c727cdeeR441-R443

a different, probably better approach is to set css pointer-events: none on the highlight region but keep the grip portion responding to events like normal.

lucianbaciu commented 1 month ago

pointer-events: none could be an option, but I'm not sure if it's possible

image

u-select::before is the blue part. u-select is capturing the event. If I set it as pointer-events: none, the grips (which are children) will be also disabled. If I disable events only in the ::before, the main u-select is eating the event

am I missing something?

leeoniya commented 1 month ago

ah yeah, i forgot the demo implements the grips as select children. then you're right, you can't use the css strategy.

https://github.com/leeoniya/uPlot/blob/15ca5df25cb4aa502a6ce77068e2fa93b190fb7f/demos/zoom-ranger-grips.html#L184-L194

leeoniya commented 1 month ago

i'm leaning towards adding the .u-select into the current filter, since it is also "native" to uPlot, like .u-over. hopefully it doesnt affect perf too much to check against two elements during mousemoves vs just one. in most cases i think we can bypass the check when the select size is 0.

lucianbaciu commented 1 month ago

thank you! I will try