fix(module: modal&drawer): body scroll bar does not respond correctly (#573)

This commit is contained in:
zxyao 2020-09-05 16:09:58 +08:00 committed by GitHub
parent 5e63c10d6e
commit 88a26ac583
4 changed files with 12 additions and 36 deletions

View File

@ -63,9 +63,7 @@ namespace AntDesign
public static string disableBodyScroll => $"{FUNC_PREFIX}disableBodyScroll";
public static string enableModalBodyScroll => $"{FUNC_PREFIX}enableModalBodyScroll";
public static string enableDrawerBodyScroll => $"{FUNC_PREFIX}enableDrawerBodyScroll";
public static string enableBodyScroll => $"{FUNC_PREFIX}enableBodyScroll";
public static string CreateIconFromfontCN => $"{FUNC_PREFIX}createIconFromfontCN";

View File

@ -377,38 +377,16 @@ export function disableBodyScroll() {
addCls(document.body, "ant-scrolling-effect");
}
function enableBodyScroll(selector, filter = null) {
let length = 0;
let queryElements = document.querySelectorAll(selector);
if (typeof filter === "function") {
queryElements.forEach((value, key, parent) => {
if (!filter(value, key, parent)) {
length += 1;
}
export function enableBodyScroll() {
let oldBodyCache = oldBodyCacheStack.length > 0 ? oldBodyCacheStack.pop() : {};
css(document.body,
{
"position": oldBodyCache["position"] ?? null,
"width": oldBodyCache["width"] ?? null,
"overflow": oldBodyCache["overflow"] ?? null
});
} else {
length = queryElements.length;
}
if (length === 0) {
let oldBodyCache = oldBodyCacheStack.length > 0 ? oldBodyCacheStack.pop() : {};
css(document.body,
{
"position": oldBodyCache["position"] ?? null,
"width": oldBodyCache["width"] ?? null,
"overflow": oldBodyCache["overflow"] ?? null
});
removeCls(document.body, "ant-scrolling-effect");
}
}
export function enableModalBodyScroll() {
enableBodyScroll(".ant-modal-mask:not(.ant-modal-mask-hidden)");
}
export function enableDrawerBodyScroll() {
enableBodyScroll(".ant-drawer-open",
(value, key, parent) => { return value.style.position === "absolute" });
removeCls(document.body, "ant-scrolling-effect");
}
export function createIconFromfontCN(scriptUrl) {

View File

@ -314,7 +314,7 @@ namespace AntDesign
await OnClose.InvokeAsync(this);
await Task.Delay(10);
}
await JsInvokeAsync(JSInteropConstants.enableDrawerBodyScroll);
await JsInvokeAsync(JSInteropConstants.enableBodyScroll);
}
private void CalcAnimation()

View File

@ -314,7 +314,7 @@ namespace AntDesign
{
_disableBodyScroll = false;
await Task.Delay(250);
await JsInvokeAsync(JSInteropConstants.enableModalBodyScroll);
await JsInvokeAsync(JSInteropConstants.enableBodyScroll);
}
if (Config.Draggable && _doDragable)