Skip to content

Commit

Permalink
Merge pull request #1228 from Wizleap-Inc/fix/vue-popup-position
Browse files Browse the repository at this point in the history
fix: ポップアップの座標計算修正(vue)
  • Loading branch information
ichi-h authored Feb 27, 2024
2 parents 81ccf0d + 76008de commit 4116c61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-ants-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wizleap-inc/wiz-ui-next": patch
---

ポップアップの座標計算を修正
13 changes: 10 additions & 3 deletions packages/wiz-ui-next/src/components/base/popup/popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
inject,
nextTick,
onMounted,
onUnmounted,
PropType,
reactive,
ref,
Expand Down Expand Up @@ -130,6 +131,11 @@ const popupSize = reactive({
width: 0,
height: 0,
});
const updatePopupSize = () => {
popupSize.width = popupRef.value?.offsetWidth ?? 0;
popupSize.height = popupRef.value?.offsetHeight ?? 0;
};
const popupSizeObserver = new ResizeObserver(updatePopupSize);
const injected = inject(POPUP_KEY);
Expand All @@ -141,11 +147,13 @@ if (!injected) {
const { bodyPxInfo, updateBodyPxInfo, containerRef } = injected;
// safariでアニメーションを有効にするために必要
onMounted(() => {
if (!popupRef.value) return;
popupSizeObserver.observe(popupRef.value);
// safariでアニメーションを有効にするために必要
popupRef.value.style.animationName = "fade";
});
onUnmounted(() => popupSizeObserver.disconnect());
const togglePopup = () => {
if (!props.animation) return (isActuallyOpen.value = props.isOpen);
Expand Down Expand Up @@ -182,8 +190,7 @@ const onChangeIsOpen = (newValue: boolean) => {
togglePopup();
removeScrollHandler = useScroll(updateBodyPxInfo, containerRef.value);
nextTick(() => {
popupSize.width = popupRef.value?.offsetWidth ?? 0;
popupSize.height = popupRef.value?.offsetHeight ?? 0;
updatePopupSize();
updateBodyPxInfo();
});
} else {
Expand Down

0 comments on commit 4116c61

Please sign in to comment.