Skip to content

Commit 4faa628

Browse files
author
黄书伟
committed
fixed bug
1 parent 9164eed commit 4faa628

File tree

4 files changed

+42
-49
lines changed

4 files changed

+42
-49
lines changed

examples/doc/updateLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2017-12-4(未发布)
22
1、修复 table 组件 固定左列偶尔无法触发滚动事件的bug
3+
2、优化 table 组件 当有纵向自适应时并设置了最小高度时,表格内容高度小于‘最小高度’则以表格内容高度为准
34

45
2017-12-1
56
1、修复 table 组件左侧固定列绑定滚动事件失效的问题

libs/v-table/src/table-resize-mixin.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,37 +103,34 @@ exports.default = {
103103
return false;
104104
}
105105

106-
var self = this,
107-
maxWidth = self.maxWidth,
108-
maxHeight = self.height && self.height > 0 ? self.height : this.getTotalColumnsHeight(),
109-
minWidth = self.minWidth,
110-
minHeight = self.minHeight,
106+
var totalColumnsHeight = this.getTotalColumnsHeight(),
107+
maxWidth = this.maxWidth,
108+
maxHeight = this.height && this.height > 0 ? this.height : totalColumnsHeight,
109+
minWidth = this.minWidth,
110+
minHeight = this.minHeight > totalColumnsHeight ? totalColumnsHeight : this.minHeight,
111111
view = this.$el,
112112
viewOffset = _utils2.default.getViewportOffset(view),
113113
currentWidth = view.getBoundingClientRect !== 'undefined' ? view.getBoundingClientRect().width : view.clientWidth,
114114
currentHeight = view.getBoundingClientRect !== 'undefined' ? view.getBoundingClientRect().height : view.clientHeight,
115-
right = window.document.documentElement.clientWidth - currentWidth - viewOffset.left,
116115
bottom = window.document.documentElement.clientHeight - currentHeight - viewOffset.top - 2;
117116

118-
if (self.isVerticalResize && currentHeight > 0) {
119-
bottom -= self.verticalResizeOffset;
120-
if (currentHeight > minHeight || currentHeight < maxHeight) {
121-
var currentHeight = currentHeight + bottom;
122-
currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight;
123-
currentHeight = currentHeight < minHeight ? minHeight : currentHeight;
124-
self.internalHeight = currentHeight;
125-
}
117+
if (this.isVerticalResize && currentHeight > 0) {
118+
119+
bottom -= this.verticalResizeOffset;
120+
121+
currentHeight = currentHeight + bottom;
122+
currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight;
123+
currentHeight = currentHeight < minHeight ? minHeight : currentHeight;
124+
this.internalHeight = currentHeight;
126125
}
127126

128-
if (self.isHorizontalResize && self.internalWidth && self.internalWidth > 0 && currentWidth > 0) {
129-
if (right <= 0 && currentWidth > minWidth || right >= 0 && currentWidth < maxWidth) {
127+
if (this.isHorizontalResize && this.internalWidth && this.internalWidth > 0 && currentWidth > 0) {
130128

131-
currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth;
132-
currentWidth = currentWidth < minWidth ? minWidth : currentWidth;
129+
currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth;
130+
currentWidth = currentWidth < minWidth ? minWidth : currentWidth;
133131

134-
self.internalWidth = currentWidth;
135-
self.changeColumnsWidth(currentWidth);
136-
}
132+
this.internalWidth = currentWidth;
133+
this.changeColumnsWidth(currentWidth);
137134
}
138135
},
139136
changeColumnsWidth: function changeColumnsWidth(currentWidth) {

packages/v-table/src/table-resize-mixin.js

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default {
1010
resizeColumns: [], // 所有需要自适应的列集合
1111
initTotalColumnsWidth: 0, // 所有列初始化时的总宽度
1212
hasContainerWidth: false, // 容器是否有宽度(display:none 时没有)
13-
containerWidthCheckTimer:null
13+
containerWidthCheckTimer: null
1414
}
1515
},
1616

@@ -41,12 +41,12 @@ export default {
4141
// 如果初始化时document上包含滚动条,渲染完document滚动条消失会造成表格宽度计算有误的问题
4242
containerWidthCheck(){
4343

44-
this.containerWidthCheckTimer = setTimeout(x=>{
44+
this.containerWidthCheckTimer = setTimeout(x => {
4545

4646
let tableContainerWidth = this.$el.clientWidth;
4747

4848
// 3为容错值
49-
if (tableContainerWidth - this.internalWidth > 3){
49+
if (tableContainerWidth - this.internalWidth > 3) {
5050

5151
this.tableResize();
5252
}
@@ -110,41 +110,36 @@ export default {
110110
return false;
111111
}
112112

113-
var self = this,
114-
maxWidth = self.maxWidth,
115-
maxHeight = (self.height && self.height > 0) ? self.height : this.getTotalColumnsHeight(),
116-
minWidth = self.minWidth,
117-
minHeight = self.minHeight,
113+
var totalColumnsHeight = this.getTotalColumnsHeight(),
114+
maxWidth = this.maxWidth,
115+
maxHeight = (this.height && this.height > 0) ? this.height : totalColumnsHeight,
116+
minWidth = this.minWidth,
117+
minHeight = this.minHeight > totalColumnsHeight ? totalColumnsHeight : this.minHeight,
118118
view = this.$el,
119119
viewOffset = utils.getViewportOffset(view),
120120
currentWidth = view.getBoundingClientRect !== 'undefined' ? view.getBoundingClientRect().width : view.clientWidth,
121121
currentHeight = view.getBoundingClientRect !== 'undefined' ? view.getBoundingClientRect().height : view.clientHeight,
122-
right = window.document.documentElement.clientWidth - currentWidth - viewOffset.left,
122+
//right = window.document.documentElement.clientWidth - currentWidth - viewOffset.left,
123123
bottom = window.document.documentElement.clientHeight - currentHeight - viewOffset.top - 2; //
124124

125125

126-
if (self.isVerticalResize && currentHeight > 0) {
127-
// (窗口高度缩小 && 当前高度大于最小高度) || (窗口高度扩大 && 当前高度小于最大高度)
128-
bottom -= self.verticalResizeOffset;
129-
if ((currentHeight > minHeight) || (currentHeight < maxHeight)) {
130-
var currentHeight = currentHeight + bottom;// - self.VerticalResizeOffset;
131-
currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight;
132-
currentHeight = currentHeight < minHeight ? minHeight : currentHeight;
133-
self.internalHeight = currentHeight;
134-
}
135-
}
126+
if (this.isVerticalResize && currentHeight > 0) {
136127

137-
if (self.isHorizontalResize && self.internalWidth && self.internalWidth > 0 && currentWidth > 0) {
128+
bottom -= this.verticalResizeOffset;
138129

139-
// (窗口宽度缩小 && 当前宽度大于最小宽度) ||(窗口宽度扩大 && 当前宽度小于最大宽度)
140-
if ((right <= 0 && currentWidth > minWidth) || (right >= 0 && currentWidth < maxWidth)) {
130+
currentHeight = currentHeight + bottom;// - this.VerticalResizeOffset;
131+
currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight;
132+
currentHeight = currentHeight < minHeight ? minHeight : currentHeight;
133+
this.internalHeight = currentHeight;
134+
}
141135

142-
currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth;
143-
currentWidth = currentWidth < minWidth ? minWidth : currentWidth;
136+
if (this.isHorizontalResize && this.internalWidth && this.internalWidth > 0 && currentWidth > 0) {
144137

145-
self.internalWidth = currentWidth;
146-
self.changeColumnsWidth(currentWidth);
147-
}
138+
currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth;
139+
currentWidth = currentWidth < minWidth ? minWidth : currentWidth;
140+
141+
this.internalWidth = currentWidth;
142+
this.changeColumnsWidth(currentWidth);
148143
}
149144
},
150145

umd/js/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)