New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

enable-transition

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enable-transition

Make display=none support gradients

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

📦 Installation

npm install enable-transition

🔨 Usage

class Test extends React.PureComponent {

    state = {
        num: 2,
        visible: false,
        display: 'none',
        height: 100
    };

    onToggle = () => this.setState({num: (this.state.num + 1) % 2});

    onToggle2 = () => this.setState(({visible}: any) => ({visible: !visible}));

    onToggle3 = () => this.setState(({display}: any) => ({display: display === 'block' ? 'none' : 'block'}));

    onToggle4 = () => this.setState(({height}: any) => ({height: height === 100 ? undefined : 100}));

    render() {
        const {num, visible, display, height} = this.state;
        return (
            <div>
                1、style切换-高度切换
                <div className={'container'}>
                    <EnableTransition attribute={'height'}  >
                        {(ref: React.LegacyRef<HTMLDivElement>) => {
                            return <div
                                ref={ref}
                                style={{
                                    width: 100,
                                    transition: 'all 500ms',
                                    height: height,
                                    backgroundColor: 'red'
                                }}
                            >高度切换
                            </div>
                        }}
                    </EnableTransition>
                    <button onClick={this.onToggle4}>toggle</button>
                </div>
                2、style切换-display切换
                <div className={'container'}>
                    <EnableTransition attribute={'display'} displayNone={{setHeightZero:true,setWidthZero:true}}>
                        {(ref: React.LegacyRef<HTMLDivElement>) => {
                            return <div
                                ref={ref}
                                style={{
                                    width: 100,
                                    height:100,
                                    transition: 'all 5000ms',
                                    display: display,
                                    backgroundColor: 'red'
                                }}
                            >高度切换
                            </div>
                        }}
                    </EnableTransition>
                    <button onClick={this.onToggle3}>toggle</button>
                </div>
            </div>
        );
    }
}

Keywords

transition

FAQs

Package last updated on 20 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts