blob: 4a3a9e161a8b8f706ee8600d6397f7b21a405d04 (
plain)
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
|
function getScrollWidth() {
const $rulerContainer = $('<div>').css({
visibility: 'hidden',
width: 100,
overflow: 'scroll',
});
const $ruler = $('<div>').css({
width: '100%',
});
$ruler.appendTo($rulerContainer);
$rulerContainer.appendTo('body');
const scrollWidth = $ruler.outerWidth();
$rulerContainer.remove();
return 100 - scrollWidth;
}
function setScrollWidth() {
$('body').attr('data-scroll-width', getScrollWidth());
}
export {
getScrollWidth,
setScrollWidth,
};
|