From 09e393b1741ce794cd7881e73d471a55bcefc5b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Tue, 18 Feb 2025 09:45:44 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9AcheckNodeOuter=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81=E4=BC=A0=E9=80=92=E5=86=85?= =?UTF-8?q?=E8=BE=B9=E8=B7=9D=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/utils/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index 94d42aab..b3524ad8 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -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 { scaleX, scaleY, translateX, translateY } = mindMap.draw.transform() let { left, top, width, height } = node @@ -408,17 +408,17 @@ export const checkNodeOuter = (mindMap, node) => { top = top * scaleY + translateY let offsetLeft = 0 let offsetTop = 0 - if (left < 0) { - offsetLeft = -left + if (left < 0 + offsetX) { + offsetLeft = -left + offsetX } - if (right > elRect.width) { - offsetLeft = -(right - elRect.width) + if (right > elRect.width - offsetX) { + offsetLeft = -(right - elRect.width) - offsetX } - if (top < 0) { - offsetTop = -top + if (top < 0 + offsetY) { + offsetTop = -top + offsetY } - if (bottom > elRect.height) { - offsetTop = -(bottom - elRect.height) + if (bottom > elRect.height - offsetY) { + offsetTop = -(bottom - elRect.height) - offsetY } return { isOuter: offsetLeft !== 0 || offsetTop !== 0, @@ -508,7 +508,7 @@ export const loadImage = imgFile => { // 移除字符串中的html实体 export const removeHTMLEntities = str => { - ;[[' ', ' ']].forEach(item => { + [[' ', ' ']].forEach(item => { str = str.replace(new RegExp(item[0], 'g'), item[1]) }) return str @@ -1069,7 +1069,7 @@ export const generateColorByContent = str => { // html转义 export const htmlEscape = str => { - ;[ + [ ['&', '&'], ['<', '<'], ['>', '>']