-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
88 lines (84 loc) · 2.29 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import React, { Component } from "react";
import "./App.css";
import Dragresize from "dragresize";
class Example extends Component {
constructor(props) {
super(props);
this.state = {
elmX: 450,
elmY: 50,
elmW: 150,
elmH: 100,
isChecked: true,
isRatio: false,
isDrag: true,
isResize: true
};
this.change = e => {
this.setState({ elmX: Number(e.target.value) });
};
}
render() {
return (
<div className="example">
<label htmlFor="x">修改X坐标:</label>
<input
id="x"
type="text"
onChange={this.change}
value={this.state.elmX}
/>
<div>X轴: {this.state.elmX}</div>
<div>Y轴: {this.state.elmY}</div>
<div>宽: {this.state.elmW}</div>
<div>高: {this.state.elmH}</div>
<a
href="javascript:;"
onClick={() => this.setState({ isChecked: !this.state.isChecked })}
>
{!this.state.isChecked ? "Checked" : "No Checked"}
</a>
|
<a
href="javascript:;"
onClick={() => this.setState({ isRatio: !this.state.isRatio })}
>
{!this.state.isRatio ? "按比例缩放" : "取消比例缩放"}
</a>
|
<a
href="javascript:;"
onClick={() => this.setState({ isDrag: !this.state.isDrag })}
>
{!this.state.isDrag ? "可拖拽" : "禁止拖拽"}
</a>
|
<a
href="javascript:;"
onClick={() => this.setState({ isResize: !this.state.isResize })}
>
{!this.state.isResize ? "可缩放" : "禁止缩放"}
</a>
<Dragresize
elmX={this.state.elmX}
elmY={this.state.elmY}
elmW={this.state.elmW}
elmH={this.state.elmH}
isChecked={this.state.isChecked}
isRatio={this.state.isRatio}
isDrag={this.state.isDrag}
isResize={this.state.isResize}
minLeft={150}
minTop={50}
onMouseMove={({ elmX, elmY }) => {
this.setState({ elmX, elmY });
}}
onResize={({ elmX, elmY, elmW, elmH }) => {
this.setState({ elmX, elmY, elmW, elmH });
}}
/>
</div>
);
}
}
export default Example;