Skip to content

Commit

Permalink
更新Mirror只有图片生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
purestart committed May 6, 2020
1 parent e391c4e commit 0a87c90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/components/fabric/fabric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -569,17 +569,18 @@ export default {
});
},
// 设置mirror
toggleMirror ({ flip = 'X' }) {
toggleMirror (options) {
options = options || {};
options = Object.assign({ flip : 'X' },options);
let img = this.canvas.getActiveObject();
// console.log(img);
if (img && img.type == 'image') {
if (flip === 'X') {
// if (img && img.type == 'image') {
if (options.flip === 'X') {
img.toggle('flipX');
} else {
img.toggle('flipY');
}
this.renderAll();
}
// }
},
// 设置层级
toNextLayer () {
Expand Down
5 changes: 4 additions & 1 deletion src/examples/index-pc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<i @click="handleDelete" class="pt-iconfont icon-delete"></i>
<i @click="rotate" class="pt-iconfont icon-shuaxin"></i>
<i @click="createImg" class="pt-iconfont icon-crop"></i>
<i @click="discardActive" class="pt-iconfont icon-crop"></i>
<i @click="toggleMirror" class="pt-iconfont icon-crop"></i>
</div>
</div>
<vue-image-model :close="()=>{imgUrl=''}" v-show="imgUrl.length>0" :url="imgUrl"></vue-image-model>
Expand Down Expand Up @@ -83,6 +83,9 @@ export default {
this.$refs.canvas.drawByPath([[50, 50], [120, 120], [80, 160]], {});
},
methods: {
toggleMirror() {
this.$refs.canvas.toggleMirror({flip:"Y"});
},
discardActive () {
this.$refs.canvas.discardActive();
},
Expand Down

0 comments on commit 0a87c90

Please sign in to comment.