mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-11-30 11:08:14 +08:00
fix(module: modal&drawer): body scroll bar does not respond correctly (#573)
This commit is contained in:
parent
5e63c10d6e
commit
88a26ac583
@ -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";
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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()
|
||||
|
@ -314,7 +314,7 @@ namespace AntDesign
|
||||
{
|
||||
_disableBodyScroll = false;
|
||||
await Task.Delay(250);
|
||||
await JsInvokeAsync(JSInteropConstants.enableModalBodyScroll);
|
||||
await JsInvokeAsync(JSInteropConstants.enableBodyScroll);
|
||||
}
|
||||
|
||||
if (Config.Draggable && _doDragable)
|
||||
|
Loading…
Reference in New Issue
Block a user