Skip to content

Commit

Permalink
🐛 エラー修正
Browse files Browse the repository at this point in the history
  • Loading branch information
takuma-ru committed May 9, 2024
1 parent a4e5f90 commit 08d6986
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
1 change: 1 addition & 0 deletions packages/core/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default antfu({
{ arraysInArrays: false },
],
"style/array-bracket-newline": [ "error", { multiline: true, minItems: 3 } ],
"no-unused-vars": "error",
},
typescript: true,
vue: true,
Expand Down
29 changes: 1 addition & 28 deletions packages/core/src/components/SwipeModal/SwipeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { usePointerEvent } from "../../hooks/usePointerEvent";
import { useModalAnim } from "../../hooks/useModalAnim";
import { useCssVar } from "../../hooks/useCssVar";
import { ANIMATION_EASING } from "../../constants";
import { setPageScrollable } from "../../utils/setPageScrollable";
import type { SwipeModalEmits, SwipeModalProps } from "./SwipeModal.types";
const props = withDefaults(defineProps<SwipeModalProps>(), {
Expand Down Expand Up @@ -83,34 +84,6 @@ const {
// functions
/**
* 背景がスクロールできるかどうかを制御する
*/
const setPageScrollable = (scrollable: "auto" | "hidden" | "reset") => {
if (scrollable === "reset") {
document.documentElement.style.removeProperty("overflow");
document.documentElement.style.removeProperty("overscroll-behavior-y");
return;
}
let dv = window;
let xOffset, yOffset, de;
if (document.defaultView) {
dv = document.defaultView;
xOffset = dv.scrollX;
yOffset = dv.scrollY;
}
else {
de = document.documentElement;
xOffset = de.scrollLeft;
yOffset = de.scrollTop;
}
document.documentElement.style.overflow = scrollable;
document.documentElement.style.overscrollBehaviorY
= scrollable === "auto" ? "auto" : "none";
dv.scrollTo(xOffset, yOffset);
};
const handleClickDialog = (event: MouseEvent) => {
if (!props.isBackdrop)
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useCssVar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useCssVar = ({ scopeName }: UseCssVarParameter) => {
};

const setCssVar = ({ name, value, fallback }: SetCssVarParameter) => {
document.documentElement.style.setProperty(`--${scopeName}-${name}`, value);
document.documentElement.style.setProperty(`--${scopeName}-${name}`, value);

fallback?.(
name,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/useModalAnim.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComputedRef, Ref } from "vue";
import type { Ref } from "vue";
import type { SwipeModalProps } from "../components/SwipeModal/SwipeModal.types";
import { ANIMATION_EASING } from "../constants";
import { useCssVar } from "./useCssVar";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/hooks/usePointerEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComputedRef, Ref, WritableComputedRef } from "vue";
import type { Ref, WritableComputedRef } from "vue";
import { ref } from "vue";
import type { SwipeModalProps } from "../components/SwipeModal/SwipeModal.types";
import { useModalAnim } from "./useModalAnim";
Expand Down
27 changes: 27 additions & 0 deletions packages/core/src/utils/setPageScrollable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 背景がスクロールできるかどうかを制御する
*/
export const setPageScrollable = (scrollable: "auto" | "hidden" | "reset") => {
if (scrollable === "reset") {
document.documentElement.style.removeProperty("overflow");
document.documentElement.style.removeProperty("overscroll-behavior-y");
return;
}

let dv = window;
let xOffset, yOffset, de;
if (document.defaultView) {
dv = document.defaultView;
xOffset = dv.scrollX;
yOffset = dv.scrollY;
}
else {
de = document.documentElement;
xOffset = de.scrollLeft;
yOffset = de.scrollTop;
}
document.documentElement.style.overflow = scrollable;
document.documentElement.style.overscrollBehaviorY
= scrollable === "auto" ? "auto" : "none";
dv.scrollTo(xOffset, yOffset);
};

0 comments on commit 08d6986

Please sign in to comment.