Feat:checkNodeOuter工具方法支持传递内边距参数
This commit is contained in:
parent
43c7f0551a
commit
09e393b174
@ -398,7 +398,7 @@ export const nextTick = function (fn, ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查节点是否超出画布
|
// 检查节点是否超出画布
|
||||||
export const checkNodeOuter = (mindMap, node) => {
|
export const checkNodeOuter = (mindMap, node, offsetX = 0, offsetY = 0) => {
|
||||||
let elRect = mindMap.elRect
|
let elRect = mindMap.elRect
|
||||||
let { scaleX, scaleY, translateX, translateY } = mindMap.draw.transform()
|
let { scaleX, scaleY, translateX, translateY } = mindMap.draw.transform()
|
||||||
let { left, top, width, height } = node
|
let { left, top, width, height } = node
|
||||||
@ -408,17 +408,17 @@ export const checkNodeOuter = (mindMap, node) => {
|
|||||||
top = top * scaleY + translateY
|
top = top * scaleY + translateY
|
||||||
let offsetLeft = 0
|
let offsetLeft = 0
|
||||||
let offsetTop = 0
|
let offsetTop = 0
|
||||||
if (left < 0) {
|
if (left < 0 + offsetX) {
|
||||||
offsetLeft = -left
|
offsetLeft = -left + offsetX
|
||||||
}
|
}
|
||||||
if (right > elRect.width) {
|
if (right > elRect.width - offsetX) {
|
||||||
offsetLeft = -(right - elRect.width)
|
offsetLeft = -(right - elRect.width) - offsetX
|
||||||
}
|
}
|
||||||
if (top < 0) {
|
if (top < 0 + offsetY) {
|
||||||
offsetTop = -top
|
offsetTop = -top + offsetY
|
||||||
}
|
}
|
||||||
if (bottom > elRect.height) {
|
if (bottom > elRect.height - offsetY) {
|
||||||
offsetTop = -(bottom - elRect.height)
|
offsetTop = -(bottom - elRect.height) - offsetY
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
isOuter: offsetLeft !== 0 || offsetTop !== 0,
|
isOuter: offsetLeft !== 0 || offsetTop !== 0,
|
||||||
@ -508,7 +508,7 @@ export const loadImage = imgFile => {
|
|||||||
|
|
||||||
// 移除字符串中的html实体
|
// 移除字符串中的html实体
|
||||||
export const removeHTMLEntities = str => {
|
export const removeHTMLEntities = str => {
|
||||||
;[[' ', ' ']].forEach(item => {
|
[[' ', ' ']].forEach(item => {
|
||||||
str = str.replace(new RegExp(item[0], 'g'), item[1])
|
str = str.replace(new RegExp(item[0], 'g'), item[1])
|
||||||
})
|
})
|
||||||
return str
|
return str
|
||||||
@ -1069,7 +1069,7 @@ export const generateColorByContent = str => {
|
|||||||
|
|
||||||
// html转义
|
// html转义
|
||||||
export const htmlEscape = str => {
|
export const htmlEscape = str => {
|
||||||
;[
|
[
|
||||||
['&', '&'],
|
['&', '&'],
|
||||||
['<', '<'],
|
['<', '<'],
|
||||||
['>', '>']
|
['>', '>']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user