Move getScrollWidth to ScrollHelper
This commit is contained in:
parent
b05092ef7e
commit
929c66d620
10 changed files with 39 additions and 16 deletions
|
@ -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;
|
||||
|
|
29
app/assets/javascripts/helpers/scroll_helper.js
Normal file
29
app/assets/javascripts/helpers/scroll_helper.js
Normal 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
Loading…
Reference in a new issue