fix:修改文字缩放按钮位置
This commit is contained in:
parent
fc86eeb33f
commit
031a8139bb
36
painter.js
36
painter.js
@ -7,7 +7,8 @@ const downloader = new Downloader();
|
|||||||
|
|
||||||
// 最大尝试的绘制次数
|
// 最大尝试的绘制次数
|
||||||
const MAX_PAINT_COUNT = 5;
|
const MAX_PAINT_COUNT = 5;
|
||||||
const ACTION_POINT_RADIUS = 10;
|
const ACTION_DEFAULT_SIZE = 10;
|
||||||
|
const ACTION_OFFSET = '2rpx';
|
||||||
Component({
|
Component({
|
||||||
canvasWidthInPx: 0,
|
canvasWidthInPx: 0,
|
||||||
canvasHeightInPx: 0,
|
canvasHeightInPx: 0,
|
||||||
@ -109,7 +110,8 @@ Component({
|
|||||||
return boxArea
|
return boxArea
|
||||||
},
|
},
|
||||||
|
|
||||||
getScaleIcon(rect) {
|
|
||||||
|
getScaleIcon(rect, type) {
|
||||||
let scaleArea = {}
|
let scaleArea = {}
|
||||||
if (this.properties.customActionStyle && this.properties.customActionStyle.scale) {
|
if (this.properties.customActionStyle && this.properties.customActionStyle.scale) {
|
||||||
scaleArea = this.properties.customActionStyle.scale
|
scaleArea = this.properties.customActionStyle.scale
|
||||||
@ -117,17 +119,17 @@ Component({
|
|||||||
scaleArea = {
|
scaleArea = {
|
||||||
type: 'rect',
|
type: 'rect',
|
||||||
css: {
|
css: {
|
||||||
height: `${2 * ACTION_POINT_RADIUS}px`,
|
height: `${2 * ACTION_DEFAULT_SIZE}px`,
|
||||||
width: `${2 * ACTION_POINT_RADIUS}px`,
|
width: `${2 * ACTION_DEFAULT_SIZE}px`,
|
||||||
borderRadius: `${ACTION_POINT_RADIUS}px`,
|
borderRadius: `${ACTION_DEFAULT_SIZE}px`,
|
||||||
color: '#0000ff',
|
color: '#0000ff',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scaleArea.css = Object.assign({}, scaleArea.css, {
|
scaleArea.css = Object.assign({}, scaleArea.css, {
|
||||||
align: 'center',
|
align: 'center',
|
||||||
left: `${rect.right}px`,
|
left: `${rect.right + ACTION_OFFSET.toPx()}px`,
|
||||||
top: `${rect.bottom - scaleArea.css.height.toPx() / 2}px`
|
top: type === 'text' ? `${rect.top - ACTION_OFFSET.toPx() - scaleArea.css.height.toPx() / 2}px` : `${rect.bottom - ACTION_OFFSET.toPx() - scaleArea.css.height.toPx() / 2}px`
|
||||||
})
|
})
|
||||||
Object.assign(scaleArea, {
|
Object.assign(scaleArea, {
|
||||||
id: 'scale'
|
id: 'scale'
|
||||||
@ -143,17 +145,17 @@ Component({
|
|||||||
deleteArea = {
|
deleteArea = {
|
||||||
type: 'rect',
|
type: 'rect',
|
||||||
css: {
|
css: {
|
||||||
height: `${2 * ACTION_POINT_RADIUS}px`,
|
height: `${2 * ACTION_DEFAULT_SIZE}px`,
|
||||||
width: `${2 * ACTION_POINT_RADIUS}px`,
|
width: `${2 * ACTION_DEFAULT_SIZE}px`,
|
||||||
borderRadius: `${ACTION_POINT_RADIUS}px`,
|
borderRadius: `${ACTION_DEFAULT_SIZE}px`,
|
||||||
color: '#0000ff',
|
color: '#0000ff',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteArea.css = Object.assign({}, deleteArea.css, {
|
deleteArea.css = Object.assign({}, deleteArea.css, {
|
||||||
align: 'center',
|
align: 'center',
|
||||||
left: `${rect.left}px`,
|
left: `${rect.left - ACTION_OFFSET.toPx()}px`,
|
||||||
top: `${rect.top - deleteArea.css.height.toPx() / 2}px`
|
top: `${rect.top - ACTION_OFFSET.toPx() - deleteArea.css.height.toPx() / 2}px`
|
||||||
})
|
})
|
||||||
Object.assign(deleteArea, {
|
Object.assign(deleteArea, {
|
||||||
id: 'delete'
|
id: 'delete'
|
||||||
@ -210,17 +212,19 @@ Component({
|
|||||||
pen.paint(callback)
|
pen.paint(callback)
|
||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
rect
|
rect,
|
||||||
|
css,
|
||||||
|
type
|
||||||
} = doView
|
} = doView
|
||||||
this.block = {
|
this.block = {
|
||||||
width: this.currentPalette.width,
|
width: this.currentPalette.width,
|
||||||
height: this.currentPalette.height,
|
height: this.currentPalette.height,
|
||||||
views: this.isEmpty(doView) ? [] : [this.getBox(rect)]
|
views: this.isEmpty(doView) ? [] : [this.getBox(rect)]
|
||||||
}
|
}
|
||||||
if (this.touchedView.css && this.touchedView.css.scalable) {
|
if (css && css.scalable) {
|
||||||
this.block.views.push(this.getScaleIcon(rect))
|
this.block.views.push(this.getScaleIcon(rect, type))
|
||||||
}
|
}
|
||||||
if (this.touchedView.css && this.touchedView.css.deletable) {
|
if (css && css.deletable) {
|
||||||
this.block.views.push(this.getDeleteIcon(rect))
|
this.block.views.push(this.getDeleteIcon(rect))
|
||||||
}
|
}
|
||||||
const topBlock = new Pen(this.frontContext, this.block)
|
const topBlock = new Pen(this.frontContext, this.block)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user