PageSourceSearch

https://www.cactus.sk/core/resources/lib/perfect-scrollbar/perfect-scrollbar.jquery.js

js cactus.sk collected 2026-10-08 03:23:38 UTC 43,911 bytes, 1,463 lines download raw bytes

1/* perfect-scrollbar v0.6.4 */
2(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
3/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
4 * Licensed under the MIT License
5 */
6'use strict';
7
8var ps = require('../main')
9  , psInstances = require('../plugin/instances');
10
11function mountJQuery(jQuery) {
12  jQuery.fn.perfectScrollbar = function (settingOrCommand) {
13    return this.each(function () {
14      if (typeof settingOrCommand === 'object' ||
15          typeof settingOrCommand === 'undefined') {
16        // If it's an object or none, initialize.
17        var settings = settingOrCommand;
18
19        if (!psInstances.get(this)) {
20          ps.initialize(this, settings);
21        }
22      } else {
23        // Unless, it may be a command.
24        var command = settingOrCommand;
25
26        if (command === 'update') {
27          ps.update(this);
28        } else if (command === 'destroy') {
29          ps.destroy(this);
30        }
31      }
32
33      return jQuery(this);
34    });
35  };
36}
37
38if (typeof define === 'function' && define.amd) {
39  // AMD. Register as an anonymous module.
40  define(['jquery'], mountJQuery);
41} else {
42  var jq = window.jQuery ? window.jQuery : window.$;
43  if (typeof jq !== 'undefined') {
44    mountJQuery(jq);
45  }
46}
47
48module.exports = mountJQuery;
49
50},{"../main":7,"../plugin/instances":18}],2:[function(require,module,exports){
51/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
52 * Licensed under the MIT License
53 */
54'use strict';
55
56function oldAdd(element, className) {
57  var classes = element.className.split(' ');
58  if (classes.indexOf(className) < 0) {
59    classes.push(className);
60  }
61  element.className = classes.join(' ');
62}
63
64function oldRemove(element, className) {
65  var classes = element.className.split(' ');
66  var idx = classes.indexOf(className);
67  if (idx >= 0) {
68    classes.splice(idx, 1);
69  }
70  element.className = classes.join(' ');
71}
72
73exports.add = function (element, className) {
74  if (element.classList) {
75    element.classList.add(className);
76  } else {
77    oldAdd(element, className);
78  }
79};
80
81exports.remove = function (element, className) {
82  if (element.classList) {
83    element.classList.remove(className);
84  } else {
85    oldRemove(element, className);
86  }
87};
88
89exports.list = function (element) {
90  if (element.classList) {
91    return element.classList;
92  } else {
93    return element.className.split(' ');
94  }
95};
96
97},{}],3:[function(require,module,exports){
98/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
99 * Licensed under the MIT License
100 */
101'use strict';
102
103exports.e = function (tagName, className) {
104  var element = document.createElement(tagName);
105  element.className = className;
106  return element;
107};
108
109exports.appendTo = function (child, parent) {
110  parent.appendChild(child);
111  return child;
112};
113
114function cssGet(element, styleName) {
115  return window.getComputedStyle(element)[styleName];
116}
117
118function cssSet(element, styleName, styleValue) {
119  if (typeof styleValue === 'number') {
120    styleValue = styleValue.toString() + 'px';
121  }
122  element.style[styleName] = styleValue;
123  return element;
124}
125
126function cssMultiSet(element, obj) {
127  for (var key in obj) {
128    var val = obj[key];
129    if (typeof val === 'number') {
130      val = val.toString() + 'px';
131    }
132    element.style[key] = val;
133  }
134  return element;
135}
136
137exports.css = function (element, styleNameOrObject, styleValue) {
138  if (typeof styleNameOrObject === 'object') {
139    // multiple set with object
140    return cssMultiSet(element, styleNameOrObject);
141  } else {
142    if (typeof styleValue === 'undefined') {
143      return cssGet(element, styleNameOrObject);
144    } else {
145      return cssSet(element, styleNameOrObject, styleValue);
146    }
147  }
148};
149
150exports.matches = function (element, query) {
151  if (typeof element.matches !== 'undefined') {
152    return element.matches(query);
153  } else {
154    if (typeof element.matchesSelector !== 'undefined') {
155      return element.matchesSelector(query);
156    } else if (typeof element.webkitMatchesSelector !== 'undefined') {
157      return element.webkitMatchesSelector(query);
158    } else if (typeof element.mozMatchesSelector !== 'undefined') {
159      return element.mozMatchesSelector(query);
160    }
160 else if (typeof element.msMatchesSelector !== 'undefined') {
161      return element.msMatchesSelector(query);
162    }
163  }
164};
165
166exports.remove = function (element) {
167  if (typeof element.remove !== 'undefined') {
168    element.remove();
169  } else {
170    if (element.parentNode) {
171      element.parentNode.removeChild(element);
172    }
173  }
174};
175
176},{}],4:[function(require,module,exports){
177/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
178 * Licensed under the MIT License
179 */
180'use strict';
181
182var EventElement = function (element) {
183  this.element = element;
184  this.events = {};
185};
186
187EventElement.prototype.bind = function (eventName, handler) {
188  if (typeof this.events[eventName] === 'undefined') {
189    this.events[eventName] = [];
190  }
191  this.events[eventName].push(handler);
192  this.element.addEventListener(eventName, handler, false);
193};
194
195EventElement.prototype.unbind = function (eventName, handler) {
196  var isHandlerProvided = (typeof handler !== 'undefined');
197  this.events[eventName] = this.events[eventName].filter(function (hdlr) {
198    if (isHandlerProvided && hdlr !== handler) {
199      return true;
200    }
201    this.element.removeEventListener(eventName, hdlr, false);
202    return false;
203  }, this);
204};
205
206EventElement.prototype.unbindAll = function () {
207  for (var name in this.events) {
208    this.unbind(name);
209  }
210};
211
212var EventManager = function () {
213  this.eventElements = [];
214};
215
216EventManager.prototype.eventElement = function (element) {
217  var ee = this.eventElements.filter(function (eventElement) {
218    return eventElement.element === element;
219  })[0];
220  if (typeof ee === 'undefined') {
221    ee = new EventElement(element);
222    this.eventElements.push(ee);
223  }
224  return ee;
225};
226
227EventManager.prototype.bind = function (element, eventName, handler) {
228  this.eventElement(element).bind(eventName, handler);
229};
230
231EventManager.prototype.unbind = function (element, eventName, handler) {
232  this.eventElement(element).unbind(eventName, handler);
233};
234
235EventManager.prototype.unbindAll = function () {
236  for (var i = 0; i < this.eventElements.length; i++) {
237    this.eventElements[i].unbindAll();
238  }
239};
240
241EventManager.prototype.once = function (element, eventName, handler) {
242  var ee = this.eventElement(element);
243  var onceHandler = function (e) {
244    ee.unbind(eventName, onceHandler);
245    handler(e);
246  };
247  ee.bind(eventName, onceHandler);
248};
249
250module.exports = EventManager;
251
252},{}],5:[function(require,module,exports){
253/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
254 * Licensed under the MIT License
255 */
256'use strict';
257
258module.exports = (function () {
259  function s4() {
260    return Math.floor((1 + Math.random()) * 0x10000)
261               .toString(16)
262               .substring(1);
263  }
264  return function () {
265    return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
266           s4() + '-' + s4() + s4() + s4();
267  };
268})();
269
270},{}],6:[function(require,module,exports){
271/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
272 * Licensed under the MIT License
273 */
274'use strict';
275
276var cls = require('./class')
277  , d = require('./dom');
278
279exports.toInt = function (x) {
280  return parseInt(x, 10) || 0;
281};
282
283exports.clone = function (obj) {
284  if (obj === null) {
285    return null;
286  } else if (typeof obj === 'object') {
287    var result = {};
288    for (var key in obj) {
289      result[key] = this.clone(obj[key]);
290    }
291    return result;
292  } else {
293    return obj;
294  }
295};
296
297exports.extend = function (original, source) {
298  var result = this.clone(original);
299  for (var key in source) {
300    result[key] = this.clone(source[key]);
301  }
302  return result;
303};
304
305exports.isEditable = function (el) {
306  return d.matches(el, "input,[contenteditable]") ||
307         d.matches(el, "select,[contenteditable]") ||
308         d.matches(el, "textarea,[contenteditable]") ||
309         d.matches(el, "button,[contenteditable]");
310};
311
312exports.removePsClasses = function (element) {
313  var clsList = cls.list(element);
314  for (var i = 0; i < clsList.length; i++) {
315    var className = clsList[i];
316    if (className.indexOf('ps-') === 0) {
317      cls.remove(element, className);
318    }
319  }
320};
321
322exports.outerWidth = function (element) {
323  return this.toInt(d.css(element, 'width')) +
324         this.toInt(d.css(element, 'paddingLeft')) +
325         this.toInt(d.css(element, 'paddingRight')) +
326         this.toInt(d.css(element, 'borderLeftWidth')) +
327         this.toInt(d.css(element, 'borderRightWidth'));
328};
329
330exports.startScrolling = function (element, axis) {
331  cls.add(element, 'ps-in-scrolling');
332  if (typeof axis !== 'undefined') {
333    cls.add(element, 'ps-' + axis);
334  } else {
335    cls.add(element, 'ps-x');
336    cls.add(element, 'ps-y');
337  }
338};
339
340exports.stopScrolling = function (element, axis) {
341  cls.remove(element, 'ps-in-scrolling');
342  if (typeof axis !== 'undefined') {
343    cls.remove(element, 'ps-' + axis);
344  } else {
345    cls.remove(element, 'ps-x');
346    cls.remove(element, 'ps-y');
347  }
348};
349
350exports.env = {
351  isWebKit: 'WebkitAppearance' in document.documentElement.style,
352  supportsTouch: (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch),
353  supportsIePointer: window.navigator.msMaxTouchPoints !== null
354};
355
356},{"./class":2,"./dom":3}],7:[function(require,module,exports){
357/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
358 * Licensed under the MIT License
359 */
360'use strict';
361
362var destroy = require('./plugin/destroy')
363  , initialize = require('./plugin/initialize')
364  , update = require('./plugin/update');
365
366module.exports = {
367  initialize: initialize,
368  update: update,
369  destroy: destroy
370};
371
372},{"./plugin/destroy":9,"./plugin/initialize":17,"./plugin/update":20}],8:[function(require,module,exports){
373/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
374 * Licensed under the MIT License
375 */
376'use strict';
377
378module.exports = {
379  wheelSpeed: 1,
380  wheelPropagation: false,
381  swipePropagation: true,
382  minScrollbarLength: null,
383  maxScrollbarLength: null,
384  useBothWheelAxes: false,
385  useKeyboard: true,
386  suppressScrollX: false,
387  suppressScrollY: false,
388  scrollXMarginOffset: 0,
389  scrollYMarginOffset: 0,
390  stopPropagationOnClick: true
391};
392
393},{}],9:[function(require,module,exports){
394/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
395 * Licensed under the MIT License
396 */
397'use strict';
398
399var d = require('../lib/dom')
400  , h = require('../lib/helper')
401  , instances = require('./instances');
402
403module.exports = function (element) {
404  var i = instances.get(element);
405
406  if (!i) {
407    return;
408  }
409
410  i.event.unbindAll();
411  d.remove(i.scrollbarX);
412  d.remove(i.scrollbarY);
413  d.remove(i.scrollbarXRail);
414  d.remove(i.scrollbarYRail);
415  h.removePsClasses(element);
416
417  instances.remove(element);
418};
419
420},{"../lib/dom":3,"../lib/helper":6,"./instances":18}],10:[function(require,module,exports){
421/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
422 * Licensed under the MIT License
423 */
424'use strict';
425
426var h = require('../../lib/helper')
427  , instances = require('../instances')
428  , updateGeometry = require('../update-geometry');
429
430function bindClickRailHandler(element, i) {
431  function pageOffset(el) {
432    return el.getBoundingClientRect();
433  }
434  var stopPropagation = window.Event.prototype.stopPropagation.bind;
435
436  if (i.settings.stopPropagationOnClick) {
437    i.event.bind(i.scrollbarY, 'click', stopPropagation);
438  }
439  i.event.bind(i.scrollbarYRail, 'click', function (e) {
440    var halfOfScrollbarLength = h.toInt(i.scrollbarYHeight / 2);
441    var positionTop = i.railYRatio * (e.pageY - window.scrollY - pageOffset(i.scrollbarYRail).top - halfOfScrollbarLength);
442    var maxPositionTop = i.railYRatio * (i.railYHeight - i.scrollbarYHeight);
443    var positionRatio = positionTop / maxPositionTop;
444
445    if (positionRatio < 0) {
446      positionRatio = 0;
447    } else if (positionRatio > 1) {
448      positionRatio = 1;
449    }
450
451    element.scrollTop = (i.contentHeight - i.containerHeight) * positionRatio;
452    updateGeometry(element);
453
454    e.stopPropagation();
455  });
456
457  if (i.settings.stopPropagationOnClick) {
458    i.event.bind(i.scrollbarX, 'click', stopPropagation);
459  }
460  i.event.bind(i.scrollbarXRail, 'click', function (e) {
461    var halfOfScrollbarLength = h.toInt(i.scrollbarXWidth / 2);
462    var positionLeft = i.railXRatio * (e.pageX - window.scrollX - pageOffset(i.scrollbarXRail).left - halfOfScrollbarLength);
463    var maxPositionLeft = i.railXRatio * (i.railXWidth - i.scrollbarXWidth);
464    var positionRatio = positionLeft / maxPositionLeft;
465
466    if (positionRatio < 0) {
467      positionRatio = 0;
468    } else if (positionRatio > 1) {
469      positionRatio = 1;
470    }
471
472    element.scrollLeft = ((i.contentWidth - i.containerWidth) * positionRatio) - i.negativeScrollAdjustment;
473    updateGeometry(element);
474
475    e.stopPropagation();
476  });
477}
478
479module.exports = function (element) {
480  var i = instances.get(element);
481  bindClickRailHandler(element, i);
482};
483
484},{"../../lib/helper":6,"../instances":18,"../update-geometry":19}],11:[function(require,module,exports){
485/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
486 * Licensed under the MIT License
487 */
488'use strict';
489
490var d = require('../../lib/dom')
491  , h = require('../../lib/helper')
492  , instances = require('../instances')
493  , updateGeometry = require('../update-geometry');
494
495function bindMouseScrollXHandler(element, i) {
496  var currentLeft = null;
497  var currentPageX = null;
498
499  function updateScrollLeft(deltaX) {
500    var newLeft = currentLeft + (deltaX * i.railXRatio);
501    var maxLeft = i.scrollbarXRail.getBoundingClientRect().left + (i.railXRatio * (i.railXWidth - i.scrollbarXWidth));
502
503    if (newLeft < 0) {
504      i.scrollbarXLeft = 0;
505    } else if (newLeft > maxLeft) {
506      i.scrollbarXLeft = maxLeft;
507    } else {
508      i.scrollbarXLeft = newLeft;
509    }
510
511    var scrollLeft = h.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment;
512    element.scrollLeft = scrollLeft;
513  }
514
515  var mouseMoveHandler = function (e) {
516    updateScrollLeft(e.pageX - currentPageX);
517    updateGeometry(element);
518    e.stopPropagation();
519    e.preventDefault();
520  };
521
522  var mouseUpHandler = function () {
523    h.stopScrolling(element, 'x');
524    i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
525  };
526
527  i.event.bind(i.scrollbarX, 'mousedown', function (e) {
528    currentPageX = e.pageX;
529    currentLeft = h.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio;
530    h.startScrolling(element, 'x');
531
532    i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
533    i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
534
535    e.stopPropagation();
536    e.preventDefault();
537  });
538}
539
540function bindMouseScrollYHandler(element, i) {
541  var currentTop = null;
542  var currentPageY = null;
543
544  function updateScrollTop(deltaY) {
545    var newTop = currentTop + (deltaY * i.railYRatio);
546    var maxTop = i.scrollbarYRail.getBoundingClientRect().top + (i.railYRatio * (i.railYHeight - i.scrollbarYHeight));
547
548    if (newTop < 0) {
549      i.scrollbarYTop = 0;
550    } else if (newTop > maxTop) {
551      i.scrollbarYTop = maxTop;
552    } else {
553      i.scrollbarYTop = newTop;
554    }
555
556    var scrollTop = h.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight)));
557    element.scrollTop = scrollTop;
558  }
559
560  var mouseMoveHandler = function (e) {
561    updateScrollTop(e.pageY - currentPageY);
562    updateGeometry(element);
563    e.stopPropagation();
564    e.preventDefault();
565  };
566
567  var mouseUpHandler = function () {
568    h.stopScrolling(element, 'y');
569    i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
570  };
571
572  i.event.bind(i.scrollbarY, 'mousedown', function (e) {
573    currentPageY = e.pageY;
574    currentTop = h.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio;
575    h.startScrolling(element, 'y');
576
577    i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
578    i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
579
580    e.stopPropagation();
581    e.preventDefault();
582  });
583}
584
585module.exports = function (element) {
586  var i = instances.get(element);
587  bindMouseScrollXHandler(element, i);
588  bindMouseScrollYHandler(element, i);
589};
590
591},{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19}],12:[function(require,module,exports){
592/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
593 * Licensed under the MIT License
594 */
595'use strict';
596
597var h = require('../../lib/helper')
598  , instances = require('../instances')
599  , updateGeometry = require('../update-geometry');
600
601function bindKeyboardHandler(element, i) {
602  var hovered = false;
603  i.event.bind(element, 'mouseenter', function () {
604    hovered = true;
605  });
606  i.event.bind(element, 'mouseleave', function () {
607    hovered = false;
608  });
609
610  var shouldPrevent = false;
611  function shouldPreventDefault(deltaX, deltaY) {
612    var scrollTop = element.scrollTop;
613    if (deltaX === 0) {
614      if (!i.scrollbarYActive) {
615        return false;
616      }
617      if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) {
618        return !i.settings.wheelPropagation;
619      }
620    }
621
622    var scrollLeft = element.scrollLeft;
623    if (deltaY === 0) {
624      if (!i.scrollbarXActive) {
625        return false;
626      }
627      if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) {
628        return !i.settings.wheelPropagation;
629      }
630    }
631    return true;
632  }
633
634  i.event.bind(i.ownerDocument, 'keydown', function (e) {
635    if (e.isDefaultPrevented && e.isDefaultPrevented()) {
636      return;
637    }
638
639    if (!hovered) {
640      return;
641    }
642
643    var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement;
644    if (activeElement) {
645      // go deeper if element is a webcomponent
646      while (activeElement.shadowRoot) {
647        activeElement = activeElement.shadowRoot.activeElement;
648      }
649      if (h.isEditable(activeElement)) {
650        return;
651      }
652    }
653
654    var deltaX = 0;
655    var deltaY = 0;
656
657    switch (e.which) {
658    case 37: // left
659      deltaX = -30;
660      break;
661    case 38: // up
662      deltaY = 30;
663      break;
664    case 39: // right
665      deltaX = 30;
666      break;
667    case 40: // down
668      deltaY = -30;
669      break;
670    case 33: // page up
671      deltaY = 90;
672      break;
673    case 32: // space bar
674    case 34: // page down
675      deltaY = -90;
676      break;
677    case 35: // end
678      if (e.ctrlKey) {
679        deltaY = -i.contentHeight;
680      } else {
681        deltaY = -i.containerHeight;
682      }
683      break;
684    case 36: // home
685      if (e.ctrlKey) {
686        deltaY = element.scrollTop;
687      } else {
688        deltaY = i.containerHeight;
689      }
690      break;
691    default:
692      return;
693    }
694
695    element.scrollTop = element.scrollTop - deltaY;
696    element.scrollLeft = element.scrollLeft + deltaX;
697    updateGeometry(element);
698
699    shouldPrevent = shouldPreventDefault(deltaX, deltaY);
700    if (shouldPrevent) {
701      e.preventDefault();
702    }
703  });
704}
705
706module.exports = function (element) {
707  var i = instances.get(element);
708  bindKeyboardHandler(element, i);
709};
710
711},{"../../lib/helper":6,"../instances":18,"../update-geometry":19}],13:[function(require,module,exports){
712/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
713 * Licensed under the MIT License
714 */
715'use strict';
716
717var h = require('../../lib/helper')
718  , instances = require('../instances')
719  , updateGeometry = require('../update-geometry');
720
721function bindMouseWheelHandler(element, i) {
722  var shouldPrevent = false;
723
724  function shouldPreventDefault(deltaX, deltaY) {
725    var scrollTop = element.scrollTop;
726    if (deltaX === 0) {
727      if (!i.scrollbarYActive) {
728        return false;
729      }
730      if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) {
731        return !i.settings.wheelPropagation;
732      }
733    }
734
735    var scrollLeft = element.scrollLeft;
736    if (deltaY === 0) {
737      if (!i.scrollbarXActive) {
738        return false;
739      }
740      if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) {
741        return !i.settings.wheelPropagation;
742      }
743    }
744    return true;
745  }
746
747  function getDeltaFromEvent(e) {
748    var deltaX = e.deltaX;
749    var deltaY = -1 * e.deltaY;
750
751    if (typeof deltaX === "undefined" || typeof deltaY === "undefined") {
752      // OS X Safari
753      deltaX = -1 * e.wheelDeltaX / 6;
754      deltaY = e.wheelDeltaY / 6;
755    }
756
757    if (e.deltaMode && e.deltaMode === 1) {
758      // Firefox in deltaMode 1: Line scrolling
759      deltaX *= 10;
760      deltaY *= 10;
761    }
762
763    if (deltaX !== deltaX && deltaY !== deltaY/* NaN checks */) {
764      // IE in some mouse drivers
765      deltaX = 0;
766      deltaY = e.wheelDelta;
767    }
768
769    return [deltaX, deltaY];
770  }
771
772  function shouldBeConsumedByTextarea(deltaX, deltaY) {
773    var hoveredTextarea = element.querySelector('textarea:hover');
774    if (hoveredTextarea) {
775      var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight;
776      if (maxScrollTop > 0) {
777        if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) &&
778            !(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) {
779          return true;
780        }
781      }
782      var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth;
783      if (maxScrollLeft > 0) {
784        if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) &&
785            !(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) {
786          return true;
787        }
788      }
789    }
790    return false;
791  }
792
793  function mousewheelHandler(e) {
794    // FIXME: this is a quick fix for the select problem in FF and IE.
795    // If there comes an effective way to deal with the problem,
796    // this lines should be removed.
797    if (!h.env.isWebKit && element.querySelector('select:focus')) {
798      return;
799    }
800
801    var delta = getDeltaFromEvent(e);
802
803    var deltaX = delta[0];
804    var deltaY = delta[1];
805
806    if (shouldBeConsumedByTextarea(deltaX, deltaY)) {
807      return;
808    }
809
810    shouldPrevent = false;
811    if (!i.settings.useBothWheelAxes) {
812      // deltaX will only be used for horizontal scrolling and deltaY will
813      // only be used for vertical scrolling - this is the default
814      element.scrollTop = element.scrollTop - (deltaY * i.settings.wheelSpeed);
815      element.scrollLeft = element.scrollLeft + (deltaX * i.settings.wheelSpeed);
816    } else if (i.scrollbarYActive && !i.scrollbarXActive) {
817      // only vertical scrollbar is active and useBothWheelAxes option is
818      // active, so let's scroll vertical bar using both mouse wheel axes
819      if (deltaY) {
820        element.scrollTop = element.scrollTop - (deltaY * i.settings.wheelSpeed);
821      } else {
822        element.scrollTop = element.scrollTop + (deltaX * i.settings.wheelSpeed);
823      }
824      shouldPrevent = true;
825    } else if (i.scrollbarXActive && !i.scrollbarYActive) {
826      // useBothWheelAxes and only horizontal bar is active, so use both
827      // wheel axes for horizontal bar
828      if (deltaX) {
829        element.scrollLeft = element.scrollLeft + (deltaX * i.settings.wheelSpeed);
830      } else {
831        element.scrollLeft = element.scrollLeft - (deltaY * i.settings.wheelSpeed);
832      }
833      shouldPrevent = true;
834    }
835
836    updateGeometry(element);
837
838    shouldPrevent = (shouldPrevent || shouldPreventDefault(deltaX, deltaY));
839    if (shouldPrevent) {
840      e.stopPropagation();
841      e.preventDefault();
842    }
843  }
844
845  if (typeof window.onwheel !== "undefined") {
846    i.event.bind(element, 'wheel', mousewheelHandler);
847  } else if (typeof window.onmousewheel !== "undefined") {
848    i.event.bind(element, 'mousewheel', mousewheelHandler);
849  }
850}
851
852module.exports = function (element) {
853  var i = instances.get(element);
854  bindMouseWheelHandler(element, i);
855};
856
857},{"../../lib/helper":6,"../instances":18,"../update-geometry":19}],14:[function(require,module,exports){
858/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
859 * Licensed under the MIT License
860 */
861'use strict';
862
863var instances = require('../instances')
864  , updateGeometry = require('../update-geometry');
865
866function bindNativeScrollHandler(element, i) {
867  i.event.bind(element, 'scroll', function () {
868    updateGeometry(element);
869  });
870}
871
872module.exports = function (element) {
873  var i = instances.get(element);
874  bindNativeScrollHandler(element, i);
875};
876
877},{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){
878/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
879 * Licensed under the MIT License
880 */
881'use strict';
882
883var h = require('../../lib/helper')
884  , instances = require('../instances')
885  , updateGeometry = require('../update-geometry');
886
887function bindSelectionHandler(element, i) {
888  function getRangeNode() {
889    var selection = window.getSelection ? window.getSelection() :
890                    document.getSelection ? document.getSelection() : '';
891    if (selection.toString().length === 0) {
892      return null;
893    } else {
894      return selection.getRangeAt(0).commonAncestorContainer;
895    }
896  }
897
898  var scrollingLoop = null;
899  var scrollDiff = {top: 0, left: 0};
900  function startScrolling() {
901    if (!scrollingLoop) {
902      scrollingLoop = setInterval(function () {
903        if (!instances.get(element)) {
904          clearInterval(scrollingLoop);
905          return;
906        }
907
908        element.scrollTop = element.scrollTop + scrollDiff.top;
909        element.scrollLeft = element.scrollLeft + scrollDiff.left;
910        updateGeometry(element);
911      }, 50); // every .1 sec
912    }
913  }
914  function stopScrolling() {
915    if (scrollingLoop) {
916      clearInterval(scrollingLoop);
917      scrollingLoop = null;
918    }
919    h.stopScrolling(element);
920  }
921
922  var isSelected = false;
923  i.event.bind(i.ownerDocument, 'selectionchange', function () {
924    if (element.contains(getRangeNode())) {
925      isSelected = true;
926    } else {
927      isSelected = false;
928      stopScrolling();
929    }
930  });
931  i.event.bind(window, 'mouseup', function () {
932    if (isSelected) {
933      isSelected = false;
934      stopScrolling();
935    }
936  });
937
938  i.event.bind(window, 'mousemove', function (e) {
939    if (isSelected) {
940      var mousePosition = {x: e.pageX, y: e.pageY};
941      var containerGeometry = {
942        left: element.offsetLeft,
943        right: element.offsetLeft + element.offsetWidth,
944        top: element.offsetTop,
945        bottom: element.offsetTop + element.offsetHeight
946      };
947
948      if (mousePosition.x < containerGeometry.left + 3) {
949        scrollDiff.left = -5;
950        h.startScrolling(element, 'x');
951      } else if (mousePosition.x > containerGeometry.right - 3) {
952        scrollDiff.left = 5;
953        h.startScrolling(element, 'x');
954      } else {
955        scrollDiff.left = 0;
956      }
957
958      if (mousePosition.y < containerGeometry.top + 3) {
959        if (containerGeometry.top + 3 - mousePosition.y < 5) {
960          scrollDiff.top = -5;
961        } else {
962          scrollDiff.top = -20;
963        }
964        h.startScrolling(element, 'y');
965      } else if (mousePosition.y > containerGeometry.bottom - 3) {
966        if (mousePosition.y - containerGeometry.bottom + 3 < 5) {
967          scrollDiff.top = 5;
968        } else {
969          scrollDiff.top = 20;
970        }
971        h.startScrolling(element, 'y');
972      } else {
973        scrollDiff.top = 0;
974      }
975
976      if (scrollDiff.top === 0 && scrollDiff.left === 0) {
977        stopScrolling();
978      } else {
979        startScrolling();
980      }
981    }
982  });
983}
984
985module.exports = function (element) {
986  var i = instances.get(element);
987  bindSelectionHandler(element, i);
988};
989
990},{"../../lib/helper":6,"../instances":18,"../update-geometry":19}],16:[function(require,module,exports){
991/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
992 * Licensed under the MIT License
993 */
994'use strict';
995
996var instances = require('../instances')
997  , updateGeometry = require('../update-geometry');
998
999function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
1000  function shouldPreventDefault(deltaX, deltaY) {
1001    var scrollTop = element.scrollTop;
1002    var scrollLeft = element.scrollLeft;
1003    var magnitudeX = Math.abs(deltaX);
1004    var magnitudeY = Math.abs(deltaY);
1005
1006    if (magnitudeY > magnitudeX) {
1007      // user is perhaps trying to swipe up/down the page
1008
1009      if (((deltaY < 0) && (scrollTop === i.contentHeight - i.containerHeight)) ||
1010          ((deltaY > 0) && (scrollTop === 0))) {
1011        return !i.settings.swipePropagation;
1012      }
1013    } else if (magnitudeX > magnitudeY) {
1014      // user is perhaps trying to swipe left/right across the page
1015
1016      if (((deltaX < 0) && (scrollLeft === i.contentWidth - i.containerWidth)) ||
1017          ((deltaX > 0) && (scrollLeft === 0))) {
1018        return !i.settings.swipePropagation;
1019      }
1020    }
1021
1022    return true;
1023  }
1024
1025  function applyTouchMove(differenceX, differenceY) {
1026    element.scrollTop = element.scrollTop - differenceY;
1027    element.scrollLeft = element.scrollLeft - differenceX;
1028
1029    updateGeometry(element);
1030  }
1031
1032  var startOffset = {};
1033  var startTime = 0;
1034  var speed = {};
1035  var easingLoop = null;
1036  var inGlobalTouch = false;
1037  var inLocalTouch = false;
1038
1039  function globalTouchStart() {
1040    inGlobalTouch = true;
1041  }
1042  function globalTouchEnd() {
1043    inGlobalTouch = false;
1044  }
1045
1046  function getTouch(e) {
1047    if (e.targetTouches) {
1048      return e.targetTouches[0];
1049    } else {
1050      // Maybe IE pointer
1051      return e;
1052    }
1053  }
1054  function shouldHandle(e) {
1055    if (e.targetTouches && e.targetTouches.length === 1) {
1056      return true;
1057    }
1058    if (e.pointerType && e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
1059      return true;
1060    }
1061    return false;
1062  }
1063  function touchStart(e) {
1064    if (shouldHandle(e)) {
1065      inLocalTouch = true;
1066
1067      var touch = getTouch(e);
1068
1069      startOffset.pageX = touch.pageX;
1070      startOffset.pageY = touch.pageY;
1071
1072      startTime = (new Date()).getTime();
1073
1074      if (easingLoop !== null) {
1075        clearInterval(easingLoop);
1076      }
1077
1078      e.stopPropagation();
1079    }
1080  }
1081  function touchMove(e) {
1082    if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
1083      var touch = getTouch(e);
1084
1085      var currentOffset = {pageX: touch.pageX, pageY: touch.pageY};
1086
1087      var differenceX = currentOffset.pageX - startOffset.pageX;
1088      var differenceY = currentOffset.pageY - startOffset.pageY;
1089
1090      applyTouchMove(differenceX, differenceY);
1091      startOffset = currentOffset;
1092
1093      var currentTime = (new Date()).getTime();
1094
1095      var timeGap = currentTime - startTime;
1096      if (timeGap > 0) {
1097        speed.x = differenceX / timeGap;
1098        speed.y = differenceY / timeGap;
1099        startTime = currentTime;
1100      }
1101
1102      if (shouldPreventDefault(differenceX, differenceY)) {
1103        e.stopPropagation();
1104        e.preventDefault();
1105      }
1106    }
1107  }
1108  function touchEnd() {
1109    if (!inGlobalTouch && inLocalTouch) {
1110      inLocalTouch = false;
1111
1112      clearInterval(easingLoop);
1113      easingLoop = setInterval(function () {
1114        if (!instances.get(element)) {
1115          clearInterval(easingLoop);
1116          return;
1117        }
1118
1119        if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
1120          clearInterval(easingLoop);
1121          return;
1122        }
1123
1124        applyTouchMove(speed.x * 30, speed.y * 30);
1125
1126        speed.x *= 0.8;
1127        speed.y *= 0.8;
1128      }, 10);
1129    }
1130  }
1131
1132  if (supportsTouch) {
1133    i.event.bind(window, 'touchstart', globalTouchStart);
1134    i.event.bind(window, 'touchend', globalTouchEnd);
1135    i.event.bind(element, 'touchstart', touchStart);
1136    i.event.bind(element, 'touchmove', touchMove);
1137    i.event.bind(element, 'touchend', touchEnd);
1138  }
1139
1140  if (supportsIePointer) {
1141    if (window.PointerEvent) {
1142      i.event.bind(window, 'pointerdown', globalTouchStart);
1143      i.event.bind(window, 'pointerup', globalTouchEnd);
1144      i.event.bind(element, 'pointerdown', touchStart);
1145      i.event.bind(element, 'pointermove', touchMove);
1146      i.event.bind(element, 'pointerup', touchEnd);
1147    } else if (window.MSPointerEvent) {
1148      i.event.bind(window, 'MSPointerDown', globalTouchStart);
1149      i.event.bind(window, 'MSPointerUp', globalTouchEnd);
1150      i.event.bind(element, 'MSPointerDown', touchStart);
1151      i.event.bind(element, 'MSPointerMove', touchMove);
1152      i.event.bind(element, 'MSPointerUp', touchEnd);
1153    }
1154  }
1155}
1156
1157module.exports = function (element, supportsTouch, supportsIePointer) {
1158  var i = instances.get(element);
1159  bindTouchHandler(element, i, supportsTouch, supportsIePointer);
1160};
1161
1162},{"../instances":18,"../update-geometry":19}],17:[function(require,module,exports){
1163/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1164 * Licensed under the MIT License
1165 */
1166'use strict';
1167
1168var cls = require('../lib/class')
1169  , h = require('../lib/helper')
1170  , instances = require('./instances')
1171  , updateGeometry = require('./update-geometry');
1172
1173// Handlers
1174var clickRailHandler = require('./handler/click-rail')
1175  , dragScrollbarHandler = require('./handler/drag-scrollbar')
1176  , keyboardHandler = require('./handler/keyboard')
1177  , mouseWheelHandler = require('./handler/mouse-wheel')
1178  , nativeScrollHandler = require('./handler/native-scroll')
1179  , selectionHandler = require('./handler/selection')
1180  , touchHandler = require('./handler/touch');
1181
1182module.exports = function (element, userSettings) {
1183  userSettings = typeof userSettings === 'object' ? userSettings : {};
1184
1185  cls.add(element, 'ps-container');
1186
1187  // Create a plugin instance.
1188  var i = instances.add(element);
1189
1190  i.settings = h.extend(i.settings, userSettings);
1191
1192  clickRailHandler(element);
1193  dragScrollbarHandler(element);
1194  mouseWheelHandler(element);
1195  nativeScrollHandler(element);
1196  selectionHandler(element);
1197
1198  if (h.env.supportsTouch || h.env.supportsIePointer) {
1199    touchHandler(element, h.env.supportsTouch, h.env.supportsIePointer);
1200  }
1201  if (i.settings.useKeyboard) {
1202    keyboardHandler(element);
1203  }
1204
1205  updateGeometry(element);
1206};
1207
1208},{"../lib/class":2,"../lib/helper":6,"./handler/click-rail":10,"./handler/drag-scrollbar":11,"./handler/keyboard":12,"./handler/mouse-wheel":13,"./handler/native-scroll":14,"./handler/selection":15,"./handler/touch":16,"./instances":18,"./update-geometry":19}],18:[function(require,module,exports){
1209/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1210 * Licensed under the MIT License
1211 */
1212'use strict';
1213
1214var d = require('../lib/dom')
1215  , defaultSettings = require('./default-setting')
1216  , EventManager = require('../lib/event-manager')
1217  , guid = require('../lib/guid')
1218  , h = require('../lib/helper');
1219
1220var instances = {};
1221
1222function Instance(element) {
1223  var i = this;
1224
1225  i.settings = h.clone(defaultSettings);
1226  i.containerWidth = null;
1227  i.containerHeight = null;
1228  i.contentWidth = null;
1229  i.contentHeight = null;
1230
1231  i.isRtl = d.css(element, 'direction') === "rtl";
1232  i.isNegativeScroll = (function () {
1233    var originalScrollLeft = element.scrollLeft;
1234    var result = null;
1235    element.scrollLeft = -1;
1236    result = element.scrollLeft < 0;
1237    element.scrollLeft = originalScrollLeft;
1238    return result;
1239  })();
1240  i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1241  i.event = new EventManager();
1242  i.ownerDocument = element.ownerDocument || document;
1243
1244  i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element);
1245  i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail);
1246  i.scrollbarXActive = null;
1247  i.scrollbarXWidth = null;
1248  i.scrollbarXLeft = null;
1249  i.scrollbarXBottom = h.toInt(d.css(i.scrollbarXRail, 'bottom'));
1250  i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN
1251  i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : h.toInt(d.css(i.scrollbarXRail, 'top'));
1252  i.railBorderXWidth = h.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + h.toInt(d.css(i.scrollbarXRail, 'borderRightWidth'));
1253  // Set rail to display:block to calculate margins
1254  d.css(i.scrollbarXRail, 'display', 'block');
1255  i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight'));
1256  d.css(i.scrollbarXRail, 'display', '');
1257  i.railXWidth = null;
1258  i.railXRatio = null;
1259
1260  i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element);
1261  i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail);
1262  i.scrollbarYActive = null;
1263  i.scrollbarYHeight = null;
1264  i.scrollbarYTop = null;
1265  i.scrollbarYRight = h.toInt(d.css(i.scrollbarYRail, 'right'));
1266  i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN
1267  i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : h.toInt(d.css(i.scrollbarYRail, 'left'));
1268  i.scrollbarYOuterWidth = i.isRtl ? h.outerWidth(i.scrollbarY) : null;
1269  i.railBorderYWidth = h.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + h.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth'));
1270  d.css(i.scrollbarYRail, 'display', 'block');
1271  i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
1272  d.css(i.scrollbarYRail, 'display', '');
1273  i.railYHeight = null;
1274  i.railYRatio = null;
1275}
1276
1277function getId(element) {
1278  if (typeof element.dataset === 'undefined') {
1279    return element.getAttribute('data-ps-id');
1280  } else {
1281    return element.dataset.psId;
1282  }
1283}
1284
1285function setId(element, id) {
1286  if (typeof element.dataset === 'undefined') {
1287    element.setAttribute('data-ps-id', id);
1288  } else {
1289    element.dataset.psId = id;
1290  }
1291}
1292
1293function removeId(element) {
1294  if (typeof element.dataset === 'undefined') {
1295    element.removeAttribute('data-ps-id');
1296  } else {
1297    delete element.dataset.psId;
1298  }
1299}
1300
1301exports.add = function (element) {
1302  var newId = guid();
1303  setId(element, newId);
1304  instances[newId] = new Instance(element);
1305  return instances[newId];
1306};
1307
1308exports.remove = function (element) {
1309  delete instances[getId(element)];
1310  removeId(element);
1311};
1312
1313exports.get = function (element) {
1314  return instances[getId(element)];
1315};
1316
1317}
1317,{"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){
1318/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1319 * Licensed under the MIT License
1320 */
1321'use strict';
1322
1323var cls = require('../lib/class')
1324  , d = require('../lib/dom')
1325  , h = require('../lib/helper')
1326  , instances = require('./instances');
1327
1328function getThumbSize(i, thumbSize) {
1329  if (i.settings.minScrollbarLength) {
1330    thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength);
1331  }
1332  if (i.settings.maxScrollbarLength) {
1333    thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength);
1334  }
1335  return thumbSize;
1336}
1337
1338function updateCss(element, i) {
1339  var xRailOffset = {width: i.railXWidth};
1340  if (i.isRtl) {
1341    xRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth - i.contentWidth;
1342  } else {
1343    xRailOffset.left = element.scrollLeft;
1344  }
1345  if (i.isScrollbarXUsingBottom) {
1346    xRailOffset.bottom = i.scrollbarXBottom - element.scrollTop;
1347  } else {
1348    xRailOffset.top = i.scrollbarXTop + element.scrollTop;
1349  }
1350  d.css(i.scrollbarXRail, xRailOffset);
1351
1352  var yRailOffset = {top: element.scrollTop, height: i.railYHeight};
1353  if (i.isScrollbarYUsingRight) {
1354    if (i.isRtl) {
1355      yRailOffset.right = i.contentWidth - (i.negativeScrollAdjustment + element.scrollLeft) - i.scrollbarYRight - i.scrollbarYOuterWidth;
1356    } else {
1357      yRailOffset.right = i.scrollbarYRight - element.scrollLeft;
1358    }
1359  } else {
1360    if (i.isRtl) {
1361      yRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth * 2 - i.contentWidth - i.scrollbarYLeft - i.scrollbarYOuterWidth;
1362    } else {
1363      yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
1364    }
1365  }
1366  d.css(i.scrollbarYRail, yRailOffset);
1367
1368  d.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth});
1369  d.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth});
1370}
1371
1372module.exports = function (element) {
1373  var i = instances.get(element);
1374
1375  i.containerWidth = element.clientWidth;
1376  i.containerHeight = element.clientHeight;
1377  i.contentWidth = element.scrollWidth;
1378  i.contentHeight = element.scrollHeight;
1379
1380  if (!element.contains(i.scrollbarXRail)) {
1381    d.appendTo(i.scrollbarXRail, element);
1382  }
1383  if (!element.contains(i.scrollbarYRail)) {
1384    d.appendTo(i.scrollbarYRail, element);
1385  }
1386
1387  if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
1388    i.scrollbarXActive = true;
1389    i.railXWidth = i.containerWidth - i.railXMarginWidth;
1390    i.railXRatio = i.containerWidth / i.railXWidth;
1391    i.scrollbarXWidth = getThumbSize(i, h.toInt(i.railXWidth * i.containerWidth / i.contentWidth));
1392    i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth));
1393  } else {
1394    i.scrollbarXActive = false;
1395    i.scrollbarXWidth = 0;
1396    i.scrollbarXLeft = 0;
1397    element.scrollLeft = 0;
1398  }
1399
1400  if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) {
1401    i.scrollbarYActive = true;
1402    i.railYHeight = i.containerHeight - i.railYMarginHeight;
1403    i.railYRatio = i.containerHeight / i.railYHeight;
1404    i.scrollbarYHeight = getThumbSize(i, h.toInt(i.railYHeight * i.containerHeight / i.contentHeight));
1405    i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight));
1406  } else {
1407    i.scrollbarYActive = false;
1408    i.scrollbarYHeight = 0;
1409    i.scrollbarYTop = 0;
1410    element.scrollTop = 0;
1411  }
1412
1413  if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) {
1414    i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth;
1415  }
1416  if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) {
1417    i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight;
1418  }
1419
1420  updateCss(element, i);
1421
1422  cls[i.scrollbarXActive ? 'add' : 'remove'](element, 'ps-active-x');
1423  cls[i.scrollbarYActive ? 'add' : 'remove'](element, 'ps-active-y');
1424};
1425
1426},{"../lib/class":2,"../lib/dom":3,"../lib/helper":6,"./instances":18}],20:[function(require,module,exports){
1427/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
1428 * Licensed under the MIT License
1429 */
1430'use strict';
1431
1432var d = require('../lib/dom')
1433  , h = require('../lib/helper')
1434  , instances = require('./instances')
1435  , updateGeometry = require('./update-geometry');
1436
1437module.exports = function (element) {
1438  var i = instances.get(element);
1439
1440  if (!i) {
1441    return;
1442  }
1443
1444  // Recalcuate negative scrollLeft adjustment
1445  i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1446
1447  // Recalculate rail margins
1448  d.css(i.scrollbarXRail, 'display', 'block');
1449  d.css(i.scrollbarYRail, 'display', 'block');
1450  i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight'));
1451  i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
1452
1453  // Hide scrollbars not to affect scrollWidth and scrollHeight
1454  d.css(i.scrollbarXRail, 'display', 'none');
1455  d.css(i.scrollbarYRail, 'display', 'none');
1456
1457  updateGeometry(element);
1458
1459  d.css(i.scrollbarXRail, 'display', '');
1460  d.css(i.scrollbarYRail, 'display', '');
1461};
1462
1463},{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19}]},{},[1]);

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.