vuestic-ui
Version:
Vue 3 UI Framework
29 lines (28 loc) • 1.06 kB
JavaScript
import { ref, computed, watch } from "vue";
import { u as useCurrentPageProp } from "./useCommonProps.js";
const useAnimationNameProps = {
...useCurrentPageProp,
animated: { type: Boolean, default: true }
};
const useAnimationName = (props, rows) => {
const animationType = ref("shuffle");
const animationName = computed(() => props.animated ? `table-transition-${animationType.value}` : "");
const oldRowsLength = ref(rows.value.length);
const isDifferentRowLength = computed(() => rows.value.length !== oldRowsLength.value);
watch(rows, (newRows, oldRows) => {
const hasRows = !!(newRows.length && oldRows.length);
animationType.value = newRows.length > 50 || isDifferentRowLength.value && hasRows ? "fade" : "shuffle";
oldRowsLength.value = newRows.length;
});
watch(() => props.currentPage, () => {
if (!isDifferentRowLength.value) {
animationType.value = "shuffle";
}
});
return animationName;
};
export {
useAnimationName as a,
useAnimationNameProps as u
};
//# sourceMappingURL=useAnimationName.js.map