leeoniya / uPlot

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

Ranger selection does not trigger mousemove event. #935

Open lucianbaciu opened 8 months ago

lucianbaciu commented 8 months 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 8 months 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 8 months 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 8 months 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 8 months 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 8 months ago

thank you! I will try

lucianbaciu commented 3 weeks ago

image

this is a diff checker

lucianbaciu commented 3 weeks ago

@leeoniya after a long investigation to see why the issue was not fixed on my project (but it was on your demos), I realized that there is still a difference between the file behind https://leeoniya.github.io/uPlot/dist/uPlot.iife.js and the one installed via npm. Both are version .31

leeoniya commented 3 weeks ago

i don't publish new versions after every fix, and also don't update the github build version between releases, so every github build until .32 will say .31, even if it's technically .32-pre.

if you would like to use a specific version that is not yet published you can update your package.json dependency to "uplot": "leeoniya/uPlot#3258d8b600c56505879d84b8bafd5e461203da44", and npm will pull the build for that commit directly from this repo.