Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(presentation): close the seam under web view slides on desktop
Elian Doran55748c994c12
diff --git a/apps/client/src/widgets/collections/presentation/index.spec.ts b/apps/client/src/widgets/collections/presentation/index.spec.tsindex fa452d936f..6357ed49ac 100644--- a/apps/client/src/widgets/collections/presentation/index.spec.ts+++ b/apps/client/src/widgets/collections/presentation/index.spec.ts@@ -38,8 +38,8 @@ describe("fitSlideContent", () => {describe("setViewportSize", () => {it("sizes the viewport in slide pixels from the scale that Reveal.js applied", () => {const container = document.createElement("div");- Object.defineProperty(container, "offsetWidth", { value: 1100 });- Object.defineProperty(container, "offsetHeight", { value: 618.75 });+ // offsetHeight would round this to 619.+ container.getBoundingClientRect = () => ({ width: 1100, height: 618.75 }) as DOMRect;// 1100px less the 4% margin gives a scale of 0.825, which Reveal.js rounds to 0.83.setViewportSize(container, { getScale: () => 0.83 });diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsxindex f714480fb4..ba64042df8 100644--- a/apps/client/src/widgets/collections/presentation/index.tsx+++ b/apps/client/src/widgets/collections/presentation/index.tsx@@ -343,8 +343,10 @@ function getNoteIdFromSlide(slide: HTMLElement | undefined) {export function setViewportSize(container: HTMLElement, api: Pick<RevealApi, "getScale">) {const scale = api.getScale();if (!scale) return;- container.style.setProperty("--viewport-width", `${container.offsetWidth / scale}px`);- container.style.setProperty("--viewport-height", `${container.offsetHeight / scale}px`);+ // `offsetWidth` and `offsetHeight` round to whole pixels, which can leave a sub-pixel seam at the edges.+ const { width, height } = container.getBoundingClientRect();+ container.style.setProperty("--viewport-width", `${width / scale}px`);+ container.style.setProperty("--viewport-height", `${height / scale}px`);}function rewireLinks(container: HTMLElement, api: RevealApi) {diff --git a/apps/client/src/widgets/collections/presentation/slidejs.css b/apps/client/src/widgets/collections/presentation/slidejs.cssindex 61128aed04..702e2f64ba 100644--- a/apps/client/src/widgets/collections/presentation/slidejs.css+++ b/apps/client/src/widgets/collections/presentation/slidejs.css@@ -112,7 +112,7 @@ footer.file-footer {position: absolute;top: 50%;left: 50%;- width: var(--viewport-width, 100%);- height: var(--viewport-height, 100cqh);+ width: calc(var(--viewport-width, 100%) + 2px);+ height: calc(var(--viewport-height, 100cqh) + 2px);transform: translate(-50%, -50%);}\ No newline at end of file