Skip to content

Commit

Permalink
perf: useZindex
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Nov 21, 2024
1 parent c36efe5 commit db8c404
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/components/DraggableCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useDragMove } from '@/utils/draggable';
import { useDragMove, useZindex } from '@/utils/draggable';
const props = withDefaults(
defineProps<{
Expand Down Expand Up @@ -151,7 +151,7 @@ const updateTarget = (arg: unknown) => {
}
};
const { setTop, zIndex } = useZIndexStore().useZindex();
const { setTop, zIndex } = useZindex();
watch(
() => props.show,
() => {
Expand Down
31 changes: 0 additions & 31 deletions src/store/zIndex.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/utils/draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ export const useDragMove = (xFilter: (x: number) => boolean) => {
offset,
};
};

let initValue = 1000;
export const useZindex = () => {
initValue++;
const zIndex = shallowRef(initValue);
const setTop = () => {
zIndex.value = ++initValue;
};
return {
zIndex,
setTop,
};
};

0 comments on commit db8c404

Please sign in to comment.