use-placeholder-16d7c5d7.js 1004 B

1234567891011121314151617181920212223242526272829303132
  1. import { O as windowWidth, F as windowHeight, E as useRect } from "./index-487cde8c.js";
  2. import { o as onPopupReopen } from "./on-popup-reopen-c5ca1603.js";
  3. import { r as ref, o as onMounted, z as nextTick, w as watch, c as createVNode } from "./index-5e4623ce.js";
  4. const useHeight = (element, withSafeArea) => {
  5. const height = ref();
  6. const setHeight = () => {
  7. height.value = useRect(element).height;
  8. };
  9. onMounted(() => {
  10. nextTick(setHeight);
  11. if (withSafeArea) {
  12. for (let i = 1; i <= 3; i++) {
  13. setTimeout(setHeight, 100 * i);
  14. }
  15. }
  16. });
  17. onPopupReopen(() => nextTick(setHeight));
  18. watch([windowWidth, windowHeight], setHeight);
  19. return height;
  20. };
  21. function usePlaceholder(contentRef, bem) {
  22. const height = useHeight(contentRef, true);
  23. return (renderContent) => createVNode("div", {
  24. "class": bem("placeholder"),
  25. "style": {
  26. height: height.value ? `${height.value}px` : void 0
  27. }
  28. }, [renderContent()]);
  29. }
  30. export {
  31. usePlaceholder as u
  32. };