This commit is contained in:
CPPAlien 2019-12-05 09:37:14 +08:00
commit dd90195feb

View File

@ -84,7 +84,9 @@ Component({
observer: function (needClear) { observer: function (needClear) {
if (needClear && !this.needClear) { if (needClear && !this.needClear) {
if (this.frontContext) { if (this.frontContext) {
this.frontContext.draw() setTimeout(() => {
this.frontContext.draw();
}, 100);
this.touchedView = {}; this.touchedView = {};
this.prevFindedIndex = this.findedIndex this.prevFindedIndex = this.findedIndex
this.findedIndex = -1; this.findedIndex = -1;
@ -245,7 +247,7 @@ Component({
const doView = this.touchedView const doView = this.touchedView
if (!doView) { if (!doView || this.isEmpty(doView)) {
return return
} }
if (newVal && newVal.css) { if (newVal && newVal.css) {
@ -266,7 +268,9 @@ Component({
} }
if (newVal && newVal.url && doView.url && newVal.url !== doView.url) { if (newVal && newVal.url && doView.url && newVal.url !== doView.url) {
downloader.download(newVal.url, this.properties.LRU).then((path) => { downloader.download(newVal.url, this.properties.LRU).then((path) => {
doView.originUrl = newVal.url if (newVal.url.startsWidth('https')) {
doView.originUrl = newVal.url
}
doView.url = path; doView.url = path;
wx.getImageInfo({ wx.getImageInfo({
src: path, src: path,
@ -296,8 +300,8 @@ Component({
height: this.currentPalette.height, height: this.currentPalette.height,
views: this.isEmpty(doView) ? [] : [doView] views: this.isEmpty(doView) ? [] : [doView]
} }
const pen = new Pen(this.globalContext, draw); const pen = new Pen(this.globalContext, draw);
if (isMoving && doView.type === 'text') { if (isMoving && doView.type === 'text') {
pen.paint((callbackInfo) => { pen.paint((callbackInfo) => {
callback && callback(callbackInfo); callback && callback(callbackInfo);
@ -306,6 +310,10 @@ Component({
}); });
}, true, this.movingCache); }, true, this.movingCache);
} else { } else {
// 某些机型(华为 P20非移动场景下只绘制一遍会偶然性图片绘制失败目前采用再绘一遍的方法
if (!isMoving && doView.type === 'image') {
pen.paint()
}
pen.paint((callbackInfo) => { pen.paint((callbackInfo) => {
callback && callback(callbackInfo); callback && callback(callbackInfo);
this.triggerEvent('viewUpdate', { this.triggerEvent('viewUpdate', {
@ -313,11 +321,13 @@ Component({
}); });
}) })
} }
const { const {
rect, rect,
css, css,
type type
} = doView } = doView
this.block = { this.block = {
width: this.currentPalette.width, width: this.currentPalette.width,
height: this.currentPalette.height, height: this.currentPalette.height,
@ -419,13 +429,7 @@ Component({
} }
if (this.findedIndex < 0 || (this.touchedView && !this.touchedView.id)) { if (this.findedIndex < 0 || (this.touchedView && !this.touchedView.id)) {
// 证明点击了背景 或无法移动的view // 证明点击了背景 或无法移动的view
const block = { this.frontContext.draw();
width: this.currentPalette.width,
height: this.currentPalette.height,
views: []
}
const topBlock = new Pen(this.frontContext, block)
topBlock.paint();
if (isDelete) { if (isDelete) {
this.triggerEvent('touchEnd', { this.triggerEvent('touchEnd', {
view: this.currentPalette.views[deleteIndex], view: this.currentPalette.views[deleteIndex],
@ -439,7 +443,7 @@ Component({
this.findedIndex = -1 this.findedIndex = -1
this.prevFindedIndex = -1 this.prevFindedIndex = -1
} else if (this.touchedView && this.touchedView.id) { } else if (this.touchedView && this.touchedView.id) {
this.sliceLayers() this.sliceLayers();
} }
}, },
@ -611,7 +615,6 @@ Component({
initDancePalette() { initDancePalette() {
this.initScreenK(); this.initScreenK();
this.downloadImages(this.properties.dancePalette).then((palette) => { this.downloadImages(this.properties.dancePalette).then((palette) => {
this.currentPalette = palette this.currentPalette = palette
const { const {
@ -630,22 +633,12 @@ Component({
this.bottomContext || (this.bottomContext = wx.createCanvasContext('bottom', this)); this.bottomContext || (this.bottomContext = wx.createCanvasContext('bottom', this));
this.topContext || (this.topContext = wx.createCanvasContext('top', this)); this.topContext || (this.topContext = wx.createCanvasContext('top', this));
this.globalContext || (this.globalContext = wx.createCanvasContext('k-canvas', this)); this.globalContext || (this.globalContext = wx.createCanvasContext('k-canvas', this));
new Pen(this.bottomContext, palette).paint(); new Pen(this.bottomContext, palette).paint(() => {
new Pen(this.globalContext, { this.triggerEvent('didShow');
width, });
height, this.globalContext.draw();
views: [] this.frontContext.draw();
}).paint(); this.topContext.draw();
new Pen(this.frontContext, {
width,
height,
views: []
}).paint();
new Pen(this.topContext, {
width,
height,
views: []
}).paint();
}); });
this.touchedView = {}; this.touchedView = {};
}, },