Skip to content

Commit

Permalink
例子3和添加元素保存原值
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijun committed Oct 6, 2019
1 parent 47a9bec commit 0148d32
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class App extends React.Component {
redoButtonStatus: '',
undoButtonStatus: '',
currentOptionArr: _.cloneDeep(newOptionArr), //当前可设置的数组的值
optionArr: _.cloneDeep(newOptionArr), //当前可设置的数组的值
currentObjectType: 'text', //当前要添加对象的类型
importCodeJson: ''
};
Expand Down Expand Up @@ -273,6 +274,9 @@ class App extends React.Component {
visible: true
});
this.canvas_sprite.add(Shape);
if(action !=='update'){
this.changeActiveObjectValue()
}
}
async addTextObject(index, action) {
let currentOptionArr;
Expand Down Expand Up @@ -409,7 +413,7 @@ class App extends React.Component {
rx: borderRadius,
strokeWidth: borderWidth / 1,
stroke: borderColor,
fill: 'rgba(0,0,0,0)',
fill: background,
shadow,
selectable: false
});
Expand Down Expand Up @@ -1293,7 +1297,7 @@ ${json.plain(this.finallObj).replace(/px/g, 'px')}
value={currentObjectType}
onChange={e => {
this.setState({ currentObjectType: e.target.value });
this.currentOptionArr = _.cloneDeep(newOptionArr);
//this.currentOptionArr = _.cloneDeep(newOptionArr); //复原数据
}}
>
{optionArr.map((item, i) => {
Expand All @@ -1306,7 +1310,7 @@ ${json.plain(this.finallObj).replace(/px/g, 'px')}
</Radio.Group>
</div>
</div>
{optionArr.map((item, i) => {
{this.currentOptionArr.map((item, i) => {
if (item.type === currentObjectType) {
return (
<div key={i} className='option-li'>
Expand All @@ -1327,6 +1331,7 @@ ${json.plain(this.finallObj).replace(/px/g, 'px')}
{!_.isArray(item.css[item2]) && item2 !== 'text' && (
<Input
defaultValue={item.css[item2]}
//value={item.css[item2]}
onChange={event => {
this.currentOptionArr[i].css[item2] = event.target.value;
if (item.type === 'canvas') {
Expand Down
1 change: 1 addition & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ input {
.ul {
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.li {
width: 200px;
Expand Down
Binary file added src/example/example3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/example/example3.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/example/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default [
require('./example1').default,
require('./example2').default,
require('./example3').default,
]

0 comments on commit 0148d32

Please sign in to comment.