Comments (3)
After thinking about this a little, I'd recommend trying to subclass
VelocityTransitionGroup. If you mark your nodes in some manner with whether
they should be animated or not (with classes, perhaps?) you can override
childWillAppear, childWillEnter, and childWillLeave. Use your own logic to
short-circuit out of those functions (just call the doneFn and return) and
only call the "super" implementations when you want animation to happen.
You could also put together a PR to allow the wrapper component class,
currently VelocityTransitionGroupChild, to be parameterized as a prop to
VelocityTransitionGroup. Then you could implement the logic in your custom
child's componentWillAppear / componentWillEnter / componentWillLeave
(calling the willAppearFunc / willEnterFunc / willLeaveFunc props as
necessary).
I think the latter's nicer because I prefer composition over inheritance
for customization (esp. given the state of JS "classes"), but the former
you could get started on right away.
On Tue, Dec 8, 2015 at 11:08 PM, Richard Lopes [email protected]
wrote:
Hello,
Having great success with the library so far.
However I got a new requirement causing me some grief to achieve.I have 2 pages:
- a list of items (that you can sort and filter)
- a form to create new items
I have 2 API endpoints:
- one gets the original list of items
- one returns new items that have been added by other users
This is how it works:
- when the list of items first load, items are rendered without animation
- when you filter or sort the list, items are rendered without animation
- when the second API notify new items have been added, those are
rendered in the list with animation- when an item is deleted, it gets removed with an animation
- when a user leave the list page to create an item on the second page,
he is redirected back to the list page after creation, the new item only
must be rendered with animationAt the moment I achieve 1 to 4 but I am having problems with 5 (5 leaves
the list page then come back, unmount/mount items). If I turn on animation
(on mount) all items are animated as no item was (React) mounted yet. If
animation is turned off nothing gets animated including the new item.For animation I wrap the list of items inside a VelocityTransitionGroup
and each item as a key attribute set to the item unique id. The unique id
works well to filter out what gets animated but in the case of 5 it doesn't
help.I have hacks in mind but they are not elegant. What would be the best
approach to meet requirements 1 to 5 ?I am thinking replacing the transition group with a VelocityElement per
row/item for finer control but I am not sure how to achieve the enter,
leave effect as provided by the transition group. Also feels like
reinventing transition group in a way.—
Reply to this email directly or view it on GitHub
#58.
from velocity-react.
Thanks for taking the time to answer this.
This is a bit more involved than I would have hoped but I will take your advice and fork the project. I think your option 2 will be better indeed. I also believe composition is a better approach.
My immediate objective is to have it working in my context but when I get a minute I can clean things up and submit a PR.
I keep you posted here.
from velocity-react.
I am going to address this now that I am back from 1 month holiday.
from velocity-react.
Related Issues (20)
- Conditional rendering inside VelocityTransitionGroup error in 1.4.0 HOT 2
- velocityHelpers is exported with a lowercase starting letter.
- examples
- Can't resolve velocity on create-react-app v2 HOT 5
- Update react-transition-group dep version
- No way to set duration or speed on VelocityTransitionGroup
- TypeError Cannot read property 'length' of null in velocity-component.js (v1.4.1) HOT 5
- Error caused by require TransitionGroup module directly HOT 4
- velocity-animate@^2.0.0 compatibility HOT 1
- next is not a function HOT 1
- slideDown finishes "too early" HOT 1
- Missing typings HOT 2
- Is this project still being developed? HOT 5
- Update react-transition-group HOT 3
- TransitionGroup CJS require not valid HOT 1
- Issue in Webpack production build
- VelocityTransitionGroup throws Strict Mode warnings HOT 3
- How to use sequences?
- TypeError: this.updater.enqueueCallback is not a function
- Upgrading to react 17 gives error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from velocity-react.