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 {
background: var(--floatHoverColor);
}
::-webkit-scrollbar:vertical {
width: 12px;
}
::-webkit-scrollbar-thumb {
background: var(--editorColor10);
}
::-webkit-scrollbar-thumb:hover {
background: var(--editorColor30);
}

View File

@ -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)
})
},