xzdarcy / react-timeline-editor

react-timeline-editor is a react component used to quickly build a timeline animation editor.
https://zdarcy.com/
MIT License
284 stars 82 forks source link

Callback for cursor time being set by clicking (not dragging) #22

Closed rewbs closed 1 year ago

rewbs commented 1 year ago

Hi, thanks for the great work.

I need my UI to react to the cursor changing position. The onCursorDrag callback works for most cases, but users can also click on the timeline (without dragging) to set the cursor time. As far as I can tell there's no hook for this event that includes the cursor time in the event object. Could we possibly get one? Thanks!

ShahriarDhruvo commented 1 year ago

What are you saying! You don't need any hook for that as it works right out of the box. When you click on the header section of the timeline then the cursor will move to that point. image By header section I was taking about this portion of the timeline

rewbs commented 1 year ago

Yes it moves the cursor. But if I have an external component that reacts to the cursor position, I need to update it with the new cursor position. Currently I can only get the cursor position via a callback when the cursor is dragged, not when it is clicked.

reactone commented 1 year ago

It’s definitely possible as I have this functionality implemented.

rewbs commented 1 year ago

It’s definitely possible as I have this functionality implemented.

Great! Which callback are you using to get the cursor position when the header is clicked?

xzdarcy commented 1 year ago

I have just added onClickTimeArea api, you can try this version v0.1.8

rewbs commented 1 year ago

I have just added onClickTimeArea api, you can try this version v0.1.8

Thanks, that works perfectly.

ShahriarDhruvo commented 1 year ago

Sorry, @rewbs I misunderstood your question and when I faced the exact same issue today I realised what you were saying. Thanks ❤️

ShahriarDhruvo commented 1 year ago

Also can you make the onClickTimeArea to take void too? Or am I doing something wrong!

image