Skip to content

Commit

Permalink
fix: use absolute position handle KMask (#129)
Browse files Browse the repository at this point in the history
* fix: use absolute position handle KMask

* test: updated snap
  • Loading branch information
baiwusanyu-c authored Aug 22, 2023
1 parent 47a1473 commit 6dfa245
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Test: KDrawer > slot: content 1`] = `"<div style=\\"top: 0px; left: 0px; width: 100%; height: 100%;\\" class=\\"k-mask--base \\"><div class=\\"k-drawer--base k-drawer--base__dark right-0 \\"><div class=\\"k-drawer--op justify-start\\"><div role=\\"button\\" aria-hidden=\\"true\\" class=\\"k-icon--base k-icon--base__dark cursor-pointer \\"><div class=\\"i-carbon-chevron-right k-icon-transition hover:text-main\\" style=\\"width: 24px; height: 24px;\\"></div></div></div> <div class=\\"k-drawer--content\\" style=\\"height: calc(100% - 24px);\\"><div class=\\"w-full fc\\" id=\\"k_drawer_content\\"><h2 class=\\"w-300px text-center !my-2\\">A person's loneliness, never had the lonely mood is wrapped by this dark night.</h2></div></div></div></div>"`;
exports[`Test: KDrawer > slot: content 1`] = `"<div style=\\"top: 0px; left: 0px; width: 100%; height: 100%; position: fixed;\\" class=\\"k-mask--base \\"><div class=\\"k-drawer--base k-drawer--base__dark right-0 \\"><div class=\\"k-drawer--op justify-start\\"><div role=\\"button\\" aria-hidden=\\"true\\" class=\\"k-icon--base k-icon--base__dark cursor-pointer \\"><div class=\\"i-carbon-chevron-right k-icon-transition hover:text-main\\" style=\\"width: 24px; height: 24px;\\"></div></div></div> <div class=\\"k-drawer--content\\" style=\\"height: calc(100% - 24px);\\"><div class=\\"w-full fc\\" id=\\"k_drawer_content\\"><h2 class=\\"w-300px text-center !my-2\\">A person's loneliness, never had the lonely mood is wrapped by this dark night.</h2></div></div></div></div>"`;
10 changes: 8 additions & 2 deletions components/Mask/src/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
if (containerDomRect) {
drawerWidth = containerDomRect.width ? `${containerDomRect.width}px` : '100%';
drawerHeight = containerDomRect.height ? `${containerDomRect.height}px` : '100%';
drawerTop = containerDomRect.top;
drawerLeft = containerDomRect.left;
// drawerTop = containerDomRect.top;
// drawerLeft = containerDomRect.left;
}
};
async function setParent() {
if (!target && value) {
await tick();
const parentEl = getParentEle()
if(parentEl === document.body){
drawerRef && (drawerRef.style.position = 'fixed');
}
parentEl.style.overflow = 'hidden'
parentEl.style.position = 'relative'
updatedPosition();
Expand All @@ -43,6 +46,9 @@
if (target && value) {
await tick();
if(target === document.body){
drawerRef && (drawerRef.style.position = 'fixed');
}
drawerRef && (target.style.overflow = 'hidden');
drawerRef && (target.style.position = 'relative');
updatedPosition();
Expand Down
121 changes: 22 additions & 99 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion preset/src/shortcuts/mask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const maskShortcuts: Record<string, string> = {
// mask
'k-mask--base': 'ikun:50:bg-ikun-black z-999 fixed'
'k-mask--base': 'ikun:50:bg-ikun-black z-999 absolute'
};

0 comments on commit 6dfa245

Please sign in to comment.