mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Fix:修复容器尺寸改变后没有水印没有重新绘制的问题
This commit is contained in:
@@ -190,6 +190,7 @@ class MindMap {
|
||||
resize() {
|
||||
this.getElRectInfo()
|
||||
this.svg.size(this.width, this.height)
|
||||
this.emit('resize')
|
||||
}
|
||||
|
||||
// 监听事件
|
||||
|
||||
@@ -12,10 +12,29 @@ class Watermark {
|
||||
this.text = '' // 水印文字
|
||||
this.textStyle = {} // 水印文字样式
|
||||
this.watermarkDraw = null // 容器
|
||||
this.maxLong = Math.sqrt(
|
||||
this.maxLong = this.getMaxLong()
|
||||
this.updateWatermark(this.mindMap.opt.watermarkConfig || {})
|
||||
this.bindEvent()
|
||||
}
|
||||
|
||||
getMaxLong() {
|
||||
return Math.sqrt(
|
||||
Math.pow(this.mindMap.width, 2) + Math.pow(this.mindMap.height, 2)
|
||||
)
|
||||
this.updateWatermark(this.mindMap.opt.watermarkConfig || {})
|
||||
}
|
||||
|
||||
bindEvent() {
|
||||
this.onResize = this.onResize.bind(this)
|
||||
this.mindMap.on('resize', this.onResize)
|
||||
}
|
||||
|
||||
unBindEvent() {
|
||||
this.mindMap.off('resize', this.onResize)
|
||||
}
|
||||
|
||||
onResize() {
|
||||
this.maxLong = this.getMaxLong()
|
||||
this.draw()
|
||||
}
|
||||
|
||||
// 创建水印容器
|
||||
@@ -136,6 +155,16 @@ class Watermark {
|
||||
this.handleConfig(config)
|
||||
this.draw()
|
||||
}
|
||||
|
||||
// 插件被移除前做的事情
|
||||
beforePluginRemove() {
|
||||
this.unBindEvent()
|
||||
}
|
||||
|
||||
// 插件被卸载前做的事情
|
||||
beforePluginDestroy() {
|
||||
this.unBindEvent()
|
||||
}
|
||||
}
|
||||
|
||||
Watermark.instanceName = 'watermark'
|
||||
|
||||
Reference in New Issue
Block a user