mirror of
https://github.com/marktext/marktext.git
synced 2025-05-08 04:01:30 +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 {
|
::-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);
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user