mirror of
https://github.com/zadam/trilium.git
synced 2025-11-14 17:25:52 +01:00
chore(monorepo/client): move client source files
This commit is contained in:
33
apps/client/src/widgets/scroll_padding.ts
Normal file
33
apps/client/src/widgets/scroll_padding.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||
|
||||
const TPL = /*html*/`<div class="scroll-padding-widget"></div>`;
|
||||
|
||||
export default class ScrollPaddingWidget extends NoteContextAwareWidget {
|
||||
|
||||
private $scrollingContainer!: JQuery<HTMLElement>;
|
||||
|
||||
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 ?? 0) / 2));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user