lazy.mjs 581 B

1234567891011121314151617181920
  1. // Utilities
  2. import { computed, shallowRef, watch } from 'vue';
  3. import { propsFactory } from "../util/index.mjs"; // Types
  4. export const makeLazyProps = propsFactory({
  5. eager: Boolean
  6. }, 'lazy');
  7. export function useLazy(props, active) {
  8. const isBooted = shallowRef(false);
  9. const hasContent = computed(() => isBooted.value || props.eager || active.value);
  10. watch(active, () => isBooted.value = true);
  11. function onAfterLeave() {
  12. if (!props.eager) isBooted.value = false;
  13. }
  14. return {
  15. isBooted,
  16. hasContent,
  17. onAfterLeave
  18. };
  19. }
  20. //# sourceMappingURL=lazy.mjs.map