Skip to content

Commit

Permalink
fix: Trail view in lp doesn't scroll with element, simpler solution
Browse files Browse the repository at this point in the history
  • Loading branch information
HEmile committed Jan 17, 2022
1 parent 045d04b commit 2cb4378
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Views/TrailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ export async function drawTrail(plugin: BCPlugin): Promise<void> {
: "";

const elForMaxWidth =
selectorForMaxWidth !== ""
? document.querySelector(selectorForMaxWidth)
: null;
selectorForMaxWidth !== ""
? document.querySelector(selectorForMaxWidth)
: null;
const max_width = elForMaxWidth
? getComputedStyle(elForMaxWidth).getPropertyValue("max-width")
: "80%";
: "100%";

const trailDiv = createDiv({
cls: `BC-trail ${
Expand All @@ -178,8 +178,9 @@ export async function drawTrail(plugin: BCPlugin): Promise<void> {
}`,
attr: {
style:
(mode !== "preview" ? `max-width: ${max_width};` : "") +
"margin: 0 auto",
(mode !== "preview" ? `max-width: ${max_width};` : "") +
"margin: 0 auto;",

},
});

Expand All @@ -188,10 +189,12 @@ export async function drawTrail(plugin: BCPlugin): Promise<void> {
if (mode === "preview") {
view.querySelector("div.markdown-preview-sizer").before(trailDiv);
} else {
const cmEditor = view.querySelector("div.cm-editor");
const cmSizer = view.querySelector("div.CodeMirror-sizer");
if (cmEditor) cmEditor.firstChild?.before(trailDiv);
if (cmSizer) cmSizer.before(trailDiv);
const cmEditor = view.querySelector("div.cm-contentContainer");
// const cmSizer = view.querySelector("div.CodeMirror-sizer");
if (cmEditor) {
cmEditor.firstChild?.before(trailDiv);
}
// if (cmSizer) cmSizer.before(trailDiv);
}

trailDiv.empty();
Expand Down

0 comments on commit 2cb4378

Please sign in to comment.