Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"dependencies": {
"hyperlist": "^1.0.0-beta",
"lodash": "^4.17.5",
"normalize-scroll-left": "^0.1.2",
"sortablejs": "^1.7.0"
},
"config": {
Expand Down
26 changes: 20 additions & 6 deletions src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
linkProperties,
throttle
} from './utils';
import { detectScrollType } from 'normalize-scroll-left';

export default class Style {
constructor(instance) {
Expand Down Expand Up @@ -49,12 +50,25 @@ export default class Style {

requestAnimationFrame(() => {
const scrollLeft = e.target.scrollLeft;
$.style(this.header, {
transform: `translateX(-${scrollLeft}px)`
});
$.style(this.footer, {
transform: `translateX(-${scrollLeft}px)`
});
const direction = getComputedStyle(document.getElementsByTagName('body')[0]).direction;
if (direction === 'rtl' && detectScrollType() === 'default') {
const scrollWidth = e.target.scrollWidth;
const clientWidth = e.target.clientWidth;
$.style(this.header, {
transform: `translateX(${scrollWidth - clientWidth - scrollLeft}px)`
});
$.style(this.footer, {
transform: `translateX(${scrollWidth - clientWidth - scrollLeft}px)`
});
}
else {
$.style(this.header, {
transform: `translateX(${-scrollLeft}px)`
});
$.style(this.footer, {
transform: `translateX(${-scrollLeft}px)`
});
}
this._settingHeaderPosition = false;
});
});
Expand Down