PageSourceSearch

https://artscastle.com.hk/wp-content/themes/joyas-shop/vendors/scrollbar/simple-scrollbar.js?ver=7.1.2

js artscastle.com.hk collected 2026-10-02 01:55:14 UTC 4,713 bytes, 165 lines download raw bytes

vendor: 4,713 bytes, lines 1-165
1;(function(root, factory) {
2  if (typeof exports === 'object') {
3    module.exports = factory(window, document)
4  } else {
5    root.SimpleScrollbar = factory(window, document)
6  }
7})(this, function(w, d) {
8  var raf = w.requestAnimationFrame || w.setImmediate || function(c) { return setTimeout(c, 0); };
9
10  function initEl(el) {
11    Object.defineProperty(el, 'data-simple-scrollbar', { value: new SimpleScrollbar(el), configurable: true });
12  }
13
14  function unbindEl(el) {
15    if (!Object.prototype.hasOwnProperty.call(el, 'data-simple-scrollbar')) return;
16    el['data-simple-scrollbar'].unBind();
17    //Remove the elements property
18    delete el['data-simple-scrollbar'];
19  }
20
21  // Mouse drag handler
22  function dragDealer(el, context) {
23    var lastPageY;
24
25    el.addEventListener('mousedown', function(e) {
26      lastPageY = e.pageY;
27      el.classList.add('ss-grabbed');
28      d.body.classList.add('ss-grabbed');
29
30      d.addEventListener('mousemove', drag);
31      d.addEventListener('mouseup', stop);
32
33      return false;
34    });
35
36    function drag(e) {
37      var delta = e.pageY - lastPageY;
38      lastPageY = e.pageY;
39
40      raf(function() {
41        context.el.scrollTop += delta / context.scrollRatio;
42      });
43    }
44
45    function stop() {
46      el.classList.remove('ss-grabbed');
47      d.body.classList.remove('ss-grabbed');
48      d.removeEventListener('mousemove', drag);
49      d.removeEventListener('mouseup', stop);
50    }
51  }
52
53  // Constructor
54  function ss(el) {
55    this.target = el;
56    this.content = el.firstElementChild;
57
58    this.direction = w.getComputedStyle(this.target).direction;
59
60    this.bar = '<div class="ss-scroll">';
61    //Create a reference to the function binding to remove the event listeners
62    this.mB = this.moveBar.bind(this);
63
64    this.wrapper = d.createElement('div');
65    this.wrapper.setAttribute('class', 'ss-wrapper');
66
67    this.el = d.createElement('div');
68    this.el.setAttribute('class', 'ss-content');
69
70    if (this.direction === 'rtl') {
71      this.el.classList.add('rtl');
72    }
73
74    this.wrapper.appendChild(this.el);
75
76    while (this.target.firstChild) {
77      this.el.appendChild(this.target.firstChild);
78    }
79    this.target.appendChild(this.wrapper);
80
81    this.target.insertAdjacentHTML('beforeend', this.bar);
82    this.bar = this.target.lastChild;
83
84    dragDealer(this.bar, this);
85    this.moveBar();
86
87    w.addEventListener('resize', this.mB);
88    this.el.addEventListener('scroll', this.mB);
89    this.el.addEventListener('mouseenter', this.mB);
90
91    this.target.classList.add('ss-container');
92
93    var css = w.getComputedStyle(el);
94  	if (css['height'] === '0px' && css['max-height'] !== '0px') {
95    	el.style.height = css['max-height'];
96    }
97
98    this.unBind = function() {
99      //Remove event listeners
100      w.removeEventListener('resize', this.mB);
101      this.el.removeEventListener('scroll', this.mB);
102      this.el.removeEventListener('mouseenter', this.mB);
103      
104      this.target.classList.remove('ss-container');
105
106      //Unwrap the initial content and remove remaining wrappers
107      this.target.insertBefore(this.content, this.wrapper);
108      this.target.removeChild(this.wrapper);
109
110      //Remove the bar including its drag-dealer event listener
111      this.target.removeChild(this.bar);
112      this.bar = null; //make way for the garbage collector
113    }
114  }
115
116  ss.prototype = {
117    moveBar: function(e) {
118      var totalHeight = this.el.scrollHeight,
119          ownHeight = this.el.clientHeight,
120          _this = this;
121
122      this.scrollRatio = ownHeight / totalHeight;
123
124      var isRtl = _this.direction === 'rtl';
125      var right = isRtl ?
126        (_this.target.clientWidth - _this.bar.clientWidth + 18) :
127        (_this.target.clientWidth - _this.bar.clientWidth) * -1;
128
129      raf(function() {
130        // Hide scrollbar if no scrolling is possible
131        if(_this.scrollRatio >= 1) {
132          _this.bar.classList.add('ss-hidden')
133        } else {
134          _this.bar.classList.remove('ss-hidden')
135          _this.bar.style.cssText = 'height:' + Math.max(_this.scrollRatio * 100, 10) + '%; top:' + (_this.el.scrollTop / totalHeight ) * 100 + '%;right:' + right + 'px;';
136        }
137      });
138    }
139  }
140
141  function initAll() {
142    var nodes = d.querySelectorAll('*[ss-container]');
143
144    for (var i = 0; i < nodes.length; i++) {
145      initEl(nodes[i]);
146    }
147  }
148
149  function unbindAll() {
150    var nodes = d.querySelectorAll('.ss-container');
151
152    for (var i = 0; i < nodes.length; i++) {
153      unbindEl(nodes[i]);
154    }
155  }
156
157  d.addEventListener('DOMContentLoaded', initAll);
158  ss.initEl = initEl;
159  ss.initAll = initAll;
160  ss.unbindEl = unbindEl;
161  ss.unbindAll = unbindAll;
162
163  var SimpleScrollbar = ss;
164  return SimpleScrollbar;
165});

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.