Skip to content

Commit cad70e3

Browse files
committed
Fix: body content may scroll when drawer is opened
1 parent fa2b4e6 commit cad70e3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

npm/dist/blog-scaffold-v2.0.0.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

npm/src/component/drawer.ts

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {showAboutMeDialog} from "./dialog/AboutMeDialog";
77
import {showPreferenceDialog} from "./dialog/PreferenceDialog";
88
import {showSearchDialog} from "./dialog/SearchDialog";
99
import { getSectionTypeByPath, SECTION_TYPE_OPERA, SECTION_TYPE_POETRY, SECTION_TYPE_REPOST, SECTION_TYPE_TAG } from "../base/constant";
10+
import { toggleClassWithEnable } from "../util/tools";
1011
// import "./drawer.scss"
1112

1213
const DRAWER_ITEM_ORIGINAL_ID = "drawer-a-original"
@@ -43,10 +44,13 @@ export function initDrawer() {
4344
drawerList.listElements.map((listItemEl) => new MDCRipple(listItemEl))
4445
drawerList.selectedIndex = currentPageIndex
4546
drawerE.addEventListener("MDCDrawer:opened", () => {
47+
// Drawer弹出时禁止body滚动
48+
toggleClassWithEnable(document.body, "mdc-dialog-scroll-lock", true)
4649
currentSelectedAE.focus()
4750
currentSelectedAE.blur()
4851
});
4952
drawerE.addEventListener("MDCDrawer:closed", () => {
53+
toggleClassWithEnable(document.body, "mdc-dialog-scroll-lock", false)
5054
// 恢复选中
5155
// drawerList.selectedIndex = currentPageIndex
5256
});

0 commit comments

Comments
 (0)