index.mjs 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { watch, unref, nextTick } from 'vue';
  2. const useDelayedRender = ({
  3. indicator,
  4. intermediateIndicator,
  5. shouldSetIntermediate = () => true,
  6. beforeShow,
  7. afterShow,
  8. afterHide,
  9. beforeHide
  10. }) => {
  11. watch(() => unref(indicator), (val) => {
  12. if (val) {
  13. beforeShow == null ? void 0 : beforeShow();
  14. nextTick(() => {
  15. if (!unref(indicator))
  16. return;
  17. if (shouldSetIntermediate("show")) {
  18. intermediateIndicator.value = true;
  19. }
  20. });
  21. } else {
  22. beforeHide == null ? void 0 : beforeHide();
  23. nextTick(() => {
  24. if (unref(indicator))
  25. return;
  26. if (shouldSetIntermediate("hide")) {
  27. intermediateIndicator.value = false;
  28. }
  29. });
  30. }
  31. });
  32. watch(() => intermediateIndicator.value, (val) => {
  33. if (val) {
  34. afterShow == null ? void 0 : afterShow();
  35. } else {
  36. afterHide == null ? void 0 : afterHide();
  37. }
  38. });
  39. };
  40. export { useDelayedRender };
  41. //# sourceMappingURL=index.mjs.map