feat: scroll to cursor when switch between tabs (#1089)

This commit is contained in:
Ran Luo 2019-06-11 00:41:24 +08:00 committed by Felix Häusler
parent d924b58623
commit d838042543
2 changed files with 10 additions and 2 deletions

View File

@ -56,12 +56,15 @@
::-webkit-scrollbar-corner { ::-webkit-scrollbar-corner {
background: var(--floatHoverColor); background: var(--floatHoverColor);
} }
::-webkit-scrollbar:vertical { ::-webkit-scrollbar:vertical {
width: 12px; width: 12px;
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background: var(--editorColor10); background: var(--editorColor10);
} }
::-webkit-scrollbar-thumb:hover { ::-webkit-scrollbar-thumb:hover {
background: var(--editorColor30); background: var(--editorColor30);
} }

View File

@ -273,6 +273,11 @@
codeFontFamily: value codeFontFamily: value
}) })
} }
},
currentFile: function (value, oldValue) {
if (value && value !== oldValue) {
this.scrollToCursor(0)
}
} }
}, },
created () { created () {
@ -524,11 +529,11 @@
this.$store.dispatch('SHOW_IMAGE_DELETION_URL', deletionUrl) this.$store.dispatch('SHOW_IMAGE_DELETION_URL', deletionUrl)
}, },
scrollToCursor () { scrollToCursor (duration = 300) {
this.$nextTick(() => { this.$nextTick(() => {
const { container } = this.editor const { container } = this.editor
const { y } = this.editor.getSelection().cursorCoords const { y } = this.editor.getSelection().cursorCoords
animatedScrollTo(container, container.scrollTop + y - STANDAR_Y, 300) animatedScrollTo(container, container.scrollTop + y - STANDAR_Y, duration)
}) })
}, },