diff --git a/lib/pen.js b/lib/pen.js index 3d7b3b7..cb0d980 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -34,8 +34,8 @@ export default class Painter { this._doClip(this.data.borderRadius, width, height); if (!bg) { - // 如果未设置背景,则默认使用白色 - this.ctx.fillStyle = '#fff'; + // 如果未设置背景,则默认使用透明色 + this.ctx.fillStyle = 'transparent'; this.ctx.fillRect(-(width / 2), -(height / 2), width, height); } else if (bg.startsWith('#') || bg.startsWith('rgba') || bg.toLowerCase() === 'transparent') { // 背景填充颜色 diff --git a/painter.js b/painter.js index 4f2efe5..7fc1c89 100644 --- a/painter.js +++ b/painter.js @@ -130,17 +130,22 @@ Component({ background: this.currentPalette.background, views: bottomLayers } - new Pen(wx.createCanvasContext('bottom', this), bottomDraw).paint(); - const topDraw = { width: this.currentPalette.width, height: this.currentPalette.height, views: topLayers } - new Pen(wx.createCanvasContext('top', this), topDraw).paint(); + if (this.prevFindedIndex < findedIndex) { + new Pen(wx.createCanvasContext('bottom', this), bottomDraw).paint(); + new Pen(wx.createCanvasContext('top', this), topDraw).paint(); + } else { + new Pen(wx.createCanvasContext('top', this), topDraw).paint(); + new Pen(wx.createCanvasContext('bottom', this), bottomDraw).paint(); + } this.doAction() } + this.prevFindedIndex = findedIndex }, onTouchEnd() { diff --git a/painter.wxml b/painter.wxml index 8c173b7..e22af0a 100644 --- a/painter.wxml +++ b/painter.wxml @@ -1,6 +1,12 @@ - \ No newline at end of file + + + + + \ No newline at end of file