GithubHelp home page GithubHelp logo

dfilatov / vidom-css-animation-group Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.15 MB

API for "appearance", "entering" and "leaving" animation via CSS transitions and animations inside Vidom

JavaScript 93.58% CSS 3.82% HTML 2.60%

vidom-css-animation-group's People

Contributors

dfilatov avatar

Stargazers

 avatar

Watchers

 avatar  avatar

vidom-css-animation-group's Issues

Uncaught Error: vidom: Detected unexpected attempt to reuse the same node "fragment".

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?

Question: how to animate component that can hide itself?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.