PageSourceSearch

https://www.northarlington.org/_Assets/js/jquery/libs/perfect-scrollbar/perfect-scrollbar.jquery.js

js northarlington.org collected 2026-10-02 16:47:27 UTC 45,611 bytes, 1,517 lines download raw bytes

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