12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
- };
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
- };
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
- var stdin_exports = {};
- __export(stdin_exports, {
- default: () => stdin_default
- });
- module.exports = __toCommonJS(stdin_exports);
- var import_vue = require("vue");
- var import_use = require("@vant/use");
- var stdin_default = (lazy) => ({
- props: {
- tag: {
- type: String,
- default: "div"
- }
- },
- emits: ["show"],
- render() {
- return (0, import_vue.h)(
- this.tag,
- this.show && this.$slots.default ? this.$slots.default() : null
- );
- },
- data() {
- return {
- el: null,
- state: {
- loaded: false
- },
- show: false
- };
- },
- mounted() {
- this.el = this.$el;
- lazy.addLazyBox(this);
- lazy.lazyLoadHandler();
- },
- beforeUnmount() {
- lazy.removeComponent(this);
- },
- methods: {
- checkInView() {
- const rect = (0, import_use.useRect)(this.$el);
- return import_use.inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
- },
- load() {
- this.show = true;
- this.state.loaded = true;
- this.$emit("show", this);
- },
- destroy() {
- return this.$destroy;
- }
- }
- });
|