Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

transitionstart event in React component

Tags:

reactjs

events

I am trying to add a callback function in my React component to capture the transitionstart event. Apparently, only transitionend is supported. Do you know any workaround?

<div
    className="super-component--animated"
    { /** Not supported **/ }
    onTransitionStart={() => {
        this.changeAnimationStatus(true);
    }}
    onTransitionEnd={() => {
        this.changeAnimationStatus(false);
    }}
>
     Hello Friends!
</div>

Transition events: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/transitionstart_event

like image 515
Matías Bustos Avatar asked Apr 25 '26 00:04

Matías Bustos


1 Answers

All unsupported event in React should be handled vanilla style.

const MyComp = () => {
...
 const handler = () => {
 ref.current.addEventListener('your_event', () => {...})
 }
 return <div ref={ref}/>
}

see the following sandbox: transition start listener example

like image 167
gadi tzkhori Avatar answered Apr 30 '26 09:04

gadi tzkhori



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!