UNPKG

yandex-metrica-ab-vue

Version:

[Русский](#yandex-metrica-ab-vue-ru) | [English](#yandex-metrica-ab-vue-en)

33 lines (32 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const vue_1 = require("vue"); const DEFAULT_ANTIFLICKER_TIMEOUT = 3000; exports.default = (0, vue_1.defineComponent)({ name: 'VarioqubAntiflicker', props: { ready: { type: Boolean, required: true, }, timeout: { type: Number, default: DEFAULT_ANTIFLICKER_TIMEOUT, }, }, setup(props, { slots }) { const internalReady = (0, vue_1.ref)(false); const thresholdTimeout = setTimeout(() => { internalReady.value = true; }, props.timeout); (0, vue_1.watch)(() => props.ready, (newValue) => { if (newValue) { internalReady.value = newValue; clearTimeout(thresholdTimeout); } }, { immediate: true }); return () => (0, vue_1.h)('div', { style: !internalReady.value ? { opacity: 0 } : {}, }, slots.default ? slots.default() : []); }, });