@liuzengwei/element-ui 2.15.5-xn.21 → 2.15.5-xn.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9739,6 +9739,13 @@ var tablevue_type_template_id_493fe34e_render = function() {
9739
9739
  [_vm._t("default")],
9740
9740
  2
9741
9741
  ),
9742
+ _vm.showHeader && _vm.stickyHeader !== false
9743
+ ? _c("div", {
9744
+ ref: "headerPlaceholder",
9745
+ staticClass: "el-table__header-placeholder",
9746
+ style: { height: "0px", visibility: "hidden" }
9747
+ })
9748
+ : _vm._e(),
9742
9749
  _vm.showHeader
9743
9750
  ? _c(
9744
9751
  "div",
@@ -13761,6 +13768,13 @@ var tablevue_type_script_lang_js_extends = Object.assign || function (target) {
13761
13768
  //
13762
13769
  //
13763
13770
  //
13771
+ //
13772
+ //
13773
+ //
13774
+ //
13775
+ //
13776
+ //
13777
+ //
13764
13778
 
13765
13779
 
13766
13780
 
@@ -14051,6 +14065,101 @@ var tableIdSeed = 1;
14051
14065
  },
14052
14066
  toggleAllSelection: function toggleAllSelection() {
14053
14067
  this.store.commit('toggleAllSelection');
14068
+ },
14069
+
14070
+
14071
+ // 初始化 sticky 滚动处理
14072
+ initStickyScroll: function initStickyScroll() {
14073
+ var _this = this;
14074
+
14075
+ if (this.stickyHeader === false) return;
14076
+
14077
+ this.$nextTick(function () {
14078
+ var headerWrapper = _this.$refs.headerWrapper;
14079
+ var headerPlaceholder = _this.$refs.headerPlaceholder;
14080
+ if (!headerWrapper) return;
14081
+
14082
+ _this.stickyScrollHandler = function () {
14083
+ var tableRect = _this.$el.getBoundingClientRect();
14084
+ var stickyOffset = typeof _this.stickyHeader === 'number' ? _this.stickyHeader : 0;
14085
+
14086
+ // 判断是否应该吸顶
14087
+ var shouldStick = tableRect.top <= stickyOffset;
14088
+ var shouldUnstick = tableRect.bottom <= headerWrapper.offsetHeight + stickyOffset;
14089
+
14090
+ if (shouldStick && !shouldUnstick) {
14091
+ // 需要吸顶
14092
+ if (!headerWrapper.classList.contains('is-fixed')) {
14093
+ // 设置占位符高度,防止页面跳动
14094
+ if (headerPlaceholder) {
14095
+ headerPlaceholder.style.height = headerWrapper.offsetHeight + 'px';
14096
+ headerPlaceholder.style.visibility = 'visible';
14097
+ }
14098
+
14099
+ headerWrapper.classList.add('is-fixed');
14100
+ headerWrapper.style.position = 'fixed';
14101
+ headerWrapper.style.top = stickyOffset + 'px';
14102
+ headerWrapper.style.left = tableRect.left + 'px';
14103
+ headerWrapper.style.width = tableRect.width + 'px';
14104
+ headerWrapper.style.zIndex = '2000';
14105
+ headerWrapper.style.backgroundColor = '#fff';
14106
+ } else {
14107
+ // 更新位置(处理水平滚动)
14108
+ headerWrapper.style.left = tableRect.left + 'px';
14109
+ }
14110
+ } else {
14111
+ // 不需要吸顶,恢复原状
14112
+ if (headerWrapper.classList.contains('is-fixed')) {
14113
+ headerWrapper.classList.remove('is-fixed');
14114
+ headerWrapper.style.position = '';
14115
+ headerWrapper.style.top = '';
14116
+ headerWrapper.style.left = '';
14117
+ headerWrapper.style.width = '';
14118
+ headerWrapper.style.zIndex = '';
14119
+ headerWrapper.style.backgroundColor = '';
14120
+
14121
+ // 隐藏占位符
14122
+ if (headerPlaceholder) {
14123
+ headerPlaceholder.style.height = '0px';
14124
+ headerPlaceholder.style.visibility = 'hidden';
14125
+ }
14126
+ }
14127
+ }
14128
+ };
14129
+
14130
+ // 监听 window 滚动
14131
+ window.addEventListener('scroll', _this.stickyScrollHandler, { passive: true });
14132
+ // 监听 window resize
14133
+ window.addEventListener('resize', _this.stickyScrollHandler, { passive: true });
14134
+ });
14135
+ },
14136
+
14137
+
14138
+ // 销毁 sticky 滚动处理
14139
+ destroyStickyScroll: function destroyStickyScroll() {
14140
+ if (this.stickyScrollHandler) {
14141
+ window.removeEventListener('scroll', this.stickyScrollHandler);
14142
+ window.removeEventListener('resize', this.stickyScrollHandler);
14143
+
14144
+ // 清理样式
14145
+ var headerWrapper = this.$refs.headerWrapper;
14146
+ var headerPlaceholder = this.$refs.headerPlaceholder;
14147
+ if (headerWrapper && headerWrapper.classList.contains('is-fixed')) {
14148
+ headerWrapper.classList.remove('is-fixed');
14149
+ headerWrapper.style.position = '';
14150
+ headerWrapper.style.top = '';
14151
+ headerWrapper.style.left = '';
14152
+ headerWrapper.style.width = '';
14153
+ headerWrapper.style.zIndex = '';
14154
+ headerWrapper.style.backgroundColor = '';
14155
+ }
14156
+ if (headerPlaceholder) {
14157
+ headerPlaceholder.style.height = '0px';
14158
+ headerPlaceholder.style.visibility = 'hidden';
14159
+ }
14160
+
14161
+ this.stickyScrollHandler = null;
14162
+ }
14054
14163
  }
14055
14164
  },
14056
14165
 
@@ -14204,15 +14313,15 @@ var tableIdSeed = 1;
14204
14313
  },
14205
14314
 
14206
14315
  created: function created() {
14207
- var _this = this;
14316
+ var _this2 = this;
14208
14317
 
14209
14318
  this.tableId = 'el-table_' + tableIdSeed++;
14210
14319
  this.debouncedUpdateLayout = Object(external_throttle_debounce_["debounce"])(50, function () {
14211
- return _this.doLayout();
14320
+ return _this2.doLayout();
14212
14321
  });
14213
14322
  },
14214
14323
  mounted: function mounted() {
14215
- var _this2 = this;
14324
+ var _this3 = this;
14216
14325
 
14217
14326
  this.bindEvents();
14218
14327
  this.store.updateColumns();
@@ -14226,7 +14335,7 @@ var tableIdSeed = 1;
14226
14335
  // init filters
14227
14336
  this.store.states.columns.forEach(function (column) {
14228
14337
  if (column.filteredValue && column.filteredValue.length) {
14229
- _this2.store.commit('filterChange', {
14338
+ _this3.store.commit('filterChange', {
14230
14339
  column: column,
14231
14340
  values: column.filteredValue,
14232
14341
  silent: true
@@ -14234,10 +14343,16 @@ var tableIdSeed = 1;
14234
14343
  }
14235
14344
  });
14236
14345
 
14346
+ // 初始化滚动容器检测
14347
+ if (this.stickyHeader !== false) {
14348
+ this.initStickyScroll();
14349
+ }
14350
+
14237
14351
  this.$ready = true;
14238
14352
  },
14239
14353
  destroyed: function destroyed() {
14240
14354
  this.unbindEvents();
14355
+ this.destroyStickyScroll();
14241
14356
  },
14242
14357
  data: function data() {
14243
14358
  var _treeProps = this.treeProps,
@@ -14273,7 +14388,9 @@ var tableIdSeed = 1;
14273
14388
  },
14274
14389
  // 是否拥有多级表头
14275
14390
  isGroup: false,
14276
- scrollPosition: 'left'
14391
+ scrollPosition: 'left',
14392
+ // sticky 滚动处理函数
14393
+ stickyScrollHandler: null
14277
14394
  };
14278
14395
  }
14279
14396
  });
@@ -44332,7 +44449,7 @@ if (typeof window !== 'undefined' && window.Vue) {
44332
44449
  }
44333
44450
 
44334
44451
  /* harmony default export */ var src_0 = __webpack_exports__["default"] = ({
44335
- version: '2.15.5-xn.21',
44452
+ version: '2.15.5-xn.22',
44336
44453
  locale: lib_locale_default.a.use,
44337
44454
  i18n: lib_locale_default.a.i18n,
44338
44455
  install: src_install,