dfilatov / vidom-css-animation-group Goto Github PK
View Code? Open in Web Editor NEWAPI for "appearance", "entering" and "leaving" animation via CSS transitions and animations inside Vidom
API for "appearance", "entering" and "leaving" animation via CSS transitions and animations inside Vidom
Hello, I'm trying to show and hide some tip with animation. Here is my code
export const Tip = (attrs:Attrs, children:any, context:any) => (
<div class={cssClassnameTipContainer}>
{children}
<CssAnimationGroup enter={GlobalAnimations.bounceInClassname} leave={GlobalAnimations.zoomOutClassname} >
{attrs.text
? <div class={cssClassnameTip} key='key-for-animation'>{attrs.text}</div>
: null
}
</CssAnimationGroup>
</div>
)
Tip appears correctly with animation, then disappears correctly with animation, but on next show I'm getting the error
Uncaught Error: vidom: Detected unexpected attempt to reuse the same node "fragment".
at checkReuse (vidom.js:722)
at FragmentElement.renderToDom (vidom.js:2708)
at TagElement.renderToDom (vidom.js:1179)
at FragmentElement.renderToDom (vidom.js:2858)
at Object.replace (vidom.js:758)
at TagElement.patch (vidom.js:1495)
at AnimationGroup.patchComponent [as patch] (vidom.js:2107)
at ComponentElement.patch (vidom.js:2649)
at CssAnimationGroup.patchComponent [as patch] (vidom.js:2107)
at ComponentElement.patch (vidom.js:2516)
What am I doing wrong?
Hello @dfilatov
CssTransitionGroup works perfect for the list, but I'm trying to animate a component that can hide itself.
Let's say I have component like this:
import { Component } from "vidom/lib/vidom";
export default class Test extends Component<{ show: boolean }, any>{
onRender(){
if(this.attrs.show) return <div>{this.children}</div>
//return node('fragment')
return null
}
}
And I'm using it something like this:
<CssTransitionGroup
appearFrom="from"
appearTo="to"
enterFrom="from"
enterTo="to"
leaveFrom="to"
leaveTo="from"
>
<button onClick={() => this.setState({one: !this.state.one}) }>switch one</button>
<button onClick={() => this.setState({two: !this.state.two}) }>switch two</button>
<button onClick={() => this.setState({three: !this.state.three}) }>switch three</button>
<Test key="one" show={this.state.one}>one</Test>
<Test key="two" show={this.state.two}>two</Test>
<Test key="three" show={this.state.three}>three</Test>
</CssTransitionGroup>
But it doesn't work.
So what is the proper way to animate this component inside CssTransitionGroup?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.