Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Commit 3908089

Browse files
author
Ken Berkeley
committed
[fix #43] @2.1.20
1 parent f5f4f91 commit 3908089

File tree

7 files changed

+31
-23
lines changed

7 files changed

+31
-23
lines changed

dist/min.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.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
<script src="//unpkg.com/jquery@2.1.4/dist/jquery.min.js"></script>
1414
<script src="//unpkg.com/bootstrap@3.3.5/dist/js/bootstrap.min.js"></script>
15-
<script type="text/javascript" src="client.7bfc66a2.js"></script></body>
15+
<script type="text/javascript" src="client.ced4d898.js"></script></body>
1616
</html>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue2-datatable-component",
33
"description": "The best Datatable for Vue.js 2.x which never sucks",
4-
"version": "2.1.19",
4+
"version": "2.1.20",
55
"main": "dist/min.js",
66
"module": "src/main.js",
77
"author": "Ken Berkeley <kenberkeley@foxmail.com>",

src/Table/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div v-if="x !== 'Footer' || x === 'Footer' && summary"
66
ref="wrappers" :name="`Table${x}Wrapper`" :class="`-table-${x.toLowerCase()}`"
77
:style="[
8-
x !== 'Header' && { marginTop: `-${SCROLLBAR_WIDTH}px` },
8+
x !== 'Header' && { marginTop: `-${scrollWidth}px` },
99
x === 'Body' && { maxHeight: `${fixHeaderAndSetBodyMaxHeight}px` }
1010
]">
1111
<div :name="`NormalTable${x}`">
@@ -47,8 +47,8 @@ import TableHeader from './TableHeader.vue'
4747
import TableBody from './TableBody.vue'
4848
import TableFooter from './TableFooter.vue'
4949
import props from '../_mixins/props'
50+
import getScrollWidth from '../_utils/getScrollWidth'
5051
import isColVisible from '../_utils/isColVisible'
51-
import SCROLLBAR_WIDTH from '../_utils/SCROLLBAR_WIDTH'
5252
import syncScroll from '../_utils/syncScroll'
5353
5454
export default {
@@ -57,7 +57,7 @@ export default {
5757
components: { TableFrame, TableHeader, TableBody, TableFooter },
5858
data: () => ({
5959
offsetLeft: 0,
60-
SCROLLBAR_WIDTH
60+
scrollWidth: getScrollWidth()
6161
}),
6262
mounted () {
6363
// this allows you to fix columns or `fixHeaderAndSetBodyMaxHeight` dynamically

src/_utils/SCROLLBAR_WIDTH.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/_utils/getScrollWidth.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Refers to https://davidwalsh.name/detect-scrollbar-width
2+
let scrollWidth
3+
4+
export default function () {
5+
if (scrollWidth) {
6+
return scrollWidth
7+
}
8+
9+
const div = document.createElement('div')
10+
11+
div.style.width = '100px'
12+
div.style.height = '100px'
13+
div.style.overflow = 'scroll'
14+
div.style.position = 'absolute'
15+
div.style.top = '-9999px'
16+
17+
document.body.appendChild(div)
18+
19+
scrollWidth = div.offsetWidth - div.clientWidth
20+
21+
document.body.removeChild(div)
22+
23+
return scrollWidth
24+
}

0 commit comments

Comments
 (0)