Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:30

0001 /* perfect-scrollbar v0.6.10 */
0002 (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){
0003 'use strict';
0004 
0005 var ps = require('../main')
0006   , psInstances = require('../plugin/instances');
0007 
0008 function mountJQuery(jQuery) {
0009   jQuery.fn.perfectScrollbar = function (settingOrCommand) {
0010     return this.each(function () {
0011       if (typeof settingOrCommand === 'object' ||
0012           typeof settingOrCommand === 'undefined') {
0013         // If it's an object or none, initialize.

0014         var settings = settingOrCommand;
0015 
0016         if (!psInstances.get(this)) {
0017           ps.initialize(this, settings);
0018         }
0019       } else {
0020         // Unless, it may be a command.

0021         var command = settingOrCommand;
0022 
0023         if (command === 'update') {
0024           ps.update(this);
0025         } else if (command === 'destroy') {
0026           ps.destroy(this);
0027         }
0028       }
0029 
0030       return jQuery(this);
0031     });
0032   };
0033 }
0034 
0035 if (typeof define === 'function' && define.amd) {
0036   // AMD. Register as an anonymous module.

0037   define(['jquery'], mountJQuery);
0038 } else {
0039   var jq = window.jQuery ? window.jQuery : window.$;
0040   if (typeof jq !== 'undefined') {
0041     mountJQuery(jq);
0042   }
0043 }
0044 
0045 module.exports = mountJQuery;
0046 
0047 },{"../main":7,"../plugin/instances":18}],2:[function(require,module,exports){
0048 'use strict';
0049 
0050 function oldAdd(element, className) {
0051   var classes = element.className.split(' ');
0052   if (classes.indexOf(className) < 0) {
0053     classes.push(className);
0054   }
0055   element.className = classes.join(' ');
0056 }
0057 
0058 function oldRemove(element, className) {
0059   var classes = element.className.split(' ');
0060   var idx = classes.indexOf(className);
0061   if (idx >= 0) {
0062     classes.splice(idx, 1);
0063   }
0064   element.className = classes.join(' ');
0065 }
0066 
0067 exports.add = function (element, className) {
0068   if (element.classList) {
0069     element.classList.add(className);
0070   } else {
0071     oldAdd(element, className);
0072   }
0073 };
0074 
0075 exports.remove = function (element, className) {
0076   if (element.classList) {
0077     element.classList.remove(className);
0078   } else {
0079     oldRemove(element, className);
0080   }
0081 };
0082 
0083 exports.list = function (element) {
0084   if (element.classList) {
0085     return Array.prototype.slice.apply(element.classList);
0086   } else {
0087     return element.className.split(' ');
0088   }
0089 };
0090 
0091 },{}],3:[function(require,module,exports){
0092 'use strict';
0093 
0094 var DOM = {};
0095 
0096 DOM.e = function (tagName, className) {
0097   var element = document.createElement(tagName);
0098   element.className = className;
0099   return element;
0100 };
0101 
0102 DOM.appendTo = function (child, parent) {
0103   parent.appendChild(child);
0104   return child;
0105 };
0106 
0107 function cssGet(element, styleName) {
0108   return window.getComputedStyle(element)[styleName];
0109 }
0110 
0111 function cssSet(element, styleName, styleValue) {
0112   if (typeof styleValue === 'number') {
0113     styleValue = styleValue.toString() + 'px';
0114   }
0115   element.style[styleName] = styleValue;
0116   return element;
0117 }
0118 
0119 function cssMultiSet(element, obj) {
0120   for (var key in obj) {
0121     var val = obj[key];
0122     if (typeof val === 'number') {
0123       val = val.toString() + 'px';
0124     }
0125     element.style[key] = val;
0126   }
0127   return element;
0128 }
0129 
0130 DOM.css = function (element, styleNameOrObject, styleValue) {
0131   if (typeof styleNameOrObject === 'object') {
0132     // multiple set with object

0133     return cssMultiSet(element, styleNameOrObject);
0134   } else {
0135     if (typeof styleValue === 'undefined') {
0136       return cssGet(element, styleNameOrObject);
0137     } else {
0138       return cssSet(element, styleNameOrObject, styleValue);
0139     }
0140   }
0141 };
0142 
0143 DOM.matches = function (element, query) {
0144   if (typeof element.matches !== 'undefined') {
0145     return element.matches(query);
0146   } else {
0147     if (typeof element.matchesSelector !== 'undefined') {
0148       return element.matchesSelector(query);
0149     } else if (typeof element.webkitMatchesSelector !== 'undefined') {
0150       return element.webkitMatchesSelector(query);
0151     } else if (typeof element.mozMatchesSelector !== 'undefined') {
0152       return element.mozMatchesSelector(query);
0153     } else if (typeof element.msMatchesSelector !== 'undefined') {
0154       return element.msMatchesSelector(query);
0155     }
0156   }
0157 };
0158 
0159 DOM.remove = function (element) {
0160   if (typeof element.remove !== 'undefined') {
0161     element.remove();
0162   } else {
0163     if (element.parentNode) {
0164       element.parentNode.removeChild(element);
0165     }
0166   }
0167 };
0168 
0169 DOM.queryChildren = function (element, selector) {
0170   return Array.prototype.filter.call(element.childNodes, function (child) {
0171     return DOM.matches(child, selector);
0172   });
0173 };
0174 
0175 module.exports = DOM;
0176 
0177 },{}],4:[function(require,module,exports){
0178 'use strict';
0179 
0180 var EventElement = function (element) {
0181   this.element = element;
0182   this.events = {};
0183 };
0184 
0185 EventElement.prototype.bind = function (eventName, handler) {
0186   if (typeof this.events[eventName] === 'undefined') {
0187     this.events[eventName] = [];
0188   }
0189   this.events[eventName].push(handler);
0190   this.element.addEventListener(eventName, handler, false);
0191 };
0192 
0193 EventElement.prototype.unbind = function (eventName, handler) {
0194   var isHandlerProvided = (typeof handler !== 'undefined');
0195   this.events[eventName] = this.events[eventName].filter(function (hdlr) {
0196     if (isHandlerProvided && hdlr !== handler) {
0197       return true;
0198     }
0199     this.element.removeEventListener(eventName, hdlr, false);
0200     return false;
0201   }, this);
0202 };
0203 
0204 EventElement.prototype.unbindAll = function () {
0205   for (var name in this.events) {
0206     this.unbind(name);
0207   }
0208 };
0209 
0210 var EventManager = function () {
0211   this.eventElements = [];
0212 };
0213 
0214 EventManager.prototype.eventElement = function (element) {
0215   var ee = this.eventElements.filter(function (eventElement) {
0216     return eventElement.element === element;
0217   })[0];
0218   if (typeof ee === 'undefined') {
0219     ee = new EventElement(element);
0220     this.eventElements.push(ee);
0221   }
0222   return ee;
0223 };
0224 
0225 EventManager.prototype.bind = function (element, eventName, handler) {
0226   this.eventElement(element).bind(eventName, handler);
0227 };
0228 
0229 EventManager.prototype.unbind = function (element, eventName, handler) {
0230   this.eventElement(element).unbind(eventName, handler);
0231 };
0232 
0233 EventManager.prototype.unbindAll = function () {
0234   for (var i = 0; i < this.eventElements.length; i++) {
0235     this.eventElements[i].unbindAll();
0236   }
0237 };
0238 
0239 EventManager.prototype.once = function (element, eventName, handler) {
0240   var ee = this.eventElement(element);
0241   var onceHandler = function (e) {
0242     ee.unbind(eventName, onceHandler);
0243     handler(e);
0244   };
0245   ee.bind(eventName, onceHandler);
0246 };
0247 
0248 module.exports = EventManager;
0249 
0250 },{}],5:[function(require,module,exports){
0251 'use strict';
0252 
0253 module.exports = (function () {
0254   function s4() {
0255     return Math.floor((1 + Math.random()) * 0x10000)
0256                .toString(16)
0257                .substring(1);
0258   }
0259   return function () {
0260     return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
0261            s4() + '-' + s4() + s4() + s4();
0262   };
0263 })();
0264 
0265 },{}],6:[function(require,module,exports){
0266 'use strict';
0267 
0268 var cls = require('./class')
0269   , d = require('./dom');
0270 
0271 exports.toInt = function (x) {
0272   return parseInt(x, 10) || 0;
0273 };
0274 
0275 exports.clone = function (obj) {
0276   if (obj === null) {
0277     return null;
0278   } else if (typeof obj === 'object') {
0279     var result = {};
0280     for (var key in obj) {
0281       result[key] = this.clone(obj[key]);
0282     }
0283     return result;
0284   } else {
0285     return obj;
0286   }
0287 };
0288 
0289 exports.extend = function (original, source) {
0290   var result = this.clone(original);
0291   for (var key in source) {
0292     result[key] = this.clone(source[key]);
0293   }
0294   return result;
0295 };
0296 
0297 exports.isEditable = function (el) {
0298   return d.matches(el, "input,[contenteditable]") ||
0299          d.matches(el, "select,[contenteditable]") ||
0300          d.matches(el, "textarea,[contenteditable]") ||
0301          d.matches(el, "button,[contenteditable]");
0302 };
0303 
0304 exports.removePsClasses = function (element) {
0305   var clsList = cls.list(element);
0306   for (var i = 0; i < clsList.length; i++) {
0307     var className = clsList[i];
0308     if (className.indexOf('ps-') === 0) {
0309       cls.remove(element, className);
0310     }
0311   }
0312 };
0313 
0314 exports.outerWidth = function (element) {
0315   return this.toInt(d.css(element, 'width')) +
0316          this.toInt(d.css(element, 'paddingLeft')) +
0317          this.toInt(d.css(element, 'paddingRight')) +
0318          this.toInt(d.css(element, 'borderLeftWidth')) +
0319          this.toInt(d.css(element, 'borderRightWidth'));
0320 };
0321 
0322 exports.startScrolling = function (element, axis) {
0323   cls.add(element, 'ps-in-scrolling');
0324   if (typeof axis !== 'undefined') {
0325     cls.add(element, 'ps-' + axis);
0326   } else {
0327     cls.add(element, 'ps-x');
0328     cls.add(element, 'ps-y');
0329   }
0330 };
0331 
0332 exports.stopScrolling = function (element, axis) {
0333   cls.remove(element, 'ps-in-scrolling');
0334   if (typeof axis !== 'undefined') {
0335     cls.remove(element, 'ps-' + axis);
0336   } else {
0337     cls.remove(element, 'ps-x');
0338     cls.remove(element, 'ps-y');
0339   }
0340 };
0341 
0342 exports.env = {
0343   isWebKit: 'WebkitAppearance' in document.documentElement.style,
0344   supportsTouch: (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch),
0345   supportsIePointer: window.navigator.msMaxTouchPoints !== null
0346 };
0347 
0348 },{"./class":2,"./dom":3}],7:[function(require,module,exports){
0349 'use strict';
0350 
0351 var destroy = require('./plugin/destroy')
0352   , initialize = require('./plugin/initialize')
0353   , update = require('./plugin/update');
0354 
0355 module.exports = {
0356   initialize: initialize,
0357   update: update,
0358   destroy: destroy
0359 };
0360 
0361 },{"./plugin/destroy":9,"./plugin/initialize":17,"./plugin/update":21}],8:[function(require,module,exports){
0362 'use strict';
0363 
0364 module.exports = {
0365   maxScrollbarLength: null,
0366   minScrollbarLength: null,
0367   scrollXMarginOffset: 0,
0368   scrollYMarginOffset: 0,
0369   stopPropagationOnClick: true,
0370   suppressScrollX: false,
0371   suppressScrollY: false,
0372   swipePropagation: true,
0373   useBothWheelAxes: false,
0374   useKeyboard: true,
0375   useSelectionScroll: false,
0376   wheelPropagation: false,
0377   wheelSpeed: 1,
0378   theme: 'default'
0379 };
0380 
0381 },{}],9:[function(require,module,exports){
0382 'use strict';
0383 
0384 var d = require('../lib/dom')
0385   , h = require('../lib/helper')
0386   , instances = require('./instances');
0387 
0388 module.exports = function (element) {
0389   var i = instances.get(element);
0390 
0391   if (!i) {
0392     return;
0393   }
0394 
0395   i.event.unbindAll();
0396   d.remove(i.scrollbarX);
0397   d.remove(i.scrollbarY);
0398   d.remove(i.scrollbarXRail);
0399   d.remove(i.scrollbarYRail);
0400   h.removePsClasses(element);
0401 
0402   instances.remove(element);
0403 };
0404 
0405 },{"../lib/dom":3,"../lib/helper":6,"./instances":18}],10:[function(require,module,exports){
0406 'use strict';
0407 
0408 var h = require('../../lib/helper')
0409   , instances = require('../instances')
0410   , updateGeometry = require('../update-geometry')
0411   , updateScroll = require('../update-scroll');
0412 
0413 function bindClickRailHandler(element, i) {
0414   function pageOffset(el) {
0415     return el.getBoundingClientRect();
0416   }
0417   var stopPropagation = window.Event.prototype.stopPropagation.bind;
0418 
0419   if (i.settings.stopPropagationOnClick) {
0420     i.event.bind(i.scrollbarY, 'click', stopPropagation);
0421   }
0422   i.event.bind(i.scrollbarYRail, 'click', function (e) {
0423     var halfOfScrollbarLength = h.toInt(i.scrollbarYHeight / 2);
0424     var positionTop = i.railYRatio * (e.pageY - window.pageYOffset - pageOffset(i.scrollbarYRail).top - halfOfScrollbarLength);
0425     var maxPositionTop = i.railYRatio * (i.railYHeight - i.scrollbarYHeight);
0426     var positionRatio = positionTop / maxPositionTop;
0427 
0428     if (positionRatio < 0) {
0429       positionRatio = 0;
0430     } else if (positionRatio > 1) {
0431       positionRatio = 1;
0432     }
0433 
0434     updateScroll(element, 'top', (i.contentHeight - i.containerHeight) * positionRatio);
0435     updateGeometry(element);
0436 
0437     e.stopPropagation();
0438   });
0439 
0440   if (i.settings.stopPropagationOnClick) {
0441     i.event.bind(i.scrollbarX, 'click', stopPropagation);
0442   }
0443   i.event.bind(i.scrollbarXRail, 'click', function (e) {
0444     var halfOfScrollbarLength = h.toInt(i.scrollbarXWidth / 2);
0445     var positionLeft = i.railXRatio * (e.pageX - window.pageXOffset - pageOffset(i.scrollbarXRail).left - halfOfScrollbarLength);
0446     var maxPositionLeft = i.railXRatio * (i.railXWidth - i.scrollbarXWidth);
0447     var positionRatio = positionLeft / maxPositionLeft;
0448 
0449     if (positionRatio < 0) {
0450       positionRatio = 0;
0451     } else if (positionRatio > 1) {
0452       positionRatio = 1;
0453     }
0454 
0455     updateScroll(element, 'left', ((i.contentWidth - i.containerWidth) * positionRatio) - i.negativeScrollAdjustment);
0456     updateGeometry(element);
0457 
0458     e.stopPropagation();
0459   });
0460 }
0461 
0462 module.exports = function (element) {
0463   var i = instances.get(element);
0464   bindClickRailHandler(element, i);
0465 };
0466 
0467 },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],11:[function(require,module,exports){
0468 'use strict';
0469 
0470 var d = require('../../lib/dom')
0471   , h = require('../../lib/helper')
0472   , instances = require('../instances')
0473   , updateGeometry = require('../update-geometry')
0474   , updateScroll = require('../update-scroll');
0475 
0476 function bindMouseScrollXHandler(element, i) {
0477   var currentLeft = null;
0478   var currentPageX = null;
0479 
0480   function updateScrollLeft(deltaX) {
0481     var newLeft = currentLeft + (deltaX * i.railXRatio);
0482     var maxLeft = Math.max(0, i.scrollbarXRail.getBoundingClientRect().left) + (i.railXRatio * (i.railXWidth - i.scrollbarXWidth));
0483 
0484     if (newLeft < 0) {
0485       i.scrollbarXLeft = 0;
0486     } else if (newLeft > maxLeft) {
0487       i.scrollbarXLeft = maxLeft;
0488     } else {
0489       i.scrollbarXLeft = newLeft;
0490     }
0491 
0492     var scrollLeft = h.toInt(i.scrollbarXLeft * (i.contentWidth - i.containerWidth) / (i.containerWidth - (i.railXRatio * i.scrollbarXWidth))) - i.negativeScrollAdjustment;
0493     updateScroll(element, 'left', scrollLeft);
0494   }
0495 
0496   var mouseMoveHandler = function (e) {
0497     updateScrollLeft(e.pageX - currentPageX);
0498     updateGeometry(element);
0499     e.stopPropagation();
0500     e.preventDefault();
0501   };
0502 
0503   var mouseUpHandler = function () {
0504     h.stopScrolling(element, 'x');
0505     i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
0506   };
0507 
0508   i.event.bind(i.scrollbarX, 'mousedown', function (e) {
0509     currentPageX = e.pageX;
0510     currentLeft = h.toInt(d.css(i.scrollbarX, 'left')) * i.railXRatio;
0511     h.startScrolling(element, 'x');
0512 
0513     i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
0514     i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
0515 
0516     e.stopPropagation();
0517     e.preventDefault();
0518   });
0519 }
0520 
0521 function bindMouseScrollYHandler(element, i) {
0522   var currentTop = null;
0523   var currentPageY = null;
0524 
0525   function updateScrollTop(deltaY) {
0526     var newTop = currentTop + (deltaY * i.railYRatio);
0527     var maxTop = Math.max(0, i.scrollbarYRail.getBoundingClientRect().top) + (i.railYRatio * (i.railYHeight - i.scrollbarYHeight));
0528 
0529     if (newTop < 0) {
0530       i.scrollbarYTop = 0;
0531     } else if (newTop > maxTop) {
0532       i.scrollbarYTop = maxTop;
0533     } else {
0534       i.scrollbarYTop = newTop;
0535     }
0536 
0537     var scrollTop = h.toInt(i.scrollbarYTop * (i.contentHeight - i.containerHeight) / (i.containerHeight - (i.railYRatio * i.scrollbarYHeight)));
0538     updateScroll(element, 'top', scrollTop);
0539   }
0540 
0541   var mouseMoveHandler = function (e) {
0542     updateScrollTop(e.pageY - currentPageY);
0543     updateGeometry(element);
0544     e.stopPropagation();
0545     e.preventDefault();
0546   };
0547 
0548   var mouseUpHandler = function () {
0549     h.stopScrolling(element, 'y');
0550     i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler);
0551   };
0552 
0553   i.event.bind(i.scrollbarY, 'mousedown', function (e) {
0554     currentPageY = e.pageY;
0555     currentTop = h.toInt(d.css(i.scrollbarY, 'top')) * i.railYRatio;
0556     h.startScrolling(element, 'y');
0557 
0558     i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler);
0559     i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler);
0560 
0561     e.stopPropagation();
0562     e.preventDefault();
0563   });
0564 }
0565 
0566 module.exports = function (element) {
0567   var i = instances.get(element);
0568   bindMouseScrollXHandler(element, i);
0569   bindMouseScrollYHandler(element, i);
0570 };
0571 
0572 },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],12:[function(require,module,exports){
0573 'use strict';
0574 
0575 var h = require('../../lib/helper')
0576   , d = require('../../lib/dom')
0577   , instances = require('../instances')
0578   , updateGeometry = require('../update-geometry')
0579   , updateScroll = require('../update-scroll');
0580 
0581 function bindKeyboardHandler(element, i) {
0582   var hovered = false;
0583   i.event.bind(element, 'mouseenter', function () {
0584     hovered = true;
0585   });
0586   i.event.bind(element, 'mouseleave', function () {
0587     hovered = false;
0588   });
0589 
0590   var shouldPrevent = false;
0591   function shouldPreventDefault(deltaX, deltaY) {
0592     var scrollTop = element.scrollTop;
0593     if (deltaX === 0) {
0594       if (!i.scrollbarYActive) {
0595         return false;
0596       }
0597       if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) {
0598         return !i.settings.wheelPropagation;
0599       }
0600     }
0601 
0602     var scrollLeft = element.scrollLeft;
0603     if (deltaY === 0) {
0604       if (!i.scrollbarXActive) {
0605         return false;
0606       }
0607       if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) {
0608         return !i.settings.wheelPropagation;
0609       }
0610     }
0611     return true;
0612   }
0613 
0614   i.event.bind(i.ownerDocument, 'keydown', function (e) {
0615     if (e.isDefaultPrevented && e.isDefaultPrevented()) {
0616       return;
0617     }
0618 
0619     var focused = d.matches(i.scrollbarX, ':focus') ||
0620                   d.matches(i.scrollbarY, ':focus');
0621 
0622     if (!hovered && !focused) {
0623       return;
0624     }
0625 
0626     var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement;
0627     if (activeElement) {
0628       // go deeper if element is a webcomponent

0629       while (activeElement.shadowRoot) {
0630         activeElement = activeElement.shadowRoot.activeElement;
0631       }
0632       if (h.isEditable(activeElement)) {
0633         return;
0634       }
0635     }
0636 
0637     var deltaX = 0;
0638     var deltaY = 0;
0639 
0640     switch (e.which) {
0641     case 37: // left

0642       deltaX = -30;
0643       break;
0644     case 38: // up

0645       deltaY = 30;
0646       break;
0647     case 39: // right

0648       deltaX = 30;
0649       break;
0650     case 40: // down

0651       deltaY = -30;
0652       break;
0653     case 33: // page up

0654       deltaY = 90;
0655       break;
0656     case 32: // space bar

0657       if (e.shiftKey) {
0658         deltaY = 90;
0659       } else {
0660         deltaY = -90;
0661       }
0662       break;
0663     case 34: // page down

0664       deltaY = -90;
0665       break;
0666     case 35: // end

0667       if (e.ctrlKey) {
0668         deltaY = -i.contentHeight;
0669       } else {
0670         deltaY = -i.containerHeight;
0671       }
0672       break;
0673     case 36: // home

0674       if (e.ctrlKey) {
0675         deltaY = element.scrollTop;
0676       } else {
0677         deltaY = i.containerHeight;
0678       }
0679       break;
0680     default:
0681       return;
0682     }
0683 
0684     updateScroll(element, 'top', element.scrollTop - deltaY);
0685     updateScroll(element, 'left', element.scrollLeft + deltaX);
0686     updateGeometry(element);
0687 
0688     shouldPrevent = shouldPreventDefault(deltaX, deltaY);
0689     if (shouldPrevent) {
0690       e.preventDefault();
0691     }
0692   });
0693 }
0694 
0695 module.exports = function (element) {
0696   var i = instances.get(element);
0697   bindKeyboardHandler(element, i);
0698 };
0699 
0700 },{"../../lib/dom":3,"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],13:[function(require,module,exports){
0701 'use strict';
0702 
0703 var instances = require('../instances')
0704   , updateGeometry = require('../update-geometry')
0705   , updateScroll = require('../update-scroll');
0706 
0707 function bindMouseWheelHandler(element, i) {
0708   var shouldPrevent = false;
0709 
0710   function shouldPreventDefault(deltaX, deltaY) {
0711     var scrollTop = element.scrollTop;
0712     if (deltaX === 0) {
0713       if (!i.scrollbarYActive) {
0714         return false;
0715       }
0716       if ((scrollTop === 0 && deltaY > 0) || (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0)) {
0717         return !i.settings.wheelPropagation;
0718       }
0719     }
0720 
0721     var scrollLeft = element.scrollLeft;
0722     if (deltaY === 0) {
0723       if (!i.scrollbarXActive) {
0724         return false;
0725       }
0726       if ((scrollLeft === 0 && deltaX < 0) || (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0)) {
0727         return !i.settings.wheelPropagation;
0728       }
0729     }
0730     return true;
0731   }
0732 
0733   function getDeltaFromEvent(e) {
0734     var deltaX = e.deltaX;
0735     var deltaY = -1 * e.deltaY;
0736 
0737     if (typeof deltaX === "undefined" || typeof deltaY === "undefined") {
0738       // OS X Safari

0739       deltaX = -1 * e.wheelDeltaX / 6;
0740       deltaY = e.wheelDeltaY / 6;
0741     }
0742 
0743     if (e.deltaMode && e.deltaMode === 1) {
0744       // Firefox in deltaMode 1: Line scrolling

0745       deltaX *= 10;
0746       deltaY *= 10;
0747     }
0748 
0749     if (deltaX !== deltaX && deltaY !== deltaY/* NaN checks */) {
0750       // IE in some mouse drivers

0751       deltaX = 0;
0752       deltaY = e.wheelDelta;
0753     }
0754 
0755     return [deltaX, deltaY];
0756   }
0757 
0758   function shouldBeConsumedByTextarea(deltaX, deltaY) {
0759     var hoveredTextarea = element.querySelector('textarea:hover');
0760     if (hoveredTextarea) {
0761       var maxScrollTop = hoveredTextarea.scrollHeight - hoveredTextarea.clientHeight;
0762       if (maxScrollTop > 0) {
0763         if (!(hoveredTextarea.scrollTop === 0 && deltaY > 0) &&
0764             !(hoveredTextarea.scrollTop === maxScrollTop && deltaY < 0)) {
0765           return true;
0766         }
0767       }
0768       var maxScrollLeft = hoveredTextarea.scrollLeft - hoveredTextarea.clientWidth;
0769       if (maxScrollLeft > 0) {
0770         if (!(hoveredTextarea.scrollLeft === 0 && deltaX < 0) &&
0771             !(hoveredTextarea.scrollLeft === maxScrollLeft && deltaX > 0)) {
0772           return true;
0773         }
0774       }
0775     }
0776     return false;
0777   }
0778 
0779   function mousewheelHandler(e) {
0780     var delta = getDeltaFromEvent(e);
0781 
0782     var deltaX = delta[0];
0783     var deltaY = delta[1];
0784 
0785     if (shouldBeConsumedByTextarea(deltaX, deltaY)) {
0786       return;
0787     }
0788 
0789     shouldPrevent = false;
0790     if (!i.settings.useBothWheelAxes) {
0791       // deltaX will only be used for horizontal scrolling and deltaY will

0792       // only be used for vertical scrolling - this is the default

0793       updateScroll(element, 'top', element.scrollTop - (deltaY * i.settings.wheelSpeed));
0794       updateScroll(element, 'left', element.scrollLeft + (deltaX * i.settings.wheelSpeed));
0795     } else if (i.scrollbarYActive && !i.scrollbarXActive) {
0796       // only vertical scrollbar is active and useBothWheelAxes option is

0797       // active, so let's scroll vertical bar using both mouse wheel axes

0798       if (deltaY) {
0799         updateScroll(element, 'top', element.scrollTop - (deltaY * i.settings.wheelSpeed));
0800       } else {
0801         updateScroll(element, 'top', element.scrollTop + (deltaX * i.settings.wheelSpeed));
0802       }
0803       shouldPrevent = true;
0804     } else if (i.scrollbarXActive && !i.scrollbarYActive) {
0805       // useBothWheelAxes and only horizontal bar is active, so use both

0806       // wheel axes for horizontal bar

0807       if (deltaX) {
0808         updateScroll(element, 'left', element.scrollLeft + (deltaX * i.settings.wheelSpeed));
0809       } else {
0810         updateScroll(element, 'left', element.scrollLeft - (deltaY * i.settings.wheelSpeed));
0811       }
0812       shouldPrevent = true;
0813     }
0814 
0815     updateGeometry(element);
0816 
0817     shouldPrevent = (shouldPrevent || shouldPreventDefault(deltaX, deltaY));
0818     if (shouldPrevent) {
0819       e.stopPropagation();
0820       e.preventDefault();
0821     }
0822   }
0823 
0824   if (typeof window.onwheel !== "undefined") {
0825     i.event.bind(element, 'wheel', mousewheelHandler);
0826   } else if (typeof window.onmousewheel !== "undefined") {
0827     i.event.bind(element, 'mousewheel', mousewheelHandler);
0828   }
0829 }
0830 
0831 module.exports = function (element) {
0832   var i = instances.get(element);
0833   bindMouseWheelHandler(element, i);
0834 };
0835 
0836 },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],14:[function(require,module,exports){
0837 'use strict';
0838 
0839 var instances = require('../instances')
0840   , updateGeometry = require('../update-geometry');
0841 
0842 function bindNativeScrollHandler(element, i) {
0843   i.event.bind(element, 'scroll', function () {
0844     updateGeometry(element);
0845   });
0846 }
0847 
0848 module.exports = function (element) {
0849   var i = instances.get(element);
0850   bindNativeScrollHandler(element, i);
0851 };
0852 
0853 },{"../instances":18,"../update-geometry":19}],15:[function(require,module,exports){
0854 'use strict';
0855 
0856 var h = require('../../lib/helper')
0857   , instances = require('../instances')
0858   , updateGeometry = require('../update-geometry')
0859   , updateScroll = require('../update-scroll');
0860 
0861 function bindSelectionHandler(element, i) {
0862   function getRangeNode() {
0863     var selection = window.getSelection ? window.getSelection() :
0864                     document.getSelection ? document.getSelection() : '';
0865     if (selection.toString().length === 0) {
0866       return null;
0867     } else {
0868       return selection.getRangeAt(0).commonAncestorContainer;
0869     }
0870   }
0871 
0872   var scrollingLoop = null;
0873   var scrollDiff = {top: 0, left: 0};
0874   function startScrolling() {
0875     if (!scrollingLoop) {
0876       scrollingLoop = setInterval(function () {
0877         if (!instances.get(element)) {
0878           clearInterval(scrollingLoop);
0879           return;
0880         }
0881 
0882         updateScroll(element, 'top', element.scrollTop + scrollDiff.top);
0883         updateScroll(element, 'left', element.scrollLeft + scrollDiff.left);
0884         updateGeometry(element);
0885       }, 50); // every .1 sec

0886     }
0887   }
0888   function stopScrolling() {
0889     if (scrollingLoop) {
0890       clearInterval(scrollingLoop);
0891       scrollingLoop = null;
0892     }
0893     h.stopScrolling(element);
0894   }
0895 
0896   var isSelected = false;
0897   i.event.bind(i.ownerDocument, 'selectionchange', function () {
0898     if (element.contains(getRangeNode())) {
0899       isSelected = true;
0900     } else {
0901       isSelected = false;
0902       stopScrolling();
0903     }
0904   });
0905   i.event.bind(window, 'mouseup', function () {
0906     if (isSelected) {
0907       isSelected = false;
0908       stopScrolling();
0909     }
0910   });
0911 
0912   i.event.bind(window, 'mousemove', function (e) {
0913     if (isSelected) {
0914       var mousePosition = {x: e.pageX, y: e.pageY};
0915       var containerGeometry = {
0916         left: element.offsetLeft,
0917         right: element.offsetLeft + element.offsetWidth,
0918         top: element.offsetTop,
0919         bottom: element.offsetTop + element.offsetHeight
0920       };
0921 
0922       if (mousePosition.x < containerGeometry.left + 3) {
0923         scrollDiff.left = -5;
0924         h.startScrolling(element, 'x');
0925       } else if (mousePosition.x > containerGeometry.right - 3) {
0926         scrollDiff.left = 5;
0927         h.startScrolling(element, 'x');
0928       } else {
0929         scrollDiff.left = 0;
0930       }
0931 
0932       if (mousePosition.y < containerGeometry.top + 3) {
0933         if (containerGeometry.top + 3 - mousePosition.y < 5) {
0934           scrollDiff.top = -5;
0935         } else {
0936           scrollDiff.top = -20;
0937         }
0938         h.startScrolling(element, 'y');
0939       } else if (mousePosition.y > containerGeometry.bottom - 3) {
0940         if (mousePosition.y - containerGeometry.bottom + 3 < 5) {
0941           scrollDiff.top = 5;
0942         } else {
0943           scrollDiff.top = 20;
0944         }
0945         h.startScrolling(element, 'y');
0946       } else {
0947         scrollDiff.top = 0;
0948       }
0949 
0950       if (scrollDiff.top === 0 && scrollDiff.left === 0) {
0951         stopScrolling();
0952       } else {
0953         startScrolling();
0954       }
0955     }
0956   });
0957 }
0958 
0959 module.exports = function (element) {
0960   var i = instances.get(element);
0961   bindSelectionHandler(element, i);
0962 };
0963 
0964 },{"../../lib/helper":6,"../instances":18,"../update-geometry":19,"../update-scroll":20}],16:[function(require,module,exports){
0965 'use strict';
0966 
0967 var instances = require('../instances')
0968   , updateGeometry = require('../update-geometry')
0969   , updateScroll = require('../update-scroll');
0970 
0971 function bindTouchHandler(element, i, supportsTouch, supportsIePointer) {
0972   function shouldPreventDefault(deltaX, deltaY) {
0973     var scrollTop = element.scrollTop;
0974     var scrollLeft = element.scrollLeft;
0975     var magnitudeX = Math.abs(deltaX);
0976     var magnitudeY = Math.abs(deltaY);
0977 
0978     if (magnitudeY > magnitudeX) {
0979       // user is perhaps trying to swipe up/down the page

0980 
0981       if (((deltaY < 0) && (scrollTop === i.contentHeight - i.containerHeight)) ||
0982           ((deltaY > 0) && (scrollTop === 0))) {
0983         return !i.settings.swipePropagation;
0984       }
0985     } else if (magnitudeX > magnitudeY) {
0986       // user is perhaps trying to swipe left/right across the page

0987 
0988       if (((deltaX < 0) && (scrollLeft === i.contentWidth - i.containerWidth)) ||
0989           ((deltaX > 0) && (scrollLeft === 0))) {
0990         return !i.settings.swipePropagation;
0991       }
0992     }
0993 
0994     return true;
0995   }
0996 
0997   function applyTouchMove(differenceX, differenceY) {
0998     updateScroll(element, 'top', element.scrollTop - differenceY);
0999     updateScroll(element, 'left', element.scrollLeft - differenceX);
1000 
1001     updateGeometry(element);
1002   }
1003 
1004   var startOffset = {};
1005   var startTime = 0;
1006   var speed = {};
1007   var easingLoop = null;
1008   var inGlobalTouch = false;
1009   var inLocalTouch = false;
1010 
1011   function globalTouchStart() {
1012     inGlobalTouch = true;
1013   }
1014   function globalTouchEnd() {
1015     inGlobalTouch = false;
1016   }
1017 
1018   function getTouch(e) {
1019     if (e.targetTouches) {
1020       return e.targetTouches[0];
1021     } else {
1022       // Maybe IE pointer

1023       return e;
1024     }
1025   }
1026   function shouldHandle(e) {
1027     if (e.targetTouches && e.targetTouches.length === 1) {
1028       return true;
1029     }
1030     if (e.pointerType && e.pointerType !== 'mouse' && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
1031       return true;
1032     }
1033     return false;
1034   }
1035   function touchStart(e) {
1036     if (shouldHandle(e)) {
1037       inLocalTouch = true;
1038 
1039       var touch = getTouch(e);
1040 
1041       startOffset.pageX = touch.pageX;
1042       startOffset.pageY = touch.pageY;
1043 
1044       startTime = (new Date()).getTime();
1045 
1046       if (easingLoop !== null) {
1047         clearInterval(easingLoop);
1048       }
1049 
1050       e.stopPropagation();
1051     }
1052   }
1053   function touchMove(e) {
1054     if (!inGlobalTouch && inLocalTouch && shouldHandle(e)) {
1055       var touch = getTouch(e);
1056 
1057       var currentOffset = {pageX: touch.pageX, pageY: touch.pageY};
1058 
1059       var differenceX = currentOffset.pageX - startOffset.pageX;
1060       var differenceY = currentOffset.pageY - startOffset.pageY;
1061 
1062       applyTouchMove(differenceX, differenceY);
1063       startOffset = currentOffset;
1064 
1065       var currentTime = (new Date()).getTime();
1066 
1067       var timeGap = currentTime - startTime;
1068       if (timeGap > 0) {
1069         speed.x = differenceX / timeGap;
1070         speed.y = differenceY / timeGap;
1071         startTime = currentTime;
1072       }
1073 
1074       if (shouldPreventDefault(differenceX, differenceY)) {
1075         e.stopPropagation();
1076         e.preventDefault();
1077       }
1078     }
1079   }
1080   function touchEnd() {
1081     if (!inGlobalTouch && inLocalTouch) {
1082       inLocalTouch = false;
1083 
1084       clearInterval(easingLoop);
1085       easingLoop = setInterval(function () {
1086         if (!instances.get(element)) {
1087           clearInterval(easingLoop);
1088           return;
1089         }
1090 
1091         if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) {
1092           clearInterval(easingLoop);
1093           return;
1094         }
1095 
1096         applyTouchMove(speed.x * 30, speed.y * 30);
1097 
1098         speed.x *= 0.8;
1099         speed.y *= 0.8;
1100       }, 10);
1101     }
1102   }
1103 
1104   if (supportsTouch) {
1105     i.event.bind(window, 'touchstart', globalTouchStart);
1106     i.event.bind(window, 'touchend', globalTouchEnd);
1107     i.event.bind(element, 'touchstart', touchStart);
1108     i.event.bind(element, 'touchmove', touchMove);
1109     i.event.bind(element, 'touchend', touchEnd);
1110   }
1111 
1112   if (supportsIePointer) {
1113     if (window.PointerEvent) {
1114       i.event.bind(window, 'pointerdown', globalTouchStart);
1115       i.event.bind(window, 'pointerup', globalTouchEnd);
1116       i.event.bind(element, 'pointerdown', touchStart);
1117       i.event.bind(element, 'pointermove', touchMove);
1118       i.event.bind(element, 'pointerup', touchEnd);
1119     } else if (window.MSPointerEvent) {
1120       i.event.bind(window, 'MSPointerDown', globalTouchStart);
1121       i.event.bind(window, 'MSPointerUp', globalTouchEnd);
1122       i.event.bind(element, 'MSPointerDown', touchStart);
1123       i.event.bind(element, 'MSPointerMove', touchMove);
1124       i.event.bind(element, 'MSPointerUp', touchEnd);
1125     }
1126   }
1127 }
1128 
1129 module.exports = function (element, supportsTouch, supportsIePointer) {
1130   var i = instances.get(element);
1131   bindTouchHandler(element, i, supportsTouch, supportsIePointer);
1132 };
1133 
1134 },{"../instances":18,"../update-geometry":19,"../update-scroll":20}],17:[function(require,module,exports){
1135 'use strict';
1136 
1137 var cls = require('../lib/class')
1138   , h = require('../lib/helper')
1139   , instances = require('./instances')
1140   , updateGeometry = require('./update-geometry');
1141 
1142 // Handlers

1143 var clickRailHandler = require('./handler/click-rail')
1144   , dragScrollbarHandler = require('./handler/drag-scrollbar')
1145   , keyboardHandler = require('./handler/keyboard')
1146   , mouseWheelHandler = require('./handler/mouse-wheel')
1147   , nativeScrollHandler = require('./handler/native-scroll')
1148   , selectionHandler = require('./handler/selection')
1149   , touchHandler = require('./handler/touch');
1150 
1151 module.exports = function (element, userSettings) {
1152   userSettings = typeof userSettings === 'object' ? userSettings : {};
1153 
1154   cls.add(element, 'ps-container');
1155 
1156   // Create a plugin instance.

1157   var i = instances.add(element);
1158 
1159   i.settings = h.extend(i.settings, userSettings);
1160   cls.add(element, 'ps-theme-' + i.settings.theme);
1161 
1162   clickRailHandler(element);
1163   dragScrollbarHandler(element);
1164   mouseWheelHandler(element);
1165   nativeScrollHandler(element);
1166 
1167   if (i.settings.useSelectionScroll) {
1168     selectionHandler(element);
1169   }
1170 
1171   if (h.env.supportsTouch || h.env.supportsIePointer) {
1172     touchHandler(element, h.env.supportsTouch, h.env.supportsIePointer);
1173   }
1174   if (i.settings.useKeyboard) {
1175     keyboardHandler(element);
1176   }
1177 
1178   updateGeometry(element);
1179 };
1180 
1181 },{"../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){
1182 'use strict';
1183 
1184 var cls = require('../lib/class')
1185   , d = require('../lib/dom')
1186   , defaultSettings = require('./default-setting')
1187   , EventManager = require('../lib/event-manager')
1188   , guid = require('../lib/guid')
1189   , h = require('../lib/helper');
1190 
1191 var instances = {};
1192 
1193 function Instance(element) {
1194   var i = this;
1195 
1196   i.settings = h.clone(defaultSettings);
1197   i.containerWidth = null;
1198   i.containerHeight = null;
1199   i.contentWidth = null;
1200   i.contentHeight = null;
1201 
1202   i.isRtl = d.css(element, 'direction') === "rtl";
1203   i.isNegativeScroll = (function () {
1204     var originalScrollLeft = element.scrollLeft;
1205     var result = null;
1206     element.scrollLeft = -1;
1207     result = element.scrollLeft < 0;
1208     element.scrollLeft = originalScrollLeft;
1209     return result;
1210   })();
1211   i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1212   i.event = new EventManager();
1213   i.ownerDocument = element.ownerDocument || document;
1214 
1215   function focus() {
1216     cls.add(element, 'ps-focus');
1217   }
1218 
1219   function blur() {
1220     cls.remove(element, 'ps-focus');
1221   }
1222 
1223   i.scrollbarXRail = d.appendTo(d.e('div', 'ps-scrollbar-x-rail'), element);
1224   i.scrollbarX = d.appendTo(d.e('div', 'ps-scrollbar-x'), i.scrollbarXRail);
1225   i.scrollbarX.setAttribute('tabindex', 0);
1226   i.event.bind(i.scrollbarX, 'focus', focus);
1227   i.event.bind(i.scrollbarX, 'blur', blur);
1228   i.scrollbarXActive = null;
1229   i.scrollbarXWidth = null;
1230   i.scrollbarXLeft = null;
1231   i.scrollbarXBottom = h.toInt(d.css(i.scrollbarXRail, 'bottom'));
1232   i.isScrollbarXUsingBottom = i.scrollbarXBottom === i.scrollbarXBottom; // !isNaN

1233   i.scrollbarXTop = i.isScrollbarXUsingBottom ? null : h.toInt(d.css(i.scrollbarXRail, 'top'));
1234   i.railBorderXWidth = h.toInt(d.css(i.scrollbarXRail, 'borderLeftWidth')) + h.toInt(d.css(i.scrollbarXRail, 'borderRightWidth'));
1235   // Set rail to display:block to calculate margins

1236   d.css(i.scrollbarXRail, 'display', 'block');
1237   i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight'));
1238   d.css(i.scrollbarXRail, 'display', '');
1239   i.railXWidth = null;
1240   i.railXRatio = null;
1241 
1242   i.scrollbarYRail = d.appendTo(d.e('div', 'ps-scrollbar-y-rail'), element);
1243   i.scrollbarY = d.appendTo(d.e('div', 'ps-scrollbar-y'), i.scrollbarYRail);
1244   i.scrollbarY.setAttribute('tabindex', 0);
1245   i.event.bind(i.scrollbarY, 'focus', focus);
1246   i.event.bind(i.scrollbarY, 'blur', blur);
1247   i.scrollbarYActive = null;
1248   i.scrollbarYHeight = null;
1249   i.scrollbarYTop = null;
1250   i.scrollbarYRight = h.toInt(d.css(i.scrollbarYRail, 'right'));
1251   i.isScrollbarYUsingRight = i.scrollbarYRight === i.scrollbarYRight; // !isNaN

1252   i.scrollbarYLeft = i.isScrollbarYUsingRight ? null : h.toInt(d.css(i.scrollbarYRail, 'left'));
1253   i.scrollbarYOuterWidth = i.isRtl ? h.outerWidth(i.scrollbarY) : null;
1254   i.railBorderYWidth = h.toInt(d.css(i.scrollbarYRail, 'borderTopWidth')) + h.toInt(d.css(i.scrollbarYRail, 'borderBottomWidth'));
1255   d.css(i.scrollbarYRail, 'display', 'block');
1256   i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
1257   d.css(i.scrollbarYRail, 'display', '');
1258   i.railYHeight = null;
1259   i.railYRatio = null;
1260 }
1261 
1262 function getId(element) {
1263   if (typeof element.dataset === 'undefined') {
1264     return element.getAttribute('data-ps-id');
1265   } else {
1266     return element.dataset.psId;
1267   }
1268 }
1269 
1270 function setId(element, id) {
1271   if (typeof element.dataset === 'undefined') {
1272     element.setAttribute('data-ps-id', id);
1273   } else {
1274     element.dataset.psId = id;
1275   }
1276 }
1277 
1278 function removeId(element) {
1279   if (typeof element.dataset === 'undefined') {
1280     element.removeAttribute('data-ps-id');
1281   } else {
1282     delete element.dataset.psId;
1283   }
1284 }
1285 
1286 exports.add = function (element) {
1287   var newId = guid();
1288   setId(element, newId);
1289   instances[newId] = new Instance(element);
1290   return instances[newId];
1291 };
1292 
1293 exports.remove = function (element) {
1294   delete instances[getId(element)];
1295   removeId(element);
1296 };
1297 
1298 exports.get = function (element) {
1299   return instances[getId(element)];
1300 };
1301 
1302 },{"../lib/class":2,"../lib/dom":3,"../lib/event-manager":4,"../lib/guid":5,"../lib/helper":6,"./default-setting":8}],19:[function(require,module,exports){
1303 'use strict';
1304 
1305 var cls = require('../lib/class')
1306   , d = require('../lib/dom')
1307   , h = require('../lib/helper')
1308   , instances = require('./instances')
1309   , updateScroll = require('./update-scroll');
1310 
1311 function getThumbSize(i, thumbSize) {
1312   if (i.settings.minScrollbarLength) {
1313     thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength);
1314   }
1315   if (i.settings.maxScrollbarLength) {
1316     thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength);
1317   }
1318   return thumbSize;
1319 }
1320 
1321 function updateCss(element, i) {
1322   var xRailOffset = {width: i.railXWidth};
1323   if (i.isRtl) {
1324     xRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth - i.contentWidth;
1325   } else {
1326     xRailOffset.left = element.scrollLeft;
1327   }
1328   if (i.isScrollbarXUsingBottom) {
1329     xRailOffset.bottom = i.scrollbarXBottom - element.scrollTop;
1330   } else {
1331     xRailOffset.top = i.scrollbarXTop + element.scrollTop;
1332   }
1333   d.css(i.scrollbarXRail, xRailOffset);
1334 
1335   var yRailOffset = {top: element.scrollTop, height: i.railYHeight};
1336   if (i.isScrollbarYUsingRight) {
1337     if (i.isRtl) {
1338       yRailOffset.right = i.contentWidth - (i.negativeScrollAdjustment + element.scrollLeft) - i.scrollbarYRight - i.scrollbarYOuterWidth;
1339     } else {
1340       yRailOffset.right = i.scrollbarYRight - element.scrollLeft;
1341     }
1342   } else {
1343     if (i.isRtl) {
1344       yRailOffset.left = i.negativeScrollAdjustment + element.scrollLeft + i.containerWidth * 2 - i.contentWidth - i.scrollbarYLeft - i.scrollbarYOuterWidth;
1345     } else {
1346       yRailOffset.left = i.scrollbarYLeft + element.scrollLeft;
1347     }
1348   }
1349   d.css(i.scrollbarYRail, yRailOffset);
1350 
1351   d.css(i.scrollbarX, {left: i.scrollbarXLeft, width: i.scrollbarXWidth - i.railBorderXWidth});
1352   d.css(i.scrollbarY, {top: i.scrollbarYTop, height: i.scrollbarYHeight - i.railBorderYWidth});
1353 }
1354 
1355 module.exports = function (element) {
1356   var i = instances.get(element);
1357 
1358   i.containerWidth = element.clientWidth;
1359   i.containerHeight = element.clientHeight;
1360   i.contentWidth = element.scrollWidth;
1361   i.contentHeight = element.scrollHeight;
1362 
1363   var existingRails;
1364   if (!element.contains(i.scrollbarXRail)) {
1365     existingRails = d.queryChildren(element, '.ps-scrollbar-x-rail');
1366     if (existingRails.length > 0) {
1367       existingRails.forEach(function (rail) {
1368         d.remove(rail);
1369       });
1370     }
1371     d.appendTo(i.scrollbarXRail, element);
1372   }
1373   if (!element.contains(i.scrollbarYRail)) {
1374     existingRails = d.queryChildren(element, '.ps-scrollbar-y-rail');
1375     if (existingRails.length > 0) {
1376       existingRails.forEach(function (rail) {
1377         d.remove(rail);
1378       });
1379     }
1380     d.appendTo(i.scrollbarYRail, element);
1381   }
1382 
1383   if (!i.settings.suppressScrollX && i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth) {
1384     i.scrollbarXActive = true;
1385     i.railXWidth = i.containerWidth - i.railXMarginWidth;
1386     i.railXRatio = i.containerWidth / i.railXWidth;
1387     i.scrollbarXWidth = getThumbSize(i, h.toInt(i.railXWidth * i.containerWidth / i.contentWidth));
1388     i.scrollbarXLeft = h.toInt((i.negativeScrollAdjustment + element.scrollLeft) * (i.railXWidth - i.scrollbarXWidth) / (i.contentWidth - i.containerWidth));
1389   } else {
1390     i.scrollbarXActive = false;
1391   }
1392 
1393   if (!i.settings.suppressScrollY && i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight) {
1394     i.scrollbarYActive = true;
1395     i.railYHeight = i.containerHeight - i.railYMarginHeight;
1396     i.railYRatio = i.containerHeight / i.railYHeight;
1397     i.scrollbarYHeight = getThumbSize(i, h.toInt(i.railYHeight * i.containerHeight / i.contentHeight));
1398     i.scrollbarYTop = h.toInt(element.scrollTop * (i.railYHeight - i.scrollbarYHeight) / (i.contentHeight - i.containerHeight));
1399   } else {
1400     i.scrollbarYActive = false;
1401   }
1402 
1403   if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) {
1404     i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth;
1405   }
1406   if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) {
1407     i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight;
1408   }
1409 
1410   updateCss(element, i);
1411 
1412   if (i.scrollbarXActive) {
1413     cls.add(element, 'ps-active-x');
1414   } else {
1415     cls.remove(element, 'ps-active-x');
1416     i.scrollbarXWidth = 0;
1417     i.scrollbarXLeft = 0;
1418     updateScroll(element, 'left', 0);
1419   }
1420   if (i.scrollbarYActive) {
1421     cls.add(element, 'ps-active-y');
1422   } else {
1423     cls.remove(element, 'ps-active-y');
1424     i.scrollbarYHeight = 0;
1425     i.scrollbarYTop = 0;
1426     updateScroll(element, 'top', 0);
1427   }
1428 };
1429 
1430 },{"../lib/class":2,"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-scroll":20}],20:[function(require,module,exports){
1431 'use strict';
1432 
1433 var instances = require('./instances');
1434 
1435 var upEvent = document.createEvent('Event')
1436   , downEvent = document.createEvent('Event')
1437   , leftEvent = document.createEvent('Event')
1438   , rightEvent = document.createEvent('Event')
1439   , yEvent = document.createEvent('Event')
1440   , xEvent = document.createEvent('Event')
1441   , xStartEvent = document.createEvent('Event')
1442   , xEndEvent = document.createEvent('Event')
1443   , yStartEvent = document.createEvent('Event')
1444   , yEndEvent = document.createEvent('Event')
1445   , lastTop
1446   , lastLeft;
1447 
1448 upEvent.initEvent('ps-scroll-up', true, true);
1449 downEvent.initEvent('ps-scroll-down', true, true);
1450 leftEvent.initEvent('ps-scroll-left', true, true);
1451 rightEvent.initEvent('ps-scroll-right', true, true);
1452 yEvent.initEvent('ps-scroll-y', true, true);
1453 xEvent.initEvent('ps-scroll-x', true, true);
1454 xStartEvent.initEvent('ps-x-reach-start', true, true);
1455 xEndEvent.initEvent('ps-x-reach-end', true, true);
1456 yStartEvent.initEvent('ps-y-reach-start', true, true);
1457 yEndEvent.initEvent('ps-y-reach-end', true, true);
1458 
1459 module.exports = function (element, axis, value) {
1460   if (typeof element === 'undefined') {
1461     throw 'You must provide an element to the update-scroll function';
1462   }
1463 
1464   if (typeof axis === 'undefined') {
1465     throw 'You must provide an axis to the update-scroll function';
1466   }
1467 
1468   if (typeof value === 'undefined') {
1469     throw 'You must provide a value to the update-scroll function';
1470   }
1471 
1472   if (axis === 'top' && value <= 0) {
1473     element.scrollTop = value = 0; // don't allow negative scroll

1474     element.dispatchEvent(yStartEvent);
1475   }
1476 
1477   if (axis === 'left' && value <= 0) {
1478     element.scrollLeft = value = 0; // don't allow negative scroll

1479     element.dispatchEvent(xStartEvent);
1480   }
1481 
1482   var i = instances.get(element);
1483 
1484   if (axis === 'top' && value >= i.contentHeight - i.containerHeight) {
1485     element.scrollTop = value = i.contentHeight - i.containerHeight; // don't allow scroll past container

1486     element.dispatchEvent(yEndEvent);
1487   }
1488 
1489   if (axis === 'left' && value >= i.contentWidth - i.containerWidth) {
1490     element.scrollLeft = value = i.contentWidth - i.containerWidth; // don't allow scroll past container

1491     element.dispatchEvent(xEndEvent);
1492   }
1493 
1494   if (!lastTop) {
1495     lastTop = element.scrollTop;
1496   }
1497 
1498   if (!lastLeft) {
1499     lastLeft = element.scrollLeft;
1500   }
1501 
1502   if (axis === 'top' && value < lastTop) {
1503     element.dispatchEvent(upEvent);
1504   }
1505 
1506   if (axis === 'top' && value > lastTop) {
1507     element.dispatchEvent(downEvent);
1508   }
1509 
1510   if (axis === 'left' && value < lastLeft) {
1511     element.dispatchEvent(leftEvent);
1512   }
1513 
1514   if (axis === 'left' && value > lastLeft) {
1515     element.dispatchEvent(rightEvent);
1516   }
1517 
1518   if (axis === 'top') {
1519     element.scrollTop = lastTop = value;
1520     element.dispatchEvent(yEvent);
1521   }
1522 
1523   if (axis === 'left') {
1524     element.scrollLeft = lastLeft = value;
1525     element.dispatchEvent(xEvent);
1526   }
1527 
1528 };
1529 
1530 },{"./instances":18}],21:[function(require,module,exports){
1531 'use strict';
1532 
1533 var d = require('../lib/dom')
1534   , h = require('../lib/helper')
1535   , instances = require('./instances')
1536   , updateGeometry = require('./update-geometry')
1537   , updateScroll = require('./update-scroll');
1538 
1539 module.exports = function (element) {
1540   var i = instances.get(element);
1541 
1542   if (!i) {
1543     return;
1544   }
1545 
1546   // Recalcuate negative scrollLeft adjustment

1547   i.negativeScrollAdjustment = i.isNegativeScroll ? element.scrollWidth - element.clientWidth : 0;
1548 
1549   // Recalculate rail margins

1550   d.css(i.scrollbarXRail, 'display', 'block');
1551   d.css(i.scrollbarYRail, 'display', 'block');
1552   i.railXMarginWidth = h.toInt(d.css(i.scrollbarXRail, 'marginLeft')) + h.toInt(d.css(i.scrollbarXRail, 'marginRight'));
1553   i.railYMarginHeight = h.toInt(d.css(i.scrollbarYRail, 'marginTop')) + h.toInt(d.css(i.scrollbarYRail, 'marginBottom'));
1554 
1555   // Hide scrollbars not to affect scrollWidth and scrollHeight

1556   d.css(i.scrollbarXRail, 'display', 'none');
1557   d.css(i.scrollbarYRail, 'display', 'none');
1558 
1559   updateGeometry(element);
1560 
1561   // Update top/left scroll to trigger events

1562   updateScroll(element, 'top', element.scrollTop);
1563   updateScroll(element, 'left', element.scrollLeft);
1564 
1565   d.css(i.scrollbarXRail, 'display', '');
1566   d.css(i.scrollbarYRail, 'display', '');
1567 };
1568 
1569 },{"../lib/dom":3,"../lib/helper":6,"./instances":18,"./update-geometry":19,"./update-scroll":20}]},{},[1]);