0.1.6 • Published 4 years ago
react-modal-resizable-draggable v0.1.6
react-modal-resizable-draggable
Accessible modal dialog component for React.JS
Demo
Keyboard feature support
- arrowLeft: move left 20px
- arrowRight: move right 20px
- arrowUp: move up 20px
- arrowDown: move down 20px
- ctrl + arrowLeft: decrease width 20px
- ctrl + arrowRight: increase width 20px
- ctrl + arrowUp: increase height 20px
- ctrl + arrowDown: decrease height 20px
Table of Contents
Installation
To install, you can use npm or yarn:
$ npm install react-modal-resizable-draggable
$ yarn add react-modal-resizable-draggableUsage
Add following css style to your css file
.flexible-modal {
position: absolute;
z-index: 1;
border: 1px solid #ccc;
background: white;
}
.flexible-modal-mask {
position: fixed;
height: 100%;
background: rgba(55, 55, 55, 0.6);
top:0;
left:0;
right:0;
bottom:0;
}
.flexible-modal-resizer {
position:absolute;
right:0;
bottom:0;
cursor:se-resize;
margin:5px;
border-bottom: solid 2px #333;
border-right: solid 2px #333;
}
.flexible-modal-drag-area{
background: rgba(22, 22, 333, 0.2);
height: 50px;
position:absolute;
right:0;
top:0;
cursor:move;
}The Modal object has one required prop:
isOpento render its children.
Optional prop:
minWidthThe minimum width of the modal(default 0).minHeightThe minimum height of the modal(default 0).initWidthThe initial width of the modal(default 800).initHeightThe initial width of the modal(default 400).topThe position of the modal.leftThe position of the modal.onRequestCloseto close the modal.disableMoveto disable the drag function(default false).disableResizeto disable the resize function(default false).disableVerticalResizeto disable the vertical resize function(default false).disableHorizontalResizeto disable the horizontal resize function(default false).disableVerticalMoveto disable the vertical drop function(default false).disableHorizontalMoveto disable the horizontal drop function(default false).disableKeystroketo disable keystroke listener(default false).onFocuscalled when the modal is clicked.classNameThe additional class to the modal.
Examples
Inside an app:
import React, {Component} from 'react';
import './App.css';
import ReactModal from 'react-modal-resizable-draggable';
class App extends Component {
constructor() {
super();
this.state = {
modalIsOpen: false
};
this.openModal = this.openModal.bind(this);
this.closeModal = this.closeModal.bind(this);
}
openModal() {
this.setState({modalIsOpen: true});
}
closeModal() {
this.setState({modalIsOpen: false});
}
render() {
return (
<div className="App">
<button onClick={this.openModal}>
Open modal
</button>
<ReactModal
initWidth={800}
initHeight={400}
onFocus={() => console.log("Modal is clicked")}
className={"my-modal-custom-class"}
onRequestClose={this.closeModal}
isOpen={this.state.modalIsOpen}>
<h3>My Modal</h3>
<div className="body">
<p>This is the modal's body.</p>
</div>
<button onClick={this.closeModal}>
Close modal
</button>
</ReactModal>
</div>
);
}
}
export default App;0.1.6
4 years ago
0.1.5
5 years ago
0.1.4
6 years ago
0.1.3
6 years ago
0.1.2
6 years ago
0.1.1-rc.16
6 years ago
0.1.1-rc.15
7 years ago
0.1.1-rc.14
7 years ago
0.1.1-rc.13
7 years ago
0.1.1-rc.12
7 years ago
0.1.1-rc.11
7 years ago
0.1.1-rc.10
7 years ago
0.1.1-rc.9
7 years ago
0.1.1-rc.8
7 years ago
0.1.1-rc.7
7 years ago
0.1.1-rc.6
7 years ago
0.1.1-rc.5
7 years ago
0.1.1-rc.4
7 years ago
0.1.1-rc.3
7 years ago
0.1.1-rc.2
7 years ago
0.1.1-rc.1
7 years ago
0.1.1
7 years ago
0.1.0
8 years ago
0.0.9
8 years ago
0.0.8
8 years ago
0.0.7
8 years ago
0.0.6-rc-4
8 years ago
0.0.6-rc-3
8 years ago
0.0.6-rc-2
8 years ago
0.0.6-rc-1
8 years ago
0.0.6
8 years ago
0.0.5
8 years ago
0.0.4
8 years ago
0.0.3
8 years ago
0.0.2
8 years ago
0.0.1
8 years ago