-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add done argument to onEntering and onExiting #331
Conversation
@@ -238,38 +244,34 @@ class Transition extends React.Component { | |||
this.props.onEnter(node, appearing); | |||
|
|||
this.safeSetState({ status: ENTERING }, () => { | |||
this.props.onEntering(node, appearing); | |||
this.props.onEntering(node, appearing, setEntered); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't e.g. onEntered
get called twice if the user both manually triggers the transition end and the timeout fires? i think, then, that this should hook into that weird "next callback" mechanism. i wish i clearly remembered how that actually worked well enough to give you a real suggestion on implementation, though
CI is failing because the commit message doesn't adhere to the preferred format; to make this easier for contributors, I pushed some changes to To lint the message of your last commit run |
@aholachek Have a look at the issue #389 – @jquense is strictly against adding I'm not sure this PR is also worth keeping open unless Jason changes his mind. @aholachek Will the workaround I've mentioned work for you? |
@mvasin thank you for looking into this problem, the workaround is ok for single elements (where I have access to the If I could figure out how to get it working for Thank you again for looking in to how to do this! I will close my pr since it seems like it's not the right direction to go in. |
Could also be safier to addEndListener={(node, done) => {
function reacttransitionend() {
node.removeEventListener('reacttransitionend', reacttransitionend);
done();
}
node.addEventListener('reacttransitionend', reacttransitionend);
}} Working demo : https://codepen.io/abernier/pen/pYKjPr?editors=0010 |
Hi,
I've been missing the functionality from V1 which passed in a callback to
componentWillLeave
that could be called on conclusion of the exit animation to signal that the element could be removed from the DOM. Having to provide a timeout in advance, or a listener on the DOM node itself, as one currently has to do for the V2 version, is not quite as convenient for JS animations.In this pr, I added
done
function arguments to theonEntering
andonExiting
callbacks so that those functions could directly signal when transitions were done.Right now, since if you are using the
done
callback you neither need to provide atimeout
prop nor aaddEndListener
prop, I removed therequired
from thetimeout
prop. If you think this PR is a good direction to go in I would love some advice about whether this was the right thing to do with props.