mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
32 lines
916 B
JavaScript
32 lines
916 B
JavaScript
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
|
|
|
const TPL = `<div class="scroll-padding-widget"></div>`;
|
|
|
|
export default class ScrollPaddingWidget extends NoteContextAwareWidget {
|
|
isEnabled() {
|
|
return super.isEnabled() && ["text", "code"].includes(this.note?.type);
|
|
}
|
|
|
|
doRender() {
|
|
this.$widget = $(TPL);
|
|
this.contentSized();
|
|
|
|
this.$widget.on("click", () =>
|
|
this.triggerCommand('scrollToEnd', {ntxId: this.ntxId}));
|
|
}
|
|
|
|
initialRenderCompleteEvent() {
|
|
this.$scrollingContainer = this.$widget.closest(".scrolling-container");
|
|
|
|
new ResizeObserver(() => this.refreshHeight()).observe(this.$scrollingContainer[0]);
|
|
|
|
this.refreshHeight();
|
|
}
|
|
|
|
refreshHeight() {
|
|
const containerHeight = this.$scrollingContainer.height();
|
|
|
|
this.$widget.css("height", Math.round(containerHeight / 2));
|
|
}
|
|
}
|