nkbt/react-collapse

onRest is called before animation

mqklin opened this issue · 2 comments

1

Please, look at the gif. It should be called 2 times (before and after animation), but it called 3 times (extra before 1st animation)

nkbt commented

It is called when element's size is determined, but main animation is not yet started (which would call onWork), it may be called few times. The only guarantee is that when it is called - Collapse does not do any work/animation at that exact time.

I am not sure this needs to be resolved as it does not cause any issues.

If you are having issues with this - let me know what issue it actually creates and please feel free to reopen the ticket.

Thanks 🙏

It caused some issues so I had to do something like this:

onRest = () => {
  this.setState(state => ({onRestCounter: state.onRestCounter + 1}));
};
componentDidUpdate() {
  if (state.onRestCounter === 3) {
    this.setState(state => ({onRestCounter: 0}));
    callSomeCallback();
  }
}

I don't remember details. I'll reopen the ticket when I have issues with this again.

Thanks!