Skip to content

Commit 5ae24e4

Browse files
author
黄书伟
committed
fixed bug
1 parent 4a02a22 commit 5ae24e4

File tree

6 files changed

+30
-34
lines changed

6 files changed

+30
-34
lines changed

examples/doc/updateLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
2017-12-4(未发布)
2+
1、修复 table 组件 固定左列偶尔无法触发滚动事件的bug
3+
14
2017-12-1
25
1、修复 table 组件左侧固定列绑定滚动事件失效的问题
36
2、优化 table 组件列滚动事件重复注册的问题
47
3、修复 table 组件 当 vue 路由切换导致列滚动事件失效的问题
58

6-
2017-11-30(未发布)
9+
2017-11-30
710
1、loading 效果位置优化,当有头部时,loading效果下移,否则垂直居中
811
2、loading 透明度允许外部传入,默认0.6(opacity)
912

libs/v-table/src/scroll-control-mixin.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ exports.default = {
4444
scrollControl: function scrollControl() {
4545
var _this = this;
4646

47-
if (this.hasBindScrollEvent) {
48-
return false;
49-
}
50-
51-
this.hasBindScrollEvent = true;
47+
this.unbindEvents();
5248

5349
setTimeout(function (x) {
5450

@@ -60,16 +56,21 @@ exports.default = {
6056
_utils2.default.bind(body2, 'scroll', _this.body2Scroll);
6157
_utils2.default.bind(rightViewFooter, 'scroll', _this.rightViewFooterScroll);
6258
});
59+
},
60+
unbindEvents: function unbindEvents() {
61+
62+
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
63+
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
64+
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
65+
66+
_utils2.default.unbind(body1, 'mousewheel', this.body1Mousewheel);
67+
_utils2.default.unbind(body2, 'scroll', this.body2Scroll);
68+
_utils2.default.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
6369
}
6470
},
6571

6672
beforeDestroy: function beforeDestroy() {
67-
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
68-
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
69-
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
7073

71-
_utils2.default.unbind(body1, 'mousewheel', this.body1Mousewheel);
72-
_utils2.default.unbind(body2, 'scroll', this.body2Scroll);
73-
_utils2.default.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
74+
this.unbindEvents();
7475
}
7576
};

libs/v-table/src/table.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@
362362
// 最大宽度(当width:'max'时)
363363
maxWidth: 5000,
364364
hasFrozenColumn: false,// 是否拥有固定列(false时最后一列的右边border无边框)
365-
hasBindScrollEvent: false, // 是否绑定了滚动事件(防止多次注册)
366365
resizeTimer:null
367366
}
368367
},
@@ -842,11 +841,6 @@
842841
843842
this.tableEmpty();
844843
845-
if (this.isTableEmpty){
846-
847-
this.hasBindScrollEvent = false;
848-
}
849-
850844
if (Array.isArray(newVal) && newVal.length > 0) {
851845
852846
this.initView();

packages/v-table/src/scroll-control-mixin.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ export default {
4242
// 列表中滚动条控制
4343
scrollControl(){
4444

45-
if (this.hasBindScrollEvent){return false;}
46-
47-
this.hasBindScrollEvent = true;
45+
this.unbindEvents();
4846

4947
// 修复左侧固定列绑定滚动事件失效的问题
5048
setTimeout(x => {
@@ -57,16 +55,22 @@ export default {
5755
utils.bind(body2, 'scroll', this.body2Scroll);
5856
utils.bind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
5957
})
58+
},
59+
60+
unbindEvents(){
61+
62+
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
63+
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
64+
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
65+
66+
utils.unbind(body1, 'mousewheel', this.body1Mousewheel);
67+
utils.unbind(body2, 'scroll', this.body2Scroll);
68+
utils.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
6069
}
6170
},
6271

6372
beforeDestroy(){
64-
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
65-
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
66-
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
6773

68-
utils.unbind(body1, 'mousewheel', this.body1Mousewheel);
69-
utils.unbind(body2, 'scroll', this.body2Scroll);
70-
utils.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
74+
this.unbindEvents();
7175
}
7276
}

packages/v-table/src/table.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@
362362
// 最大宽度(当width:'max'时)
363363
maxWidth: 5000,
364364
hasFrozenColumn: false,// 是否拥有固定列(false时最后一列的右边border无边框)
365-
hasBindScrollEvent: false, // 是否绑定了滚动事件(防止多次注册)
366365
resizeTimer:null
367366
}
368367
},
@@ -842,11 +841,6 @@
842841
843842
this.tableEmpty();
844843
845-
if (this.isTableEmpty){
846-
847-
this.hasBindScrollEvent = false;
848-
}
849-
850844
if (Array.isArray(newVal) && newVal.length > 0) {
851845
852846
this.initView();

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)