Commit 929c66d6 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Move getScrollWidth to ScrollHelper

parent b05092ef
......@@ -54,6 +54,7 @@ import RefSelectDropdown from './ref_select_dropdown';
import GfmAutoComplete from './gfm_auto_complete';
import ShortcutsBlob from './shortcuts_blob';
import initSettingsPanels from './settings_panels';
import { setScrollWidth } from './helpers/scroll_helper';
(function() {
var Dispatcher;
......@@ -76,14 +77,7 @@ import initSettingsPanels from './settings_panels';
return false;
}
function getScrollBarWidth () {
var $outer = $('<div>').css({ visibility: 'hidden', width: 100, overflow: 'scroll' }).appendTo('body'),
widthWithScroll = $('<div>').css({ width: '100%' }).appendTo($outer).outerWidth();
$outer.remove();
return 100 - widthWithScroll;
}
$('body').attr('data-scroll-width', getScrollBarWidth());
setScrollWidth();
path = page.split(':');
shortcut_handler = null;
......
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,
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment