3 ms·
Is it possible to automatically (without any additional code) animate the differences between two versions of the DOM? This would make it possible to, e.g., ani
by amelius 12y ago
Is it possible to automatically (without any additional code) animate the differences between two versions of the DOM? This would make it possible to, e.g., animate the creation of some space between two DIVs before inserting a new DIV in between, and animate the removal of space when a DIV disappears. This is something that is not easy in CSS alone, and could reduce much of the flickering in web-pages which potentially makes users lose their orientation (if the DIVs are large).
- pests 12y agoThere was a recent ReactConf talk that included something like this. Check out the examples referencing 'magic move'. There is a YT video of the talk where this is shown but you can install the examples locally to see them yourself. https://github.com/ryanflorence/reactconf-2015-HYPE https://github.com/ryanflorence/reactconf-2015-HYPE I think does what you describe. If you want to see something cool check out the '06-itunes-style-interface' example. Implements the drop down that iTunes uses for albums or how Google Image Search has an inline drop down when you click a result. The item being left closes gracefully when you switch to another item at the same time the new item is opening.
- lobster_johnson 12y agoThat's what transition groups do. When you wrap something I a transition group, it will generate events when a child is removed or added, allowing you to add required transition effects. The CSS transition group is pretty useful: When a child is removed, it is kept in the DOM, with a CSS "exit" class added (here you could have a CSS transition for opacity, for example), and then finally removed when React determines that the animation is done. Conversely, added nodes get an "enter" class. Transition groups are explicit -- you have to wrap your components in them -- and that's a good thing, as it allows you to control what kinds of transitions are used in different contexts.