优化主题配置更新,改变不涉及节点大小的配置不触发节点重新计算
This commit is contained in:
parent
0886ba7698
commit
5bb23ca738
@ -10,7 +10,7 @@ import BatchExecution from './src/BatchExecution'
|
|||||||
import { layoutValueList, CONSTANTS } from './src/utils/constant'
|
import { layoutValueList, CONSTANTS } from './src/utils/constant'
|
||||||
import { SVG } from '@svgdotjs/svg.js'
|
import { SVG } from '@svgdotjs/svg.js'
|
||||||
import { simpleDeepClone } from './src/utils'
|
import { simpleDeepClone } from './src/utils'
|
||||||
import defaultTheme from './src/themes/default'
|
import defaultTheme, { checkIsNodeSizeIndependenceConfig } from './src/themes/default'
|
||||||
|
|
||||||
// 默认选项配置
|
// 默认选项配置
|
||||||
const defaultOpt = {
|
const defaultOpt = {
|
||||||
@ -267,7 +267,9 @@ class MindMap {
|
|||||||
// 设置主题配置
|
// 设置主题配置
|
||||||
setThemeConfig(config) {
|
setThemeConfig(config) {
|
||||||
this.opt.themeConfig = config
|
this.opt.themeConfig = config
|
||||||
this.render(null, CONSTANTS.CHANGE_THEME)
|
// 检查改变的是否是节点大小无关的主题属性
|
||||||
|
let res = checkIsNodeSizeIndependenceConfig(config)
|
||||||
|
this.render(null, res ? '' : CONSTANTS.CHANGE_THEME)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取自定义主题配置
|
// 获取自定义主题配置
|
||||||
|
|||||||
@ -156,4 +156,38 @@ export const supportActiveStyle = [
|
|||||||
'borderRadius'
|
'borderRadius'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 检测主题配置是否是节点大小无关的
|
||||||
|
const nodeSizeIndependenceList = [
|
||||||
|
'lineWidth',
|
||||||
|
'lineColor',
|
||||||
|
'lineDasharray',
|
||||||
|
'lineStyle',
|
||||||
|
'generalizationLineWidth',
|
||||||
|
'generalizationLineColor',
|
||||||
|
'associativeLineWidth',
|
||||||
|
'associativeLineColor',
|
||||||
|
'associativeLineActiveWidth',
|
||||||
|
'associativeLineActiveColor',
|
||||||
|
'associativeLineTextColor',
|
||||||
|
'associativeLineTextFontSize',
|
||||||
|
'associativeLineTextLineHeight',
|
||||||
|
'associativeLineTextFontFamily',
|
||||||
|
'backgroundColor',
|
||||||
|
'backgroundImage',
|
||||||
|
'backgroundRepeat',
|
||||||
|
'backgroundPosition',
|
||||||
|
'backgroundSize'
|
||||||
|
]
|
||||||
|
export const checkIsNodeSizeIndependenceConfig = (config) => {
|
||||||
|
let keys = Object.keys(config)
|
||||||
|
for(let i = 0; i < keys.length; i++) {
|
||||||
|
if (!nodeSizeIndependenceList.find((item) => {
|
||||||
|
return item === keys[i]
|
||||||
|
})) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
export const lineStyleProps = ['lineColor', 'lineDasharray', 'lineWidth']
|
export const lineStyleProps = ['lineColor', 'lineDasharray', 'lineWidth']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user