forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollbar.js
More file actions
44 lines (34 loc) · 699 Bytes
/
scrollbar.js
File metadata and controls
44 lines (34 loc) · 699 Bytes
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
import { css } from './dom'
let size
export function width () {
if (size) {
return size
}
const
inner = document.createElement('p'),
outer = document.createElement('div')
css(inner, {
width: '100%',
height: '200px'
})
css(outer, {
position: 'absolute',
top: '0px',
left: '0px',
visibility: 'hidden',
width: '200px',
height: '150px',
overflow: 'hidden'
})
outer.appendChild(inner)
document.body.appendChild(outer)
let w1 = inner.offsetWidth
outer.style.overflow = 'scroll'
let w2 = inner.offsetWidth
if (w1 === w2) {
w2 = outer.clientWidth
}
document.body.removeChild(outer)
size = w1 - w2
return size
}