scroll-control-mixin.js
4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _utils = require('../../src/utils/utils.js');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
methods: {
body1Mousewheel: function body1Mousewheel(e) {
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
var e1 = e.originalEvent || window.event || e;
var scrollHeight = e1.wheelDelta || e1.detail * -1;
body2.scrollTop = body2.scrollTop - scrollHeight;
},
bodyScrollTop: function bodyScrollTop() {
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
if (body1) {
body1.scrollTop = 0;
}
body2.scrollTop = 0;
},
body2Scroll: function body2Scroll(e) {
var view2 = this.$el.querySelector('.v-table-rightview');
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
if (body1) {
body1.scrollTop = body2.scrollTop;
}
view2.querySelector('.v-table-header').scrollLeft = body2.scrollLeft;
},
rightViewFooterScroll: function rightViewFooterScroll() {
var view2 = this.$el.querySelector('.v-table-rightview');
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
view2.querySelector('.v-table-header').scrollLeft = rightViewFooter.scrollLeft;
view2.querySelector('.v-table-body').scrollLeft = rightViewFooter.scrollLeft;
},
scrollControl: function scrollControl() {
var _this = this;
this.unbindEvents();
setTimeout(function (x) {
var body1 = _this.$el.querySelector('.v-table-leftview .v-table-body');
var body2 = _this.$el.querySelector('.v-table-rightview .v-table-body');
var rightViewFooter = _this.$el.querySelector('.v-table-rightview .v-table-footer');
_utils2.default.bind(body1, 'mousewheel', _this.body1Mousewheel);
_utils2.default.bind(body2, 'scroll', _this.body2Scroll);
_utils2.default.bind(rightViewFooter, 'scroll', _this.rightViewFooterScroll);
});
},
unbindEvents: function unbindEvents() {
var body1 = this.$el.querySelector('.v-table-leftview .v-table-body');
var body2 = this.$el.querySelector('.v-table-rightview .v-table-body');
var rightViewFooter = this.$el.querySelector('.v-table-rightview .v-table-footer');
_utils2.default.unbind(body1, 'mousewheel', this.body1Mousewheel);
_utils2.default.unbind(body2, 'scroll', this.body2Scroll);
_utils2.default.unbind(rightViewFooter, 'scroll', this.rightViewFooterScroll);
},
scrollToTop: function scrollToTop() {
this.bodyScrollTop();
}
},
beforeDestroy: function beforeDestroy() {
this.unbindEvents();
}
};