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