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