Skip to content

Commit c29f7a4

Browse files
committed
change example
1 parent a5e1125 commit c29f7a4

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
2222
"camelcase": 0,
2323
"no-mixed-operators": 0,
24+
"no-script-url": 0
2425
},
2526
"globals": {
2627
"db": true,

example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Document</title>
5+
<title>Dragresize Example</title>
66
</head>
77
<body>
88
<div id="dragresize"></div>

example/index.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@ import React, { Component } from 'react';
22
import { render } from 'react-dom';
33
import Dragresize from '../src/Dragresize';
44

5+
import './index.less';
6+
57
class Example extends Component {
68
constructor(props) {
79
super(props);
810
this.state = {
911
elmX: 150,
10-
elmY: 10,
12+
elmY: 50,
1113
elmW: 150,
1214
elmH: 100,
13-
isChecked: false,
15+
isChecked: true,
16+
isRatio: false,
17+
isDrag: true,
18+
isResize: true,
1419
};
1520

1621
this.change = (e) => {
@@ -21,22 +26,35 @@ class Example extends Component {
2126
render() {
2227
return (
2328
<div className="example">
24-
<input type="text" onChange={this.change} value={this.state.elmX} />
25-
<div>X: { this.state.elmX }</div>
26-
<div>Y: { this.state.elmY }</div>
27-
<div>W: { this.state.elmW }</div>
28-
<div>H: { this.state.elmH }</div>
29+
<label htmlFor="x">修改X坐标:</label>
30+
<input id="x" type="text" onChange={this.change} value={this.state.elmX} />
31+
<div>X轴: { this.state.elmX }</div>
32+
<div>Y轴: { this.state.elmY }</div>
33+
<div>宽: { this.state.elmW }</div>
34+
<div>高: { this.state.elmH }</div>
2935
<a href="javascript:;" onClick={() => this.setState({ isChecked: !this.state.isChecked })}>
30-
{!this.state.isChecked ? '选中' : '取消'}
36+
{!this.state.isChecked ? 'Checked' : 'No Checked'}
37+
</a>
38+
<a href="javascript:;" onClick={() => this.setState({ isRatio: !this.state.isRatio })}>
39+
{!this.state.isRatio ? '按比例缩放' : '取消比例缩放'}
40+
</a>
41+
<a href="javascript:;" onClick={() => this.setState({ isDrag: !this.state.isDrag })}>
42+
{!this.state.isDrag ? '可拖拽' : '禁止拖拽'}
43+
</a>
44+
<a href="javascript:;" onClick={() => this.setState({ isResize: !this.state.isResize })}>
45+
{!this.state.isResize ? '可缩放' : '禁止缩放'}
3146
</a>
3247
<Dragresize
3348
elmX={this.state.elmX}
3449
elmY={this.state.elmY}
3550
elmW={this.state.elmW}
3651
elmH={this.state.elmH}
3752
isChecked={this.state.isChecked}
38-
isRatio={false}
53+
isRatio={this.state.isRatio}
54+
isDrag={this.state.isDrag}
55+
isResize={this.state.isResize}
3956
minLeft={150}
57+
minTop={50}
4058
onMouseMove={({ elmX, elmY }) => { this.setState({ elmX, elmY }); }}
4159
onResize={({ elmX, elmY, elmW, elmH }) => { this.setState({ elmX, elmY, elmW, elmH }); }}
4260
/>

example/index.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:global{
2+
a {
3+
display: block;
4+
line-height: 2;
5+
}
6+
7+
input {
8+
margin-bottom: 20px;
9+
}
10+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"author": "",
1313
"license": "ISC",
1414
"peerDependencies": {
15-
"react": "^15.0.x",
16-
"react-dom": "^15.0.x"
15+
"react": "^15.x",
16+
"react-dom": "^15.x"
1717
},
1818
"dependencies": {
1919
"react": "^15.3.1",

webpack.dll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
}),
2323
new webpack.optimize.UglifyJsPlugin({
2424
compress: {
25-
warnings: false,
25+
warnings: true,
2626
},
2727
}),
2828
],

0 commit comments

Comments
 (0)