/* eslint-disable @typescript-eslint/no-this-alias,no-undef */

/* eslint-disable no-var */
var idCount = 0; // eslint-disable-next-line no-undef

Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持

  },
  properties: {
    className: String,
    perf: Boolean,
    height: Number
  },
  data: {
    id: '',
    isShow: false
  },
  lifetimes: {
    ready: function ready() {
      var _this = this;

      wx.nextTick(function () {
        _this.setData({
          id: "visible".concat(idCount++),
          height: _this.properties.height || 1
        });

        var offsetY = _this.properties.perf ? // eslint-disable-next-line no-undef
        wx.getSystemInfoSync().windowHeight * 2 : 0;
        var that = _this;
        wx.createIntersectionObserver(_this).relativeToViewport({
          top: offsetY,
          bottom: offsetY
        }).observe("#".concat(_this.data.id), function (_ref) {
          var height = _ref.intersectionRect.height;
          var isShow = height > 0;
          that.setData({
            isShow: isShow
          });

          if (isShow) {
            that.triggerEvent('visible');
          } else {
            that.triggerEvent('hidden');
          }
        });
      });
    }
  }
});