mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-01 20:32:19 +08:00
Fix lag when scrolling the tab row.
This commit is contained in:
parent
1c199938b6
commit
897fde7332
@ -377,23 +377,29 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
this.$widget.append(this.$style);
|
this.$widget.append(this.$style);
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollTabContainer(direction: number) {
|
scrollTabContainer(direction: number, behavior: ScrollBehavior = "smooth") {
|
||||||
const currentScrollLeft = this.$tabScrollingContainer?.scrollLeft() ?? 0;
|
const currentScrollLeft = this.$tabScrollingContainer[0]?.scrollLeft;
|
||||||
this.$tabScrollingContainer[0].scrollTo({
|
this.$tabScrollingContainer[0].scrollTo({
|
||||||
left: currentScrollLeft + direction,
|
left: currentScrollLeft + direction,
|
||||||
behavior: "smooth"
|
behavior
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
setupScrollEvents() {
|
setupScrollEvents() {
|
||||||
|
let isScrolling = false;
|
||||||
|
this.$tabScrollingContainer[0].addEventListener('wheel', (event) => {
|
||||||
|
if (!isScrolling) {
|
||||||
|
isScrolling = true;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
this.scrollTabContainer(event.deltaY * 1.5, 'instant');
|
||||||
|
isScrolling = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.$scrollButtonLeft[0].addEventListener('click', () => this.scrollTabContainer(-200));
|
this.$scrollButtonLeft[0].addEventListener('click', () => this.scrollTabContainer(-200));
|
||||||
this.$scrollButtonRight[0].addEventListener('click', () => this.scrollTabContainer(200));
|
this.$scrollButtonRight[0].addEventListener('click', () => this.scrollTabContainer(200));
|
||||||
|
|
||||||
this.$tabScrollingContainer[0].addEventListener('wheel', (event) => {
|
|
||||||
const targetScrollLeft = event.deltaY * 1.5;
|
|
||||||
this.scrollTabContainer(targetScrollLeft);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$tabScrollingContainer[0].addEventListener('scroll', () => {
|
this.$tabScrollingContainer[0].addEventListener('scroll', () => {
|
||||||
clearTimeout(this.updateScrollTimeout);
|
clearTimeout(this.updateScrollTimeout);
|
||||||
this.updateScrollTimeout = setTimeout(() => {
|
this.updateScrollTimeout = setTimeout(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user