Move getScrollWidth to ScrollHelper

This commit is contained in:
Luke "Jared" Bennett 2017-07-19 18:07:34 +01:00
parent b05092ef7e
commit 929c66d620
No known key found for this signature in database
GPG Key ID: 402ED51FB5D306C2
10 changed files with 39 additions and 16 deletions

View File

@ -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;

View File

@ -0,0 +1,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,
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long