Skip to content

Commit

Permalink
fix: 兼容键盘方向键滚动,并保持固定层同步
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin-front committed Oct 8, 2019
1 parent 5688712 commit 3009b7b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"homepage": "https://github.com/tm-fe/FlexTable#readme",
"dependencies": {
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"normalize-wheel": "^1.0.1",
"vue-checkbox-radio": "^0.6.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
box-shadow: 2px 0 6px -2px rgba(0,0,0,.2);

.@{fb}-body{
margin-right: -13px;
overflow: hidden;
}
}
&-fixed-right-wrap{
Expand Down
6 changes: 6 additions & 0 deletions src/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
:no-data="noData"
:scrollTop="scrollTop"
:hoverIndex="hoverIndex"
@scroll.native.passive="syncScroll"
@on-toggle-select="toggleSelect"
></table-body>
<!-- /flex-table-body -->
Expand Down Expand Up @@ -148,6 +149,7 @@ import tableFoot from './tableFoot.vue';
import tableScrollBar from './tableScrollBar.vue';
import Spinner from './Spinner.vue';
import debounce from "lodash.debounce";
import throttle from "lodash.throttle";
import normalizeWheel from 'normalize-wheel';
import { MIN_WIDTH } from './data';
Expand Down Expand Up @@ -343,6 +345,10 @@ export default {
this.$el.removeEventListener('mousemove', this.onColResizeMove);
},
methods:{
syncScroll: throttle(function(event) {
const { scrollTop } = event.target;
this.scrollTop = scrollTop;
}, 20),
updateHoverIndex: debounce(function(index) {
this.hoverIndex = index;
}, 50),
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4620,6 +4620,11 @@ lodash.tail@^4.1.1:
resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664"
integrity sha1-0jM6NtnncXyK0vfKyv7HwytERmQ=

lodash.throttle@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=

lodash@^4.0.0, lodash@^4.17.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
Expand Down

0 comments on commit 3009b7b

Please sign in to comment.