Skip to content

Commit

Permalink
fix: bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sethyuan committed Jun 30, 2023
1 parent 73e398e commit a674762
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-plugin-tocgen",
"version": "2.10.4",
"version": "2.10.5",
"main": "dist/index.html",
"logseq": {
"id": "_sethyuan-logseq-tocgen",
Expand Down
15 changes: 7 additions & 8 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,14 @@ async function main() {
routeOff = logseq.App.onRouteChanged(
async ({ template, parameters: { query } }) => {
if (lastPageUUID) {
const last = lastScrollTop
if (last > 0) {
if (lastScrollTop > 0) {
await logseq.Editor.upsertBlockProperty(
lastPageUUID,
"scroll-top",
last,
lastScrollTop,
)
} else {
await logseq.Editor.removeBlockProperty(lastPageUUID, "scroll-top")
}
}

Expand All @@ -363,11 +364,9 @@ async function main() {
if (currPage == null) return

lastPageUUID = currPage.uuid
if (currPage.properties?.scrollTop != null) {
setTimeout(() => {
gotoOffset(mainContentContainer, currPage.properties.scrollTop)
}, 100)
}
setTimeout(() => {
gotoOffset(mainContentContainer, currPage.properties?.scrollTop ?? 0)
}, 100)
}
},
)
Expand Down

0 comments on commit a674762

Please sign in to comment.