Welcome to mirror list, hosted at ThFree Co, Russian Federation.

scroll_helper.js « helpers « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e921f9e2e0f669a9c1b3aec1e7315b63b84c4df7 (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
30
31
import $ from 'jquery';

const ScrollHelper = {
  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.get(0).offsetWidth;

    $rulerContainer.remove();

    return 100 - scrollWidth;
  },

  setScrollWidth() {
    $('body').attr('data-scroll-width', ScrollHelper.getScrollWidth());
  },
};

export default ScrollHelper;