Demo:显示和移除滚动条时同时进行滚动条插件的注册和移除

This commit is contained in:
街角小林 2023-12-21 12:09:10 +08:00
parent 88f2e60720
commit 7b8946bec4
2 changed files with 21 additions and 1 deletions

View File

@ -94,7 +94,6 @@ MindMap.usePlugin(MiniMap)
.usePlugin(TouchEvent)
.usePlugin(SearchPlugin)
.usePlugin(Painter)
.usePlugin(ScrollbarPlugin)
.usePlugin(Formula)
// .usePlugin(Cooperate)//
@ -145,6 +144,7 @@ export default {
...mapState({
isZenMode: state => state.localConfig.isZenMode,
openNodeRichText: state => state.localConfig.openNodeRichText,
isShowScrollbar: state => state.localConfig.isShowScrollbar,
useLeftKeySelectionRightKeyDrag: state =>
state.localConfig.useLeftKeySelectionRightKeyDrag,
isShowScrollbar: state => state.localConfig.isShowScrollbar
@ -157,6 +157,13 @@ export default {
} else {
this.removeRichTextPlugin()
}
},
isShowScrollbar() {
if (this.isShowScrollbar) {
this.addScrollbarPlugin()
} else {
this.removeScrollbarPlugin()
}
}
},
mounted() {
@ -378,6 +385,7 @@ export default {
// }
})
if (this.openNodeRichText) this.addRichTextPlugin()
if (this.isShowScrollbar) this.addScrollbarPlugin()
this.mindMap.keyCommand.addShortcut('Control+s', () => {
this.manualSave()
})
@ -525,6 +533,17 @@ export default {
this.mindMap.removePlugin(RichText)
},
//
addScrollbarPlugin() {
if (!this.mindMap) return
this.mindMap.addPlugin(ScrollbarPlugin)
},
//
removeScrollbarPlugin() {
this.mindMap.removePlugin(ScrollbarPlugin)
},
//
testDynamicCreateNodes() {
// return

View File

@ -61,6 +61,7 @@ export default {
methods: {
//
setScrollBarWrapSize() {
if (!this.mindMap.scrollbar) return
const {
width
} = this.$refs.horizontalScrollbarRef.getBoundingClientRect()