-
Notifications
You must be signed in to change notification settings - Fork 55
feat(Animation): add logic for mount/remove children #2115
Conversation
-spreading unhandled props in Animation and Popper components
-improved duration type
-added example
-used Transition component inside the Animation -removed Animation root element
onExiting={onExiting} | ||
onExited={onExited} | ||
> | ||
{state => result} |
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.
I am currently not using the state, as in the usage I am changing the animation. We don't have the children as function concept anywhere else so far, so I didn't add it for the Animation component. (it would be easy to migrate if we decide in the future!)
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.
Does this work for adding/removing table items within the Table component or tree items within Tree?
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.
It should work, if not, we can Implement the AnimationGroup component in a similar way of how the TransitionGroup (https://reactcommunity.org/react-transition-group/transition-group) component is implemented from the same library). But, to be honest, I would try to avoid adding different APIs and try to implement it with this API
@@ -27,6 +27,7 @@ export interface Conformant { | |||
exportedAtTopLevel?: boolean | |||
rendersPortal?: boolean | |||
wrapperComponent?: React.ReactType | |||
handlesAsProp?: boolean |
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.
As the Animation is not rendering root element, but only copies the children, we don't have the "as" prop there.
@@ -26,7 +26,8 @@ | |||
"popper.js": "^1.15.0", | |||
"prop-types": "^15.7.2", | |||
"react-fela": "^10.6.1", | |||
"react-is": "^16.6.3" | |||
"react-is": "^16.6.3", | |||
"react-transition-group": "^4.3.0" |
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.
New dependency added
Changed dependencies are detected.Changed dependencies in
Perf comparison
Generated by 🚫 dangerJS |
unmountOnExit?: boolean | ||
|
||
/** The duration of the transition, in milliseconds. */ | ||
timeout?: number | { enter?: number; exit?: number; appear?: number } |
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.
based on your comment, should timeout
actually be named duration
?
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.
ah, nevermind. i see that it is what it's called in react-transition-group
... https://reactcommunity.org/react-transition-group/transition#Transition-prop-timeout
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.
Yeah, this two are different concepts (duration is the css animationDuraion), and this is timeout for removing the elements. Maybe I should come up with a better name...
Hi, just a heads up that I made a change #2153 renaming all |
# Conflicts: # CHANGELOG.md # packages/react/package.json # packages/react/src/components/Animation/Animation.tsx # packages/react/src/themes/teams/components/Animation/animationStyles.ts
# Conflicts: # CHANGELOG.md # packages/react/package.json # packages/react/src/components/Animation/Animation.tsx # packages/react/src/themes/teams/components/Animation/animationStyles.ts
# Conflicts: # CHANGELOG.md
-updated snapshots
onEntered?: (node: HTMLElement, isAppearing: boolean) => void | ||
|
||
/** Callback fired before the "exiting" status is applied. */ | ||
onExit?: (node: HTMLElement) => void |
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.
onExit?: (node: HTMLElement) => void | |
onExit?: () => void |
Do we want to expose node
there? 🤔
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.
This is the API from the Transition component itself, I would rather not change anything for now...
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.
But maybe we should return here null as first argument for the event, and the node afterwards, to be consistent with the other callbacks. What do you think?
Maybe I am over-complicating, but let me know what you think @layershifter
This PR adds the option on the
Animation
component, to wait with the mounting of the component until it is visible, as well as remove the dom element if the element is hidden.For this, the
react-transition-group
dependency was added, and theTransition
component is used behind the scenes from theAnimation
component. The API exposed is partially the Transition's API.There are example usages in the changes.
BREAKING CHANGE
Other change is that, the Animation component is not rendering the additional div anymore, it is rendering only the children.