0.1.7 • Published 4 years ago

antd-draggable-modal v0.1.7

Weekly downloads
96
License
MIT
Repository
github
Last release
4 years ago

基于Ant-design的可以拖拽的Modal

基于Ant-design的可以拖拽的Modal

npm.io

特性:

  • 支持弹出窗居中打开
  • 支持拖拽 title bar 实现拖拽
  • 支持多层弹窗拖拽

安装:

$ yarn add antd-draggable-modal

用法:

import React, { Component } from 'react';
import { Button } from 'antd';
import AntdDraggableModal from 'antd-draggable-modal';

class Index extends Component {
  state = {
    visible: false,
    visible2: false,
  }

  handleVisible = visible => {
    this.setState({
      visible,
    });
  }

  handleOk = () => {
    this.handleVisible(false);
  }

  handleCancel = () => {
    this.handleVisible(false);
  }

  render() {
    return (
      <>
        <Button onClick={() => this.handleVisible(true)}>打开弹窗</Button>

        {this.state.visible && (
          <AntdDraggableModal
            title="Basic Modal"
            visible={this.state.visible}
            onOk={this.handleOk}
            onCancel={this.handleCancel}
          >
            <p>Some contents...</p>
            <p>Some contents...</p>
            <p>Some contents...</p>
            <Button onClick={() => this.setState({ visible2: true })}>打开弹窗2</Button>
          </AntdDraggableModal>
        )}
        
        {this.state.visible2 && (
          <AntdDraggableModal
            title="Basic Modal2"
            visible={this.state.visible2}
            onOk={() => this.setState({ visible2: false })}
            onCancel={() => this.setState({ visible2: false })}
          >
            <p>Some contents...</p>
            <p>Some contents...</p>
            <p>Some contents...</p>
          </AntdDraggableModal>
        )}
      </>
    );
  }
}

export default Index;
0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago