mirror of
https://github.com/marktext/marktext.git
synced 2025-05-04 04:59:05 +08:00
feat: scroll to cursor when switch between tabs (#1089)
This commit is contained in:
parent
d924b58623
commit
d838042543
@ -56,12 +56,15 @@
|
||||
::-webkit-scrollbar-corner {
|
||||
background: var(--floatHoverColor);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar:vertical {
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--editorColor10);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--editorColor30);
|
||||
}
|
||||
|
@ -273,6 +273,11 @@
|
||||
codeFontFamily: value
|
||||
})
|
||||
}
|
||||
},
|
||||
currentFile: function (value, oldValue) {
|
||||
if (value && value !== oldValue) {
|
||||
this.scrollToCursor(0)
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -524,11 +529,11 @@
|
||||
this.$store.dispatch('SHOW_IMAGE_DELETION_URL', deletionUrl)
|
||||
},
|
||||
|
||||
scrollToCursor () {
|
||||
scrollToCursor (duration = 300) {
|
||||
this.$nextTick(() => {
|
||||
const { container } = this.editor
|
||||
const { y } = this.editor.getSelection().cursorCoords
|
||||
animatedScrollTo(container, container.scrollTop + y - STANDAR_Y, 300)
|
||||
animatedScrollTo(container, container.scrollTop + y - STANDAR_Y, duration)
|
||||
})
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user