Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions components/painter/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ Component({
this.needClear = needClear;
},
},
//用户自定义传入参数 可传递回调函数等
customOpt: {
type: Object,
value: {},
},
},

data: {
Expand Down Expand Up @@ -642,6 +647,7 @@ Component({
}
this.setData(
{
// use2d 为true的情况wxml中canvas标签的宽高无法动态设置!这里setData并无法真正的设置成功!请在canvas标签增加wx:if="{{photoStyle}}"
photoStyle: `width:${this.canvasWidthInPx}px;height:${this.canvasHeightInPx}px;`,
},
function () {
Expand Down Expand Up @@ -736,12 +742,15 @@ Component({
const that = this;
const optionsOf2d = {
canvas: that.canvasNode,
}
// 这里使用canvas2d时候,不能再自行设置宽高,会导致图像模糊。真机调试为准!!模拟器有问题!
// destWidth: that.canvasWidthInPx,
// destHeight: that.canvasHeightInPx,
};
const optionsOfOld = {
canvasId: 'photo',
destWidth: that.canvasWidthInPx,
destHeight: that.canvasHeightInPx,
}
};
setTimeout(() => {
wx.canvasToTempFilePath(
{
Expand Down Expand Up @@ -806,6 +815,12 @@ Component({
that.triggerEvent('imgOK', {
path: filePath,
});
// auth: hlr : 在taro 3.4.9 版本 triggerEvent 无法触发回调。只能用这个方式手动传入回调函数,在callback中返回!
if (that.properties.customOpt.onImgOK) {
that.properties.customOpt.onImgOK({
path: filePath,
});
}
} else {
that.startPaint();
}
Expand Down
2 changes: 1 addition & 1 deletion components/painter/painter.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</block>
</block>
<block wx:if="{{use2D}}">
<canvas type="2d" id="photo" style="{{photoStyle}};" />
<canvas type="2d" id="photo" style="{{photoStyle}};" wx:if="{{photoStyle}}" />
</block>
</view>