UNPKG

1.66 kBJavaScriptView Raw
1var __defProp = Object.defineProperty;
2var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3var __getOwnPropNames = Object.getOwnPropertyNames;
4var __hasOwnProp = Object.prototype.hasOwnProperty;
5var __export = (target, all) => {
6 for (var name in all)
7 __defProp(target, name, { get: all[name], enumerable: true });
8};
9var __copyProps = (to, from, except, desc) => {
10 if (from && typeof from === "object" || typeof from === "function") {
11 for (let key of __getOwnPropNames(from))
12 if (!__hasOwnProp.call(to, key) && key !== except)
13 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14 }
15 return to;
16};
17var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18var stdin_exports = {};
19__export(stdin_exports, {
20 useHeight: () => useHeight
21});
22module.exports = __toCommonJS(stdin_exports);
23var import_use = require("@vant/use");
24var import_vue = require("vue");
25var import_utils = require("../utils");
26var import_on_popup_reopen = require("./on-popup-reopen");
27const useHeight = (element, withSafeArea) => {
28 const height = (0, import_vue.ref)();
29 const setHeight = () => {
30 height.value = (0, import_use.useRect)(element).height;
31 };
32 (0, import_vue.onMounted)(() => {
33 (0, import_vue.nextTick)(setHeight);
34 if (withSafeArea) {
35 for (let i = 1; i <= 3; i++) {
36 setTimeout(setHeight, 100 * i);
37 }
38 }
39 });
40 (0, import_on_popup_reopen.onPopupReopen)(() => (0, import_vue.nextTick)(setHeight));
41 (0, import_vue.watch)([import_utils.windowWidth, import_utils.windowHeight], setHeight);
42 return height;
43};