PageSourceSearch

https://eideford.com/js/plugins/simple-scrollbar.js?v=12.1.255

js eideford.com collected 2026-10-07 15:18:58 UTC 3,005 bytes, 110 lines download raw bytes

1(function(w, d) {
2  var raf = w.requestAnimationFrame || w.setImmediate || function(c) { return setTimeout(c, 0); };
3
4  function initEl(el) {
5    if (el.hasOwnProperty('data-simple-scrollbar')) return;
6    Object.defineProperty(el, 'data-simple-scrollbar', new SimpleScrollbar(el));
7  }
8
9  // Mouse drag handler
10  function dragDealer(el, context) {
11    var lastPageY;
12
13    el.addEventListener('mousedown', function(e) {
14      lastPageY = e.pageY;
15      el.classList.add('ss-grabbed');
16      d.body.classList.add('ss-grabbed');
17
18      d.addEventListener('mousemove', drag);
19      d.addEventListener('mouseup', stop);
20
21      return false;
22    });
23
24    function drag(e) {
25      var delta = e.pageY - lastPageY;
26      lastPageY = e.pageY;
27
28      raf(function() {
29        context.el.scrollTop += delta / context.scrollRatio;
30      });
31    }
32
33    function stop() {
34      el.classList.remove('ss-grabbed');
35      d.body.classList.remove('ss-grabbed');
36      d.removeEventListener('mousemove', drag);
37      d.removeEventListener('mouseup', stop);
38    }
39  }
40
41  // Constructor
42  function ss(el) {
43    this.target = el;
44    
45    this.bar = '<div class="ss-scroll">';
46
47    this.wrapper = d.createElement('div');
48    this.wrapper.setAttribute('class', 'ss-wrapper');
49
50    this.el = d.createElement('div');
51    this.el.setAttribute('class', 'ss-content');
52
53    this.wrapper.appendChild(this.el);
54
55    while (this.target.firstChild) {
56      this.el.appendChild(this.target.firstChild);
57    }
58    this.target.appendChild(this.wrapper);
59
60    this.target.insertAdjacentHTML('beforeend', this.bar);
61    this.bar = this.target.lastChild;
62
63    dragDealer(this.bar, this);
64    this.moveBar();
65
66    this.el.addEventListener('scroll', this.moveBar.bind(this));
67    this.el.addEventListener('mouseenter', this.moveBar.bind(this));
68
69    this.target.classList.add('ss-container'); 
70      
71    var css = window.getComputedStyle(el);
72  	if (css['height'] === '0px' && css['max-height'] !== '0px') {
73    	el.style.height = css['max-height'];
74    }
75  }
76
77  ss.prototype = {
78    moveBar: function(e) {
79      var totalHeight = this.el.scrollHeight,
80          ownHeight = this.el.clientHeight,
81          _this = this;
82
83      this.scrollRatio = ownHeight / totalHeight;
84
85      raf(function() {
86        // Hide scrollbar if no scrolling is possible
87        if(_this.scrollRatio >= 1) {
88          _this.bar.classList.add('ss-hidden')
89        } else {
90          _this.bar.classList.remove('ss-hidden')
91          _this.bar.style.cssText = 'height:' + (_this.scrollRatio) * 100 + '%; top:' + (_this.el.scrollTop / totalHeight ) * 100 + '%;right:-' + (_this.target.clientWidth - _this.bar.clientWidth) + 'px;';
92        }
93      });
94    }
95  }
96
97  function initAll() {
98    var nodes = d.querySelectorAll('*[ss-container]');
99
100    for (var i = 0; i < nodes.length; i++) {
101      initEl(nodes[i]);
102    }
103  }
104
105  d.addEventListener('DOMContentLoaded', initAll);
106  ss.initEl = initEl;
107  ss.initAll = initAll;
108
109  w.SimpleScrollbar = ss;
110})(window, document);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.