diff --git a/dist/vue2-perfect-scrollbar.umd.js b/dist/vue2-perfect-scrollbar.umd.js index 654adfb..f3011ea 100644 --- a/dist/vue2-perfect-scrollbar.umd.js +++ b/dist/vue2-perfect-scrollbar.umd.js @@ -5,242 +5,242 @@ }(this, (function (exports) { 'use strict'; /*! - * perfect-scrollbar v1.5.0 - * Copyright 2020 Hyunje Jun, MDBootstrap and Contributors + * perfect-scrollbar v1.5.2 + * Copyright 2021 Hyunje Jun, MDBootstrap and Contributors * Licensed under MIT */ - function get(element) { - return getComputedStyle(element); + function get(element) { + return getComputedStyle(element); + } + + function set(element, obj) { + for (var key in obj) { + var val = obj[key]; + if (typeof val === 'number') { + val = val + "px"; + } + element.style[key] = val; + } + return element; } - function set(element, obj) { - for (var key in obj) { - var val = obj[key]; - if (typeof val === 'number') { - val = val + "px"; - } - element.style[key] = val; - } - return element; - } - - function div(className) { - var div = document.createElement('div'); - div.className = className; - return div; + function div(className) { + var div = document.createElement('div'); + div.className = className; + return div; + } + + var elMatches = + typeof Element !== 'undefined' && + (Element.prototype.matches || + Element.prototype.webkitMatchesSelector || + Element.prototype.mozMatchesSelector || + Element.prototype.msMatchesSelector); + + function matches(element, query) { + if (!elMatches) { + throw new Error('No element matching method supported'); + } + + return elMatches.call(element, query); + } + + function remove(element) { + if (element.remove) { + element.remove(); + } else { + if (element.parentNode) { + element.parentNode.removeChild(element); + } + } + } + + function queryChildren(element, selector) { + return Array.prototype.filter.call(element.children, function (child) { return matches(child, selector); } + ); } - var elMatches = - typeof Element !== 'undefined' && - (Element.prototype.matches || - Element.prototype.webkitMatchesSelector || - Element.prototype.mozMatchesSelector || - Element.prototype.msMatchesSelector); - - function matches(element, query) { - if (!elMatches) { - throw new Error('No element matching method supported'); - } - - return elMatches.call(element, query); - } - - function remove(element) { - if (element.remove) { - element.remove(); - } else { - if (element.parentNode) { - element.parentNode.removeChild(element); - } - } + var cls = { + main: 'ps', + rtl: 'ps__rtl', + element: { + thumb: function (x) { return ("ps__thumb-" + x); }, + rail: function (x) { return ("ps__rail-" + x); }, + consuming: 'ps__child--consume', + }, + state: { + focus: 'ps--focus', + clicking: 'ps--clicking', + active: function (x) { return ("ps--active-" + x); }, + scrolling: function (x) { return ("ps--scrolling-" + x); }, + }, + }; + + /* + * Helper methods + */ + var scrollingClassTimeout = { x: null, y: null }; + + function addScrollingClass(i, x) { + var classList = i.element.classList; + var className = cls.state.scrolling(x); + + if (classList.contains(className)) { + clearTimeout(scrollingClassTimeout[x]); + } else { + classList.add(className); + } + } + + function removeScrollingClass(i, x) { + scrollingClassTimeout[x] = setTimeout( + function () { return i.isAlive && i.element.classList.remove(cls.state.scrolling(x)); }, + i.settings.scrollingThreshold + ); + } + + function setScrollingClassInstantly(i, x) { + addScrollingClass(i, x); + removeScrollingClass(i, x); } - function queryChildren(element, selector) { - return Array.prototype.filter.call(element.children, function (child) { return matches(child, selector); } - ); - } - - var cls = { - main: 'ps', - rtl: 'ps__rtl', - element: { - thumb: function (x) { return ("ps__thumb-" + x); }, - rail: function (x) { return ("ps__rail-" + x); }, - consuming: 'ps__child--consume', - }, - state: { - focus: 'ps--focus', - clicking: 'ps--clicking', - active: function (x) { return ("ps--active-" + x); }, - scrolling: function (x) { return ("ps--scrolling-" + x); }, - }, - }; - - /* - * Helper methods - */ - var scrollingClassTimeout = { x: null, y: null }; - - function addScrollingClass(i, x) { - var classList = i.element.classList; - var className = cls.state.scrolling(x); - - if (classList.contains(className)) { - clearTimeout(scrollingClassTimeout[x]); - } else { - classList.add(className); - } - } - - function removeScrollingClass(i, x) { - scrollingClassTimeout[x] = setTimeout( - function () { return i.isAlive && i.element.classList.remove(cls.state.scrolling(x)); }, - i.settings.scrollingThreshold - ); - } - - function setScrollingClassInstantly(i, x) { - addScrollingClass(i, x); - removeScrollingClass(i, x); - } - - var EventElement = function EventElement(element) { - this.element = element; - this.handlers = {}; - }; - - var prototypeAccessors = { isEmpty: { configurable: true } }; - - EventElement.prototype.bind = function bind (eventName, handler) { - if (typeof this.handlers[eventName] === 'undefined') { - this.handlers[eventName] = []; - } - this.handlers[eventName].push(handler); - this.element.addEventListener(eventName, handler, false); + var EventElement = function EventElement(element) { + this.element = element; + this.handlers = {}; }; + var prototypeAccessors = { isEmpty: { configurable: true } }; + + EventElement.prototype.bind = function bind (eventName, handler) { + if (typeof this.handlers[eventName] === 'undefined') { + this.handlers[eventName] = []; + } + this.handlers[eventName].push(handler); + this.element.addEventListener(eventName, handler, false); + }; + EventElement.prototype.unbind = function unbind (eventName, target) { var this$1 = this; - - this.handlers[eventName] = this.handlers[eventName].filter(function (handler) { - if (target && handler !== target) { - return true; - } - this$1.element.removeEventListener(eventName, handler, false); - return false; - }); - }; - + + this.handlers[eventName] = this.handlers[eventName].filter(function (handler) { + if (target && handler !== target) { + return true; + } + this$1.element.removeEventListener(eventName, handler, false); + return false; + }); + }; + EventElement.prototype.unbindAll = function unbindAll () { var this$1 = this; - - for (var name in this$1.handlers) { - this$1.unbind(name); - } - }; - + + for (var name in this$1.handlers) { + this$1.unbind(name); + } + }; + prototypeAccessors.isEmpty.get = function () { var this$1 = this; - - return Object.keys(this.handlers).every( - function (key) { return this$1.handlers[key].length === 0; } - ); - }; - - Object.defineProperties( EventElement.prototype, prototypeAccessors ); - - var EventManager = function EventManager() { - this.eventElements = []; + + return Object.keys(this.handlers).every( + function (key) { return this$1.handlers[key].length === 0; } + ); }; - EventManager.prototype.eventElement = function eventElement (element) { - var ee = this.eventElements.filter(function (ee) { return ee.element === element; })[0]; - if (!ee) { - ee = new EventElement(element); - this.eventElements.push(ee); - } - return ee; + Object.defineProperties( EventElement.prototype, prototypeAccessors ); + + var EventManager = function EventManager() { + this.eventElements = []; + }; + + EventManager.prototype.eventElement = function eventElement (element) { + var ee = this.eventElements.filter(function (ee) { return ee.element === element; })[0]; + if (!ee) { + ee = new EventElement(element); + this.eventElements.push(ee); + } + return ee; + }; + + EventManager.prototype.bind = function bind (element, eventName, handler) { + this.eventElement(element).bind(eventName, handler); + }; + + EventManager.prototype.unbind = function unbind (element, eventName, handler) { + var ee = this.eventElement(element); + ee.unbind(eventName, handler); + + if (ee.isEmpty) { + // remove + this.eventElements.splice(this.eventElements.indexOf(ee), 1); + } + }; + + EventManager.prototype.unbindAll = function unbindAll () { + this.eventElements.forEach(function (e) { return e.unbindAll(); }); + this.eventElements = []; + }; + + EventManager.prototype.once = function once (element, eventName, handler) { + var ee = this.eventElement(element); + var onceHandler = function (evt) { + ee.unbind(eventName, onceHandler); + handler(evt); + }; + ee.bind(eventName, onceHandler); }; - EventManager.prototype.bind = function bind (element, eventName, handler) { - this.eventElement(element).bind(eventName, handler); - }; - - EventManager.prototype.unbind = function unbind (element, eventName, handler) { - var ee = this.eventElement(element); - ee.unbind(eventName, handler); - - if (ee.isEmpty) { - // remove - this.eventElements.splice(this.eventElements.indexOf(ee), 1); - } - }; - - EventManager.prototype.unbindAll = function unbindAll () { - this.eventElements.forEach(function (e) { return e.unbindAll(); }); - this.eventElements = []; - }; - - EventManager.prototype.once = function once (element, eventName, handler) { - var ee = this.eventElement(element); - var onceHandler = function (evt) { - ee.unbind(eventName, onceHandler); - handler(evt); - }; - ee.bind(eventName, onceHandler); - }; - - function createEvent(name) { - if (typeof window.CustomEvent === 'function') { - return new CustomEvent(name); - } else { - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent(name, false, false, undefined); - return evt; - } - } - - function processScrollDiff( - i, - axis, - diff, - useScrollingClass, - forceFireReachEvent + function createEvent(name) { + if (typeof window.CustomEvent === 'function') { + return new CustomEvent(name); + } else { + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(name, false, false, undefined); + return evt; + } + } + + function processScrollDiff( + i, + axis, + diff, + useScrollingClass, + forceFireReachEvent ) { if ( useScrollingClass === void 0 ) { useScrollingClass = true; } if ( forceFireReachEvent === void 0 ) { forceFireReachEvent = false; } - - var fields; - if (axis === 'top') { - fields = [ - 'contentHeight', - 'containerHeight', - 'scrollTop', - 'y', - 'up', - 'down' ]; - } else if (axis === 'left') { - fields = [ - 'contentWidth', - 'containerWidth', - 'scrollLeft', - 'x', - 'left', - 'right' ]; - } else { - throw new Error('A proper axis should be provided'); - } - - processScrollDiff$1(i, diff, fields, useScrollingClass, forceFireReachEvent); - } - - function processScrollDiff$1( - i, - diff, - ref, - useScrollingClass, - forceFireReachEvent + + var fields; + if (axis === 'top') { + fields = [ + 'contentHeight', + 'containerHeight', + 'scrollTop', + 'y', + 'up', + 'down' ]; + } else if (axis === 'left') { + fields = [ + 'contentWidth', + 'containerWidth', + 'scrollLeft', + 'x', + 'left', + 'right' ]; + } else { + throw new Error('A proper axis should be provided'); + } + + processScrollDiff$1(i, diff, fields, useScrollingClass, forceFireReachEvent); + } + + function processScrollDiff$1( + i, + diff, + ref, + useScrollingClass, + forceFireReachEvent ) { var contentHeight = ref[0]; var containerHeight = ref[1]; @@ -250,296 +250,297 @@ var down = ref[5]; if ( useScrollingClass === void 0 ) { useScrollingClass = true; } if ( forceFireReachEvent === void 0 ) { forceFireReachEvent = false; } - - var element = i.element; - - // reset reach - i.reach[y] = null; - - // 1 for subpixel rounding - if (element[scrollTop] < 1) { - i.reach[y] = 'start'; - } - - // 1 for subpixel rounding - if (element[scrollTop] > i[contentHeight] - i[containerHeight] - 1) { - i.reach[y] = 'end'; - } - - if (diff) { - element.dispatchEvent(createEvent(("ps-scroll-" + y))); - - if (diff < 0) { - element.dispatchEvent(createEvent(("ps-scroll-" + up))); - } else if (diff > 0) { - element.dispatchEvent(createEvent(("ps-scroll-" + down))); - } - - if (useScrollingClass) { - setScrollingClassInstantly(i, y); - } - } - - if (i.reach[y] && (diff || forceFireReachEvent)) { - element.dispatchEvent(createEvent(("ps-" + y + "-reach-" + (i.reach[y])))); - } + + var element = i.element; + + // reset reach + i.reach[y] = null; + + // 1 for subpixel rounding + if (element[scrollTop] < 1) { + i.reach[y] = 'start'; + } + + // 1 for subpixel rounding + if (element[scrollTop] > i[contentHeight] - i[containerHeight] - 1) { + i.reach[y] = 'end'; + } + + if (diff) { + element.dispatchEvent(createEvent(("ps-scroll-" + y))); + + if (diff < 0) { + element.dispatchEvent(createEvent(("ps-scroll-" + up))); + } else if (diff > 0) { + element.dispatchEvent(createEvent(("ps-scroll-" + down))); + } + + if (useScrollingClass) { + setScrollingClassInstantly(i, y); + } + } + + if (i.reach[y] && (diff || forceFireReachEvent)) { + element.dispatchEvent(createEvent(("ps-" + y + "-reach-" + (i.reach[y])))); + } } - function toInt(x) { - return parseInt(x, 10) || 0; - } - - function isEditable(el) { - return ( - matches(el, 'input,[contenteditable]') || - matches(el, 'select,[contenteditable]') || - matches(el, 'textarea,[contenteditable]') || - matches(el, 'button,[contenteditable]') - ); - } - - function outerWidth(element) { - var styles = get(element); - return ( - toInt(styles.width) + - toInt(styles.paddingLeft) + - toInt(styles.paddingRight) + - toInt(styles.borderLeftWidth) + - toInt(styles.borderRightWidth) - ); - } - - var env = { - isWebKit: - typeof document !== 'undefined' && - 'WebkitAppearance' in document.documentElement.style, - supportsTouch: - typeof window !== 'undefined' && - ('ontouchstart' in window || - ('maxTouchPoints' in window.navigator && - window.navigator.maxTouchPoints > 0) || - (window.DocumentTouch && document instanceof window.DocumentTouch)), - supportsIePointer: - typeof navigator !== 'undefined' && navigator.msMaxTouchPoints, - isChrome: - typeof navigator !== 'undefined' && - /Chrome/i.test(navigator && navigator.userAgent), + function toInt(x) { + return parseInt(x, 10) || 0; + } + + function isEditable(el) { + return ( + matches(el, 'input,[contenteditable]') || + matches(el, 'select,[contenteditable]') || + matches(el, 'textarea,[contenteditable]') || + matches(el, 'button,[contenteditable]') + ); + } + + function outerWidth(element) { + var styles = get(element); + return ( + toInt(styles.width) + + toInt(styles.paddingLeft) + + toInt(styles.paddingRight) + + toInt(styles.borderLeftWidth) + + toInt(styles.borderRightWidth) + ); + } + + var env = { + isWebKit: + typeof document !== 'undefined' && + 'WebkitAppearance' in document.documentElement.style, + supportsTouch: + typeof window !== 'undefined' && + ('ontouchstart' in window || + ('maxTouchPoints' in window.navigator && + window.navigator.maxTouchPoints > 0) || + (window.DocumentTouch && document instanceof window.DocumentTouch)), + supportsIePointer: + typeof navigator !== 'undefined' && navigator.msMaxTouchPoints, + isChrome: + typeof navigator !== 'undefined' && + /Chrome/i.test(navigator && navigator.userAgent), }; - function updateGeometry(i) { - var element = i.element; - var roundedScrollTop = Math.floor(element.scrollTop); - var rect = element.getBoundingClientRect(); - - i.containerWidth = Math.ceil(rect.width); - i.containerHeight = Math.ceil(rect.height); - i.contentWidth = element.scrollWidth; - i.contentHeight = element.scrollHeight; - - if (!element.contains(i.scrollbarXRail)) { - // clean up and append - queryChildren(element, cls.element.rail('x')).forEach(function (el) { return remove(el); } - ); - element.appendChild(i.scrollbarXRail); - } - if (!element.contains(i.scrollbarYRail)) { - // clean up and append - queryChildren(element, cls.element.rail('y')).forEach(function (el) { return remove(el); } - ); - element.appendChild(i.scrollbarYRail); - } - - if ( - !i.settings.suppressScrollX && - i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth - ) { - i.scrollbarXActive = true; - i.railXWidth = i.containerWidth - i.railXMarginWidth; - i.railXRatio = i.containerWidth / i.railXWidth; - i.scrollbarXWidth = getThumbSize( - i, - toInt((i.railXWidth * i.containerWidth) / i.contentWidth) - ); - i.scrollbarXLeft = toInt( - ((i.negativeScrollAdjustment + element.scrollLeft) * - (i.railXWidth - i.scrollbarXWidth)) / - (i.contentWidth - i.containerWidth) - ); - } else { - i.scrollbarXActive = false; - } - - if ( - !i.settings.suppressScrollY && - i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight - ) { - i.scrollbarYActive = true; - i.railYHeight = i.containerHeight - i.railYMarginHeight; - i.railYRatio = i.containerHeight / i.railYHeight; - i.scrollbarYHeight = getThumbSize( - i, - toInt((i.railYHeight * i.containerHeight) / i.contentHeight) - ); - i.scrollbarYTop = toInt( - (roundedScrollTop * (i.railYHeight - i.scrollbarYHeight)) / - (i.contentHeight - i.containerHeight) - ); - } else { - i.scrollbarYActive = false; - } - - if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) { - i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth; - } - if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) { - i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight; - } - - updateCss(element, i); - - if (i.scrollbarXActive) { - element.classList.add(cls.state.active('x')); - } else { - element.classList.remove(cls.state.active('x')); - i.scrollbarXWidth = 0; - i.scrollbarXLeft = 0; - element.scrollLeft = i.isRtl === true ? i.contentWidth : 0; - } - if (i.scrollbarYActive) { - element.classList.add(cls.state.active('y')); - } else { - element.classList.remove(cls.state.active('y')); - i.scrollbarYHeight = 0; - i.scrollbarYTop = 0; - element.scrollTop = 0; - } + function updateGeometry(i) { + var element = i.element; + var roundedScrollTop = Math.floor(element.scrollTop); + var rect = element.getBoundingClientRect(); + + i.containerWidth = Math.round(rect.width); + i.containerHeight = Math.round(rect.height); + + i.contentWidth = element.scrollWidth; + i.contentHeight = element.scrollHeight; + + if (!element.contains(i.scrollbarXRail)) { + // clean up and append + queryChildren(element, cls.element.rail('x')).forEach(function (el) { return remove(el); } + ); + element.appendChild(i.scrollbarXRail); + } + if (!element.contains(i.scrollbarYRail)) { + // clean up and append + queryChildren(element, cls.element.rail('y')).forEach(function (el) { return remove(el); } + ); + element.appendChild(i.scrollbarYRail); + } + + if ( + !i.settings.suppressScrollX && + i.containerWidth + i.settings.scrollXMarginOffset < i.contentWidth + ) { + i.scrollbarXActive = true; + i.railXWidth = i.containerWidth - i.railXMarginWidth; + i.railXRatio = i.containerWidth / i.railXWidth; + i.scrollbarXWidth = getThumbSize( + i, + toInt((i.railXWidth * i.containerWidth) / i.contentWidth) + ); + i.scrollbarXLeft = toInt( + ((i.negativeScrollAdjustment + element.scrollLeft) * + (i.railXWidth - i.scrollbarXWidth)) / + (i.contentWidth - i.containerWidth) + ); + } else { + i.scrollbarXActive = false; + } + + if ( + !i.settings.suppressScrollY && + i.containerHeight + i.settings.scrollYMarginOffset < i.contentHeight + ) { + i.scrollbarYActive = true; + i.railYHeight = i.containerHeight - i.railYMarginHeight; + i.railYRatio = i.containerHeight / i.railYHeight; + i.scrollbarYHeight = getThumbSize( + i, + toInt((i.railYHeight * i.containerHeight) / i.contentHeight) + ); + i.scrollbarYTop = toInt( + (roundedScrollTop * (i.railYHeight - i.scrollbarYHeight)) / + (i.contentHeight - i.containerHeight) + ); + } else { + i.scrollbarYActive = false; + } + + if (i.scrollbarXLeft >= i.railXWidth - i.scrollbarXWidth) { + i.scrollbarXLeft = i.railXWidth - i.scrollbarXWidth; + } + if (i.scrollbarYTop >= i.railYHeight - i.scrollbarYHeight) { + i.scrollbarYTop = i.railYHeight - i.scrollbarYHeight; + } + + updateCss(element, i); + + if (i.scrollbarXActive) { + element.classList.add(cls.state.active('x')); + } else { + element.classList.remove(cls.state.active('x')); + i.scrollbarXWidth = 0; + i.scrollbarXLeft = 0; + element.scrollLeft = i.isRtl === true ? i.contentWidth : 0; + } + if (i.scrollbarYActive) { + element.classList.add(cls.state.active('y')); + } else { + element.classList.remove(cls.state.active('y')); + i.scrollbarYHeight = 0; + i.scrollbarYTop = 0; + element.scrollTop = 0; + } + } + + function getThumbSize(i, thumbSize) { + if (i.settings.minScrollbarLength) { + thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength); + } + if (i.settings.maxScrollbarLength) { + thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength); + } + return thumbSize; + } + + function updateCss(element, i) { + var xRailOffset = { width: i.railXWidth }; + var roundedScrollTop = Math.floor(element.scrollTop); + + if (i.isRtl) { + xRailOffset.left = + i.negativeScrollAdjustment + + element.scrollLeft + + i.containerWidth - + i.contentWidth; + } else { + xRailOffset.left = element.scrollLeft; + } + if (i.isScrollbarXUsingBottom) { + xRailOffset.bottom = i.scrollbarXBottom - roundedScrollTop; + } else { + xRailOffset.top = i.scrollbarXTop + roundedScrollTop; + } + set(i.scrollbarXRail, xRailOffset); + + var yRailOffset = { top: roundedScrollTop, height: i.railYHeight }; + if (i.isScrollbarYUsingRight) { + if (i.isRtl) { + yRailOffset.right = + i.contentWidth - + (i.negativeScrollAdjustment + element.scrollLeft) - + i.scrollbarYRight - + i.scrollbarYOuterWidth - + 9; + } else { + yRailOffset.right = i.scrollbarYRight - element.scrollLeft; + } + } else { + if (i.isRtl) { + yRailOffset.left = + i.negativeScrollAdjustment + + element.scrollLeft + + i.containerWidth * 2 - + i.contentWidth - + i.scrollbarYLeft - + i.scrollbarYOuterWidth; + } else { + yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; + } + } + set(i.scrollbarYRail, yRailOffset); + + set(i.scrollbarX, { + left: i.scrollbarXLeft, + width: i.scrollbarXWidth - i.railBorderXWidth, + }); + set(i.scrollbarY, { + top: i.scrollbarYTop, + height: i.scrollbarYHeight - i.railBorderYWidth, + }); } - function getThumbSize(i, thumbSize) { - if (i.settings.minScrollbarLength) { - thumbSize = Math.max(thumbSize, i.settings.minScrollbarLength); - } - if (i.settings.maxScrollbarLength) { - thumbSize = Math.min(thumbSize, i.settings.maxScrollbarLength); - } - return thumbSize; - } - - function updateCss(element, i) { - var xRailOffset = { width: i.railXWidth }; - var roundedScrollTop = Math.floor(element.scrollTop); - - if (i.isRtl) { - xRailOffset.left = - i.negativeScrollAdjustment + - element.scrollLeft + - i.containerWidth - - i.contentWidth; - } else { - xRailOffset.left = element.scrollLeft; - } - if (i.isScrollbarXUsingBottom) { - xRailOffset.bottom = i.scrollbarXBottom - roundedScrollTop; - } else { - xRailOffset.top = i.scrollbarXTop + roundedScrollTop; - } - set(i.scrollbarXRail, xRailOffset); - - var yRailOffset = { top: roundedScrollTop, height: i.railYHeight }; - if (i.isScrollbarYUsingRight) { - if (i.isRtl) { - yRailOffset.right = - i.contentWidth - - (i.negativeScrollAdjustment + element.scrollLeft) - - i.scrollbarYRight - - i.scrollbarYOuterWidth - - 9; - } else { - yRailOffset.right = i.scrollbarYRight - element.scrollLeft; - } - } else { - if (i.isRtl) { - yRailOffset.left = - i.negativeScrollAdjustment + - element.scrollLeft + - i.containerWidth * 2 - - i.contentWidth - - i.scrollbarYLeft - - i.scrollbarYOuterWidth; - } else { - yRailOffset.left = i.scrollbarYLeft + element.scrollLeft; - } - } - set(i.scrollbarYRail, yRailOffset); - - set(i.scrollbarX, { - left: i.scrollbarXLeft, - width: i.scrollbarXWidth - i.railBorderXWidth, - }); - set(i.scrollbarY, { - top: i.scrollbarYTop, - height: i.scrollbarYHeight - i.railBorderYWidth, - }); - } - - function clickRail(i) { - var element = i.element; - - i.event.bind(i.scrollbarY, 'mousedown', function (e) { return e.stopPropagation(); }); - i.event.bind(i.scrollbarYRail, 'mousedown', function (e) { - var positionTop = - e.pageY - - window.pageYOffset - - i.scrollbarYRail.getBoundingClientRect().top; - var direction = positionTop > i.scrollbarYTop ? 1 : -1; - - i.element.scrollTop += direction * i.containerHeight; - updateGeometry(i); - - e.stopPropagation(); - }); - - i.event.bind(i.scrollbarX, 'mousedown', function (e) { return e.stopPropagation(); }); - i.event.bind(i.scrollbarXRail, 'mousedown', function (e) { - var positionLeft = - e.pageX - - window.pageXOffset - - i.scrollbarXRail.getBoundingClientRect().left; - var direction = positionLeft > i.scrollbarXLeft ? 1 : -1; - - i.element.scrollLeft += direction * i.containerWidth; - updateGeometry(i); - - e.stopPropagation(); - }); + function clickRail(i) { + var element = i.element; + + i.event.bind(i.scrollbarY, 'mousedown', function (e) { return e.stopPropagation(); }); + i.event.bind(i.scrollbarYRail, 'mousedown', function (e) { + var positionTop = + e.pageY - + window.pageYOffset - + i.scrollbarYRail.getBoundingClientRect().top; + var direction = positionTop > i.scrollbarYTop ? 1 : -1; + + i.element.scrollTop += direction * i.containerHeight; + updateGeometry(i); + + e.stopPropagation(); + }); + + i.event.bind(i.scrollbarX, 'mousedown', function (e) { return e.stopPropagation(); }); + i.event.bind(i.scrollbarXRail, 'mousedown', function (e) { + var positionLeft = + e.pageX - + window.pageXOffset - + i.scrollbarXRail.getBoundingClientRect().left; + var direction = positionLeft > i.scrollbarXLeft ? 1 : -1; + + i.element.scrollLeft += direction * i.containerWidth; + updateGeometry(i); + + e.stopPropagation(); + }); } - function dragThumb(i) { - bindMouseScrollHandler(i, [ - 'containerWidth', - 'contentWidth', - 'pageX', - 'railXWidth', - 'scrollbarX', - 'scrollbarXWidth', - 'scrollLeft', - 'x', - 'scrollbarXRail' ]); - bindMouseScrollHandler(i, [ - 'containerHeight', - 'contentHeight', - 'pageY', - 'railYHeight', - 'scrollbarY', - 'scrollbarYHeight', - 'scrollTop', - 'y', - 'scrollbarYRail' ]); - } - - function bindMouseScrollHandler( - i, - ref + function dragThumb(i) { + bindMouseScrollHandler(i, [ + 'containerWidth', + 'contentWidth', + 'pageX', + 'railXWidth', + 'scrollbarX', + 'scrollbarXWidth', + 'scrollLeft', + 'x', + 'scrollbarXRail' ]); + bindMouseScrollHandler(i, [ + 'containerHeight', + 'contentHeight', + 'pageY', + 'railYHeight', + 'scrollbarY', + 'scrollbarYHeight', + 'scrollTop', + 'y', + 'scrollbarYRail' ]); + } + + function bindMouseScrollHandler( + i, + ref ) { var containerHeight = ref[0]; var contentHeight = ref[1]; @@ -550,801 +551,806 @@ var scrollTop = ref[6]; var y = ref[7]; var scrollbarYRail = ref[8]; - - var element = i.element; - - var startingScrollTop = null; - var startingMousePageY = null; - var scrollBy = null; - - function mouseMoveHandler(e) { - if (e.touches && e.touches[0]) { - e[pageY] = e.touches[0].pageY; - } - element[scrollTop] = - startingScrollTop + scrollBy * (e[pageY] - startingMousePageY); - addScrollingClass(i, y); - updateGeometry(i); - - e.stopPropagation(); - e.preventDefault(); - } - - function mouseUpHandler() { - removeScrollingClass(i, y); - i[scrollbarYRail].classList.remove(cls.state.clicking); - i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); - } - - function bindMoves(e, touchMode) { - startingScrollTop = element[scrollTop]; - if (touchMode && e.touches) { - e[pageY] = e.touches[0].pageY; - } - startingMousePageY = e[pageY]; - scrollBy = - (i[contentHeight] - i[containerHeight]) / - (i[railYHeight] - i[scrollbarYHeight]); - if (!touchMode) { - i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); - i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); - e.preventDefault(); - } else { - i.event.bind(i.ownerDocument, 'touchmove', mouseMoveHandler); - } - - i[scrollbarYRail].classList.add(cls.state.clicking); - - e.stopPropagation(); - } - - i.event.bind(i[scrollbarY], 'mousedown', function (e) { - bindMoves(e); - }); - i.event.bind(i[scrollbarY], 'touchstart', function (e) { - bindMoves(e, true); - }); + + var element = i.element; + + var startingScrollTop = null; + var startingMousePageY = null; + var scrollBy = null; + + function mouseMoveHandler(e) { + if (e.touches && e.touches[0]) { + e[pageY] = e.touches[0].pageY; + } + element[scrollTop] = + startingScrollTop + scrollBy * (e[pageY] - startingMousePageY); + addScrollingClass(i, y); + updateGeometry(i); + + e.stopPropagation(); + e.preventDefault(); + } + + function mouseUpHandler() { + removeScrollingClass(i, y); + i[scrollbarYRail].classList.remove(cls.state.clicking); + i.event.unbind(i.ownerDocument, 'mousemove', mouseMoveHandler); + } + + function bindMoves(e, touchMode) { + startingScrollTop = element[scrollTop]; + if (touchMode && e.touches) { + e[pageY] = e.touches[0].pageY; + } + startingMousePageY = e[pageY]; + scrollBy = + (i[contentHeight] - i[containerHeight]) / + (i[railYHeight] - i[scrollbarYHeight]); + if (!touchMode) { + i.event.bind(i.ownerDocument, 'mousemove', mouseMoveHandler); + i.event.once(i.ownerDocument, 'mouseup', mouseUpHandler); + e.preventDefault(); + } else { + i.event.bind(i.ownerDocument, 'touchmove', mouseMoveHandler); + } + + i[scrollbarYRail].classList.add(cls.state.clicking); + + e.stopPropagation(); + } + + i.event.bind(i[scrollbarY], 'mousedown', function (e) { + bindMoves(e); + }); + i.event.bind(i[scrollbarY], 'touchstart', function (e) { + bindMoves(e, true); + }); } - function keyboard(i) { - var element = i.element; - - var elementHovered = function () { return matches(element, ':hover'); }; - var scrollbarFocused = function () { return matches(i.scrollbarX, ':focus') || matches(i.scrollbarY, ':focus'); }; - - function shouldPreventDefault(deltaX, deltaY) { - var scrollTop = Math.floor(element.scrollTop); - if (deltaX === 0) { - if (!i.scrollbarYActive) { - return false; - } - if ( - (scrollTop === 0 && deltaY > 0) || - (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0) - ) { - return !i.settings.wheelPropagation; - } - } - - var scrollLeft = element.scrollLeft; - if (deltaY === 0) { - if (!i.scrollbarXActive) { - return false; - } - if ( - (scrollLeft === 0 && deltaX < 0) || - (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0) - ) { - return !i.settings.wheelPropagation; - } - } - return true; - } - - i.event.bind(i.ownerDocument, 'keydown', function (e) { - if ( - (e.isDefaultPrevented && e.isDefaultPrevented()) || - e.defaultPrevented - ) { - return; - } - - if (!elementHovered() && !scrollbarFocused()) { - return; - } - - var activeElement = document.activeElement - ? document.activeElement - : i.ownerDocument.activeElement; - if (activeElement) { - if (activeElement.tagName === 'IFRAME') { - activeElement = activeElement.contentDocument.activeElement; - } else { - // go deeper if element is a webcomponent - while (activeElement.shadowRoot) { - activeElement = activeElement.shadowRoot.activeElement; - } - } - if (isEditable(activeElement)) { - return; - } - } - - var deltaX = 0; - var deltaY = 0; - - switch (e.which) { - case 37: // left - if (e.metaKey) { - deltaX = -i.contentWidth; - } else if (e.altKey) { - deltaX = -i.containerWidth; - } else { - deltaX = -30; - } - break; - case 38: // up - if (e.metaKey) { - deltaY = i.contentHeight; - } else if (e.altKey) { - deltaY = i.containerHeight; - } else { - deltaY = 30; - } - break; - case 39: // right - if (e.metaKey) { - deltaX = i.contentWidth; - } else if (e.altKey) { - deltaX = i.containerWidth; - } else { - deltaX = 30; - } - break; - case 40: // down - if (e.metaKey) { - deltaY = -i.contentHeight; - } else if (e.altKey) { - deltaY = -i.containerHeight; - } else { - deltaY = -30; - } - break; - case 32: // space bar - if (e.shiftKey) { - deltaY = i.containerHeight; - } else { - deltaY = -i.containerHeight; - } - break; - case 33: // page up - deltaY = i.containerHeight; - break; - case 34: // page down - deltaY = -i.containerHeight; - break; - case 36: // home - deltaY = i.contentHeight; - break; - case 35: // end - deltaY = -i.contentHeight; - break; - default: - return; - } - - if (i.settings.suppressScrollX && deltaX !== 0) { - return; - } - if (i.settings.suppressScrollY && deltaY !== 0) { - return; - } - - element.scrollTop -= deltaY; - element.scrollLeft += deltaX; - updateGeometry(i); - - if (shouldPreventDefault(deltaX, deltaY)) { - e.preventDefault(); - } - }); + function keyboard(i) { + var element = i.element; + + var elementHovered = function () { return matches(element, ':hover'); }; + var scrollbarFocused = function () { return matches(i.scrollbarX, ':focus') || matches(i.scrollbarY, ':focus'); }; + + function shouldPreventDefault(deltaX, deltaY) { + var scrollTop = Math.floor(element.scrollTop); + if (deltaX === 0) { + if (!i.scrollbarYActive) { + return false; + } + if ( + (scrollTop === 0 && deltaY > 0) || + (scrollTop >= i.contentHeight - i.containerHeight && deltaY < 0) + ) { + return !i.settings.wheelPropagation; + } + } + + var scrollLeft = element.scrollLeft; + if (deltaY === 0) { + if (!i.scrollbarXActive) { + return false; + } + if ( + (scrollLeft === 0 && deltaX < 0) || + (scrollLeft >= i.contentWidth - i.containerWidth && deltaX > 0) + ) { + return !i.settings.wheelPropagation; + } + } + return true; + } + + i.event.bind(i.ownerDocument, 'keydown', function (e) { + if ( + (e.isDefaultPrevented && e.isDefaultPrevented()) || + e.defaultPrevented + ) { + return; + } + + if (!elementHovered() && !scrollbarFocused()) { + return; + } + + var activeElement = document.activeElement + ? document.activeElement + : i.ownerDocument.activeElement; + if (activeElement) { + if (activeElement.tagName === 'IFRAME') { + activeElement = activeElement.contentDocument.activeElement; + } else { + // go deeper if element is a webcomponent + while (activeElement.shadowRoot) { + activeElement = activeElement.shadowRoot.activeElement; + } + } + if (isEditable(activeElement)) { + return; + } + } + + var deltaX = 0; + var deltaY = 0; + + switch (e.which) { + case 37: // left + if (e.metaKey) { + deltaX = -i.contentWidth; + } else if (e.altKey) { + deltaX = -i.containerWidth; + } else { + deltaX = -30; + } + break; + case 38: // up + if (e.metaKey) { + deltaY = i.contentHeight; + } else if (e.altKey) { + deltaY = i.containerHeight; + } else { + deltaY = 30; + } + break; + case 39: // right + if (e.metaKey) { + deltaX = i.contentWidth; + } else if (e.altKey) { + deltaX = i.containerWidth; + } else { + deltaX = 30; + } + break; + case 40: // down + if (e.metaKey) { + deltaY = -i.contentHeight; + } else if (e.altKey) { + deltaY = -i.containerHeight; + } else { + deltaY = -30; + } + break; + case 32: // space bar + if (e.shiftKey) { + deltaY = i.containerHeight; + } else { + deltaY = -i.containerHeight; + } + break; + case 33: // page up + deltaY = i.containerHeight; + break; + case 34: // page down + deltaY = -i.containerHeight; + break; + case 36: // home + deltaY = i.contentHeight; + break; + case 35: // end + deltaY = -i.contentHeight; + break; + default: + return; + } + + if (i.settings.suppressScrollX && deltaX !== 0) { + return; + } + if (i.settings.suppressScrollY && deltaY !== 0) { + return; + } + + element.scrollTop -= deltaY; + element.scrollLeft += deltaX; + updateGeometry(i); + + if (shouldPreventDefault(deltaX, deltaY)) { + e.preventDefault(); + } + }); } - function wheel(i) { - var element = i.element; - - function shouldPreventDefault(deltaX, deltaY) { - var roundedScrollTop = Math.floor(element.scrollTop); - var isTop = element.scrollTop === 0; - var isBottom = - roundedScrollTop + element.offsetHeight === element.scrollHeight; - var isLeft = element.scrollLeft === 0; - var isRight = - element.scrollLeft + element.offsetWidth === element.scrollWidth; - - var hitsBound; - - // pick axis with primary direction - if (Math.abs(deltaY) > Math.abs(deltaX)) { - hitsBound = isTop || isBottom; - } else { - hitsBound = isLeft || isRight; - } - - return hitsBound ? !i.settings.wheelPropagation : true; - } - - function getDeltaFromEvent(e) { - var deltaX = e.deltaX; - var deltaY = -1 * e.deltaY; - - if (typeof deltaX === 'undefined' || typeof deltaY === 'undefined') { - // OS X Safari - deltaX = (-1 * e.wheelDeltaX) / 6; - deltaY = e.wheelDeltaY / 6; - } - - if (e.deltaMode && e.deltaMode === 1) { - // Firefox in deltaMode 1: Line scrolling - deltaX *= 10; - deltaY *= 10; - } - - if (deltaX !== deltaX && deltaY !== deltaY /* NaN checks */) { - // IE in some mouse drivers - deltaX = 0; - deltaY = e.wheelDelta; - } - - if (e.shiftKey) { - // reverse axis with shift key - return [-deltaY, -deltaX]; - } - return [deltaX, deltaY]; - } - - function shouldBeConsumedByChild(target, deltaX, deltaY) { - // FIXME: this is a workaround for issue in FF and IE #571 + if (!env.isWebKit && element.querySelector('select:focus')) { + return true; + } + + if (!element.contains(target)) { + return false; + } + + var cursor = target; + + while (cursor && cursor !== element) { + if (cursor.classList.contains(cls.element.consuming)) { + return true; + } + + var style = get(cursor); + + // if deltaY && vertical scrollable + if (deltaY && style.overflowY.match(/(scroll|auto)/)) { + var maxScrollTop = cursor.scrollHeight - cursor.clientHeight; + if (maxScrollTop > 0) { + if ( + (cursor.scrollTop > 0 && deltaY < 0) || + (cursor.scrollTop < maxScrollTop && deltaY > 0) + ) { + return true; + } + } + } + // if deltaX && horizontal scrollable + if (deltaX && style.overflowX.match(/(scroll|auto)/)) { + var maxScrollLeft = cursor.scrollWidth - cursor.clientWidth; + if (maxScrollLeft > 0) { + if ( + (cursor.scrollLeft > 0 && deltaX < 0) || + (cursor.scrollLeft < maxScrollLeft && deltaX > 0) + ) { + return true; + } + } + } + + cursor = cursor.parentNode; + } + + return false; + } + + function mousewheelHandler(e) { var ref = getDeltaFromEvent(e); var deltaX = ref[0]; - var deltaY = ref[1]; - - if (shouldBeConsumedByChild(e.target, deltaX, deltaY)) { - return; - } - - var shouldPrevent = false; - if (!i.settings.useBothWheelAxes) { - // deltaX will only be used for horizontal scrolling and deltaY will - // only be used for vertical scrolling - this is the default - element.scrollTop -= deltaY * i.settings.wheelSpeed; - element.scrollLeft += deltaX * i.settings.wheelSpeed; - } else if (i.scrollbarYActive && !i.scrollbarXActive) { - // only vertical scrollbar is active and useBothWheelAxes option is - // active, so let's scroll vertical bar using both mouse wheel axes - if (deltaY) { - element.scrollTop -= deltaY * i.settings.wheelSpeed; - } else { - element.scrollTop += deltaX * i.settings.wheelSpeed; - } - shouldPrevent = true; - } else if (i.scrollbarXActive && !i.scrollbarYActive) { - // useBothWheelAxes and only horizontal bar is active, so use both - // wheel axes for horizontal bar - if (deltaX) { - element.scrollLeft += deltaX * i.settings.wheelSpeed; - } else { - element.scrollLeft -= deltaY * i.settings.wheelSpeed; - } - shouldPrevent = true; - } - - updateGeometry(i); - - shouldPrevent = shouldPrevent || shouldPreventDefault(deltaX, deltaY); - if (shouldPrevent && !e.ctrlKey) { - e.stopPropagation(); - e.preventDefault(); - } - } - - if (typeof window.onwheel !== 'undefined') { - i.event.bind(element, 'wheel', mousewheelHandler); - } else if (typeof window.onmousewheel !== 'undefined') { - i.event.bind(element, 'mousewheel', mousewheelHandler); - } + var deltaY = ref[1]; + + if (shouldBeConsumedByChild(e.target, deltaX, deltaY)) { + return; + } + + var shouldPrevent = false; + if (!i.settings.useBothWheelAxes) { + // deltaX will only be used for horizontal scrolling and deltaY will + // only be used for vertical scrolling - this is the default + element.scrollTop -= deltaY * i.settings.wheelSpeed; + element.scrollLeft += deltaX * i.settings.wheelSpeed; + } else if (i.scrollbarYActive && !i.scrollbarXActive) { + // only vertical scrollbar is active and useBothWheelAxes option is + // active, so let's scroll vertical bar using both mouse wheel axes + if (deltaY) { + element.scrollTop -= deltaY * i.settings.wheelSpeed; + } else { + element.scrollTop += deltaX * i.settings.wheelSpeed; + } + shouldPrevent = true; + } else if (i.scrollbarXActive && !i.scrollbarYActive) { + // useBothWheelAxes and only horizontal bar is active, so use both + // wheel axes for horizontal bar + if (deltaX) { + element.scrollLeft += deltaX * i.settings.wheelSpeed; + } else { + element.scrollLeft -= deltaY * i.settings.wheelSpeed; + } + shouldPrevent = true; + } + + updateGeometry(i); + + shouldPrevent = shouldPrevent || shouldPreventDefault(deltaX, deltaY); + if (shouldPrevent && !e.ctrlKey) { + e.stopPropagation(); + e.preventDefault(); + } + } + + if (typeof window.onwheel !== 'undefined') { + i.event.bind(element, 'wheel', mousewheelHandler); + } else if (typeof window.onmousewheel !== 'undefined') { + i.event.bind(element, 'mousewheel', mousewheelHandler); + } } - function touch(i) { - if (!env.supportsTouch && !env.supportsIePointer) { - return; - } - - var element = i.element; - - function shouldPrevent(deltaX, deltaY) { - var scrollTop = Math.floor(element.scrollTop); - var scrollLeft = element.scrollLeft; - var magnitudeX = Math.abs(deltaX); - var magnitudeY = Math.abs(deltaY); - - if (magnitudeY > magnitudeX) { - // user is perhaps trying to swipe up/down the page - - if ( - (deltaY < 0 && scrollTop === i.contentHeight - i.containerHeight) || - (deltaY > 0 && scrollTop === 0) - ) { - // set prevent for mobile Chrome refresh - return window.scrollY === 0 && deltaY > 0 && env.isChrome; - } - } else if (magnitudeX > magnitudeY) { - // user is perhaps trying to swipe left/right across the page - - if ( - (deltaX < 0 && scrollLeft === i.contentWidth - i.containerWidth) || - (deltaX > 0 && scrollLeft === 0) - ) { - return true; - } - } - - return true; - } - - function applyTouchMove(differenceX, differenceY) { - element.scrollTop -= differenceY; - element.scrollLeft -= differenceX; - - updateGeometry(i); - } - - var startOffset = {}; - var startTime = 0; - var speed = {}; - var easingLoop = null; - - function getTouch(e) { - if (e.targetTouches) { - return e.targetTouches[0]; - } else { - // Maybe IE pointer - return e; - } - } - - function shouldHandle(e) { - if (e.pointerType && e.pointerType === 'pen' && e.buttons === 0) { - return false; - } - if (e.targetTouches && e.targetTouches.length === 1) { - return true; - } - if ( - e.pointerType && - e.pointerType !== 'mouse' && - e.pointerType !== e.MSPOINTER_TYPE_MOUSE - ) { - return true; - } - return false; - } - - function touchStart(e) { - if (!shouldHandle(e)) { - return; - } - - var touch = getTouch(e); - - startOffset.pageX = touch.pageX; - startOffset.pageY = touch.pageY; - - startTime = new Date().getTime(); - - if (easingLoop !== null) { - clearInterval(easingLoop); - } - } - - function shouldBeConsumedByChild(target, deltaX, deltaY) { - if (!element.contains(target)) { - return false; - } - - var cursor = target; - - while (cursor && cursor !== element) { - if (cursor.classList.contains(cls.element.consuming)) { - return true; - } - - var style = get(cursor); - - // if deltaY && vertical scrollable - if (deltaY && style.overflowY.match(/(scroll|auto)/)) { - var maxScrollTop = cursor.scrollHeight - cursor.clientHeight; - if (maxScrollTop > 0) { - if ( - (cursor.scrollTop > 0 && deltaY < 0) || - (cursor.scrollTop < maxScrollTop && deltaY > 0) - ) { - return true; - } - } - } - // if deltaX && horizontal scrollable - if (deltaX && style.overflowX.match(/(scroll|auto)/)) { - var maxScrollLeft = cursor.scrollWidth - cursor.clientWidth; - if (maxScrollLeft > 0) { - if ( - (cursor.scrollLeft > 0 && deltaX < 0) || - (cursor.scrollLeft < maxScrollLeft && deltaX > 0) - ) { - return true; - } - } - } - - cursor = cursor.parentNode; - } - - return false; - } - - function touchMove(e) { - if (shouldHandle(e)) { - var touch = getTouch(e); - - var currentOffset = { pageX: touch.pageX, pageY: touch.pageY }; - - var differenceX = currentOffset.pageX - startOffset.pageX; - var differenceY = currentOffset.pageY - startOffset.pageY; - - if (shouldBeConsumedByChild(e.target, differenceX, differenceY)) { - return; - } - - applyTouchMove(differenceX, differenceY); - startOffset = currentOffset; - - var currentTime = new Date().getTime(); - - var timeGap = currentTime - startTime; - if (timeGap > 0) { - speed.x = differenceX / timeGap; - speed.y = differenceY / timeGap; - startTime = currentTime; - } - - if (shouldPrevent(differenceX, differenceY)) { - e.preventDefault(); - } - } - } - function touchEnd() { - if (i.settings.swipeEasing) { - clearInterval(easingLoop); - easingLoop = setInterval(function() { - if (i.isInitialized) { - clearInterval(easingLoop); - return; - } - - if (!speed.x && !speed.y) { - clearInterval(easingLoop); - return; - } - - if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) { - clearInterval(easingLoop); - return; - } - - applyTouchMove(speed.x * 30, speed.y * 30); - - speed.x *= 0.8; - speed.y *= 0.8; - }, 10); - } - } - - if (env.supportsTouch) { - i.event.bind(element, 'touchstart', touchStart); - i.event.bind(element, 'touchmove', touchMove); - i.event.bind(element, 'touchend', touchEnd); - } else if (env.supportsIePointer) { - if (window.PointerEvent) { - i.event.bind(element, 'pointerdown', touchStart); - i.event.bind(element, 'pointermove', touchMove); - i.event.bind(element, 'pointerup', touchEnd); - } else if (window.MSPointerEvent) { - i.event.bind(element, 'MSPointerDown', touchStart); - i.event.bind(element, 'MSPointerMove', touchMove); - i.event.bind(element, 'MSPointerUp', touchEnd); - } - } + function touch(i) { + if (!env.supportsTouch && !env.supportsIePointer) { + return; + } + + var element = i.element; + + function shouldPrevent(deltaX, deltaY) { + var scrollTop = Math.floor(element.scrollTop); + var scrollLeft = element.scrollLeft; + var magnitudeX = Math.abs(deltaX); + var magnitudeY = Math.abs(deltaY); + + if (magnitudeY > magnitudeX) { + // user is perhaps trying to swipe up/down the page + + if ( + (deltaY < 0 && scrollTop === i.contentHeight - i.containerHeight) || + (deltaY > 0 && scrollTop === 0) + ) { + // set prevent for mobile Chrome refresh + return window.scrollY === 0 && deltaY > 0 && env.isChrome; + } + } else if (magnitudeX > magnitudeY) { + // user is perhaps trying to swipe left/right across the page + + if ( + (deltaX < 0 && scrollLeft === i.contentWidth - i.containerWidth) || + (deltaX > 0 && scrollLeft === 0) + ) { + return true; + } + } + + return true; + } + + function applyTouchMove(differenceX, differenceY) { + element.scrollTop -= differenceY; + element.scrollLeft -= differenceX; + + updateGeometry(i); + } + + var startOffset = {}; + var startTime = 0; + var speed = {}; + var easingLoop = null; + + function getTouch(e) { + if (e.targetTouches) { + return e.targetTouches[0]; + } else { + // Maybe IE pointer + return e; + } + } + + function shouldHandle(e) { + if (e.pointerType && e.pointerType === 'pen' && e.buttons === 0) { + return false; + } + if (e.targetTouches && e.targetTouches.length === 1) { + return true; + } + if ( + e.pointerType && + e.pointerType !== 'mouse' && + e.pointerType !== e.MSPOINTER_TYPE_MOUSE + ) { + return true; + } + return false; + } + + function touchStart(e) { + if (!shouldHandle(e)) { + return; + } + + var touch = getTouch(e); + + startOffset.pageX = touch.pageX; + startOffset.pageY = touch.pageY; + + startTime = new Date().getTime(); + + if (easingLoop !== null) { + clearInterval(easingLoop); + } + } + + function shouldBeConsumedByChild(target, deltaX, deltaY) { + if (!element.contains(target)) { + return false; + } + + var cursor = target; + + while (cursor && cursor !== element) { + if (cursor.classList.contains(cls.element.consuming)) { + return true; + } + + var style = get(cursor); + + // if deltaY && vertical scrollable + if (deltaY && style.overflowY.match(/(scroll|auto)/)) { + var maxScrollTop = cursor.scrollHeight - cursor.clientHeight; + if (maxScrollTop > 0) { + if ( + (cursor.scrollTop > 0 && deltaY < 0) || + (cursor.scrollTop < maxScrollTop && deltaY > 0) + ) { + return true; + } + } + } + // if deltaX && horizontal scrollable + if (deltaX && style.overflowX.match(/(scroll|auto)/)) { + var maxScrollLeft = cursor.scrollWidth - cursor.clientWidth; + if (maxScrollLeft > 0) { + if ( + (cursor.scrollLeft > 0 && deltaX < 0) || + (cursor.scrollLeft < maxScrollLeft && deltaX > 0) + ) { + return true; + } + } + } + + cursor = cursor.parentNode; + } + + return false; + } + + function touchMove(e) { + if (shouldHandle(e)) { + var touch = getTouch(e); + + var currentOffset = { pageX: touch.pageX, pageY: touch.pageY }; + + var differenceX = currentOffset.pageX - startOffset.pageX; + var differenceY = currentOffset.pageY - startOffset.pageY; + + if (shouldBeConsumedByChild(e.target, differenceX, differenceY)) { + return; + } + + applyTouchMove(differenceX, differenceY); + startOffset = currentOffset; + + var currentTime = new Date().getTime(); + + var timeGap = currentTime - startTime; + if (timeGap > 0) { + speed.x = differenceX / timeGap; + speed.y = differenceY / timeGap; + startTime = currentTime; + } + + if (shouldPrevent(differenceX, differenceY)) { + e.preventDefault(); + } + } + } + function touchEnd() { + if (i.settings.swipeEasing) { + clearInterval(easingLoop); + easingLoop = setInterval(function() { + if (i.isInitialized) { + clearInterval(easingLoop); + return; + } + + if (!speed.x && !speed.y) { + clearInterval(easingLoop); + return; + } + + if (Math.abs(speed.x) < 0.01 && Math.abs(speed.y) < 0.01) { + clearInterval(easingLoop); + return; + } + + if (!i.element) { + clearInterval(easingLoop); + return; + } + + applyTouchMove(speed.x * 30, speed.y * 30); + + speed.x *= 0.8; + speed.y *= 0.8; + }, 10); + } + } + + if (env.supportsTouch) { + i.event.bind(element, 'touchstart', touchStart); + i.event.bind(element, 'touchmove', touchMove); + i.event.bind(element, 'touchend', touchEnd); + } else if (env.supportsIePointer) { + if (window.PointerEvent) { + i.event.bind(element, 'pointerdown', touchStart); + i.event.bind(element, 'pointermove', touchMove); + i.event.bind(element, 'pointerup', touchEnd); + } else if (window.MSPointerEvent) { + i.event.bind(element, 'MSPointerDown', touchStart); + i.event.bind(element, 'MSPointerMove', touchMove); + i.event.bind(element, 'MSPointerUp', touchEnd); + } + } } - var defaultSettings = function () { return ({ - handlers: ['click-rail', 'drag-thumb', 'keyboard', 'wheel', 'touch'], - maxScrollbarLength: null, - minScrollbarLength: null, - scrollingThreshold: 1000, - scrollXMarginOffset: 0, - scrollYMarginOffset: 0, - suppressScrollX: false, - suppressScrollY: false, - swipeEasing: true, - useBothWheelAxes: false, - wheelPropagation: true, - wheelSpeed: 1, - }); }; - - var handlers = { - 'click-rail': clickRail, - 'drag-thumb': dragThumb, - keyboard: keyboard, - wheel: wheel, - touch: touch, - }; - + var defaultSettings = function () { return ({ + handlers: ['click-rail', 'drag-thumb', 'keyboard', 'wheel', 'touch'], + maxScrollbarLength: null, + minScrollbarLength: null, + scrollingThreshold: 1000, + scrollXMarginOffset: 0, + scrollYMarginOffset: 0, + suppressScrollX: false, + suppressScrollY: false, + swipeEasing: true, + useBothWheelAxes: false, + wheelPropagation: true, + wheelSpeed: 1, + }); }; + + var handlers = { + 'click-rail': clickRail, + 'drag-thumb': dragThumb, + keyboard: keyboard, + wheel: wheel, + touch: touch, + }; + var PerfectScrollbar = function PerfectScrollbar(element, userSettings) { var this$2 = this; var this$1 = this; if ( userSettings === void 0 ) { userSettings = {}; } - - if (typeof element === 'string') { - element = document.querySelector(element); - } - - if (!element || !element.nodeName) { - throw new Error('no element is specified to initialize PerfectScrollbar'); - } - - this.element = element; - - element.classList.add(cls.main); - - this.settings = defaultSettings(); - for (var key in userSettings) { - this$2.settings[key] = userSettings[key]; - } - - this.containerWidth = null; - this.containerHeight = null; - this.contentWidth = null; - this.contentHeight = null; - - var focus = function () { return element.classList.add(cls.state.focus); }; - var blur = function () { return element.classList.remove(cls.state.focus); }; - - this.isRtl = get(element).direction === 'rtl'; - if (this.isRtl === true) { - element.classList.add(cls.rtl); - } - this.isNegativeScroll = (function () { - var originalScrollLeft = element.scrollLeft; - var result = null; - element.scrollLeft = -1; - result = element.scrollLeft < 0; - element.scrollLeft = originalScrollLeft; - return result; - })(); - this.negativeScrollAdjustment = this.isNegativeScroll - ? element.scrollWidth - element.clientWidth - : 0; - this.event = new EventManager(); - this.ownerDocument = element.ownerDocument || document; - - this.scrollbarXRail = div(cls.element.rail('x')); - element.appendChild(this.scrollbarXRail); - this.scrollbarX = div(cls.element.thumb('x')); - this.scrollbarXRail.appendChild(this.scrollbarX); - this.scrollbarX.setAttribute('tabindex', 0); - this.event.bind(this.scrollbarX, 'focus', focus); - this.event.bind(this.scrollbarX, 'blur', blur); - this.scrollbarXActive = null; - this.scrollbarXWidth = null; - this.scrollbarXLeft = null; - var railXStyle = get(this.scrollbarXRail); - this.scrollbarXBottom = parseInt(railXStyle.bottom, 10); - if (isNaN(this.scrollbarXBottom)) { - this.isScrollbarXUsingBottom = false; - this.scrollbarXTop = toInt(railXStyle.top); - } else { - this.isScrollbarXUsingBottom = true; - } - this.railBorderXWidth = - toInt(railXStyle.borderLeftWidth) + toInt(railXStyle.borderRightWidth); - // Set rail to display:block to calculate margins - set(this.scrollbarXRail, { display: 'block' }); - this.railXMarginWidth = - toInt(railXStyle.marginLeft) + toInt(railXStyle.marginRight); - set(this.scrollbarXRail, { display: '' }); - this.railXWidth = null; - this.railXRatio = null; - - this.scrollbarYRail = div(cls.element.rail('y')); - element.appendChild(this.scrollbarYRail); - this.scrollbarY = div(cls.element.thumb('y')); - this.scrollbarYRail.appendChild(this.scrollbarY); - this.scrollbarY.setAttribute('tabindex', 0); - this.event.bind(this.scrollbarY, 'focus', focus); - this.event.bind(this.scrollbarY, 'blur', blur); - this.scrollbarYActive = null; - this.scrollbarYHeight = null; - this.scrollbarYTop = null; - var railYStyle = get(this.scrollbarYRail); - this.scrollbarYRight = parseInt(railYStyle.right, 10); - if (isNaN(this.scrollbarYRight)) { - this.isScrollbarYUsingRight = false; - this.scrollbarYLeft = toInt(railYStyle.left); - } else { - this.isScrollbarYUsingRight = true; - } - this.scrollbarYOuterWidth = this.isRtl ? outerWidth(this.scrollbarY) : null; - this.railBorderYWidth = - toInt(railYStyle.borderTopWidth) + toInt(railYStyle.borderBottomWidth); - set(this.scrollbarYRail, { display: 'block' }); - this.railYMarginHeight = - toInt(railYStyle.marginTop) + toInt(railYStyle.marginBottom); - set(this.scrollbarYRail, { display: '' }); - this.railYHeight = null; - this.railYRatio = null; - - this.reach = { - x: - element.scrollLeft <= 0 - ? 'start' - : element.scrollLeft >= this.contentWidth - this.containerWidth - ? 'end' - : null, - y: - element.scrollTop <= 0 - ? 'start' - : element.scrollTop >= this.contentHeight - this.containerHeight - ? 'end' - : null, - }; - - this.isAlive = true; - - this.settings.handlers.forEach(function (handlerName) { return handlers[handlerName](this$1); }); - - this.lastScrollTop = Math.floor(element.scrollTop); // for onScroll only - this.lastScrollLeft = element.scrollLeft; // for onScroll only - this.event.bind(this.element, 'scroll', function (e) { return this$1.onScroll(e); }); - updateGeometry(this); - }; - - PerfectScrollbar.prototype.update = function update () { - if (!this.isAlive) { - return; - } - - // Recalcuate negative scrollLeft adjustment - this.negativeScrollAdjustment = this.isNegativeScroll - ? this.element.scrollWidth - this.element.clientWidth - : 0; - - // Recalculate rail margins - set(this.scrollbarXRail, { display: 'block' }); - set(this.scrollbarYRail, { display: 'block' }); - this.railXMarginWidth = - toInt(get(this.scrollbarXRail).marginLeft) + - toInt(get(this.scrollbarXRail).marginRight); - this.railYMarginHeight = - toInt(get(this.scrollbarYRail).marginTop) + - toInt(get(this.scrollbarYRail).marginBottom); - - // Hide scrollbars not to affect scrollWidth and scrollHeight - set(this.scrollbarXRail, { display: 'none' }); - set(this.scrollbarYRail, { display: 'none' }); - - updateGeometry(this); - - processScrollDiff(this, 'top', 0, false, true); - processScrollDiff(this, 'left', 0, false, true); - - set(this.scrollbarXRail, { display: '' }); - set(this.scrollbarYRail, { display: '' }); - }; - - PerfectScrollbar.prototype.onScroll = function onScroll (e) { - if (!this.isAlive) { - return; - } - - updateGeometry(this); - processScrollDiff(this, 'top', this.element.scrollTop - this.lastScrollTop); - processScrollDiff( - this, - 'left', - this.element.scrollLeft - this.lastScrollLeft - ); - - this.lastScrollTop = Math.floor(this.element.scrollTop); - this.lastScrollLeft = this.element.scrollLeft; - }; - - PerfectScrollbar.prototype.destroy = function destroy () { - if (!this.isAlive) { - return; - } - - this.event.unbindAll(); - remove(this.scrollbarX); - remove(this.scrollbarY); - remove(this.scrollbarXRail); - remove(this.scrollbarYRail); - this.removePsClasses(); - - // unset elements - this.element = null; - this.scrollbarX = null; - this.scrollbarY = null; - this.scrollbarXRail = null; - this.scrollbarYRail = null; - - this.isAlive = false; - }; - - PerfectScrollbar.prototype.removePsClasses = function removePsClasses () { - this.element.className = this.element.className - .split(' ') - .filter(function (name) { return !name.match(/^ps([-_].+|)$/); }) - .join(' '); + + if (typeof element === 'string') { + element = document.querySelector(element); + } + + if (!element || !element.nodeName) { + throw new Error('no element is specified to initialize PerfectScrollbar'); + } + + this.element = element; + + element.classList.add(cls.main); + + this.settings = defaultSettings(); + for (var key in userSettings) { + this$2.settings[key] = userSettings[key]; + } + + this.containerWidth = null; + this.containerHeight = null; + this.contentWidth = null; + this.contentHeight = null; + + var focus = function () { return element.classList.add(cls.state.focus); }; + var blur = function () { return element.classList.remove(cls.state.focus); }; + + this.isRtl = get(element).direction === 'rtl'; + if (this.isRtl === true) { + element.classList.add(cls.rtl); + } + this.isNegativeScroll = (function () { + var originalScrollLeft = element.scrollLeft; + var result = null; + element.scrollLeft = -1; + result = element.scrollLeft < 0; + element.scrollLeft = originalScrollLeft; + return result; + })(); + this.negativeScrollAdjustment = this.isNegativeScroll + ? element.scrollWidth - element.clientWidth + : 0; + this.event = new EventManager(); + this.ownerDocument = element.ownerDocument || document; + + this.scrollbarXRail = div(cls.element.rail('x')); + element.appendChild(this.scrollbarXRail); + this.scrollbarX = div(cls.element.thumb('x')); + this.scrollbarXRail.appendChild(this.scrollbarX); + this.scrollbarX.setAttribute('tabindex', 0); + this.event.bind(this.scrollbarX, 'focus', focus); + this.event.bind(this.scrollbarX, 'blur', blur); + this.scrollbarXActive = null; + this.scrollbarXWidth = null; + this.scrollbarXLeft = null; + var railXStyle = get(this.scrollbarXRail); + this.scrollbarXBottom = parseInt(railXStyle.bottom, 10); + if (isNaN(this.scrollbarXBottom)) { + this.isScrollbarXUsingBottom = false; + this.scrollbarXTop = toInt(railXStyle.top); + } else { + this.isScrollbarXUsingBottom = true; + } + this.railBorderXWidth = + toInt(railXStyle.borderLeftWidth) + toInt(railXStyle.borderRightWidth); + // Set rail to display:block to calculate margins + set(this.scrollbarXRail, { display: 'block' }); + this.railXMarginWidth = + toInt(railXStyle.marginLeft) + toInt(railXStyle.marginRight); + set(this.scrollbarXRail, { display: '' }); + this.railXWidth = null; + this.railXRatio = null; + + this.scrollbarYRail = div(cls.element.rail('y')); + element.appendChild(this.scrollbarYRail); + this.scrollbarY = div(cls.element.thumb('y')); + this.scrollbarYRail.appendChild(this.scrollbarY); + this.scrollbarY.setAttribute('tabindex', 0); + this.event.bind(this.scrollbarY, 'focus', focus); + this.event.bind(this.scrollbarY, 'blur', blur); + this.scrollbarYActive = null; + this.scrollbarYHeight = null; + this.scrollbarYTop = null; + var railYStyle = get(this.scrollbarYRail); + this.scrollbarYRight = parseInt(railYStyle.right, 10); + if (isNaN(this.scrollbarYRight)) { + this.isScrollbarYUsingRight = false; + this.scrollbarYLeft = toInt(railYStyle.left); + } else { + this.isScrollbarYUsingRight = true; + } + this.scrollbarYOuterWidth = this.isRtl ? outerWidth(this.scrollbarY) : null; + this.railBorderYWidth = + toInt(railYStyle.borderTopWidth) + toInt(railYStyle.borderBottomWidth); + set(this.scrollbarYRail, { display: 'block' }); + this.railYMarginHeight = + toInt(railYStyle.marginTop) + toInt(railYStyle.marginBottom); + set(this.scrollbarYRail, { display: '' }); + this.railYHeight = null; + this.railYRatio = null; + + this.reach = { + x: + element.scrollLeft <= 0 + ? 'start' + : element.scrollLeft >= this.contentWidth - this.containerWidth + ? 'end' + : null, + y: + element.scrollTop <= 0 + ? 'start' + : element.scrollTop >= this.contentHeight - this.containerHeight + ? 'end' + : null, + }; + + this.isAlive = true; + + this.settings.handlers.forEach(function (handlerName) { return handlers[handlerName](this$1); }); + + this.lastScrollTop = Math.floor(element.scrollTop); // for onScroll only + this.lastScrollLeft = element.scrollLeft; // for onScroll only + this.event.bind(this.element, 'scroll', function (e) { return this$1.onScroll(e); }); + updateGeometry(this); + }; + + PerfectScrollbar.prototype.update = function update () { + if (!this.isAlive) { + return; + } + + // Recalcuate negative scrollLeft adjustment + this.negativeScrollAdjustment = this.isNegativeScroll + ? this.element.scrollWidth - this.element.clientWidth + : 0; + + // Recalculate rail margins + set(this.scrollbarXRail, { display: 'block' }); + set(this.scrollbarYRail, { display: 'block' }); + this.railXMarginWidth = + toInt(get(this.scrollbarXRail).marginLeft) + + toInt(get(this.scrollbarXRail).marginRight); + this.railYMarginHeight = + toInt(get(this.scrollbarYRail).marginTop) + + toInt(get(this.scrollbarYRail).marginBottom); + + // Hide scrollbars not to affect scrollWidth and scrollHeight + set(this.scrollbarXRail, { display: 'none' }); + set(this.scrollbarYRail, { display: 'none' }); + + updateGeometry(this); + + processScrollDiff(this, 'top', 0, false, true); + processScrollDiff(this, 'left', 0, false, true); + + set(this.scrollbarXRail, { display: '' }); + set(this.scrollbarYRail, { display: '' }); + }; + + PerfectScrollbar.prototype.onScroll = function onScroll (e) { + if (!this.isAlive) { + return; + } + + updateGeometry(this); + processScrollDiff(this, 'top', this.element.scrollTop - this.lastScrollTop); + processScrollDiff( + this, + 'left', + this.element.scrollLeft - this.lastScrollLeft + ); + + this.lastScrollTop = Math.floor(this.element.scrollTop); + this.lastScrollLeft = this.element.scrollLeft; + }; + + PerfectScrollbar.prototype.destroy = function destroy () { + if (!this.isAlive) { + return; + } + + this.event.unbindAll(); + remove(this.scrollbarX); + remove(this.scrollbarY); + remove(this.scrollbarXRail); + remove(this.scrollbarYRail); + this.removePsClasses(); + + // unset elements + this.element = null; + this.scrollbarX = null; + this.scrollbarY = null; + this.scrollbarXRail = null; + this.scrollbarYRail = null; + + this.isAlive = false; + }; + + PerfectScrollbar.prototype.removePsClasses = function removePsClasses () { + this.element.className = this.element.className + .split(' ') + .filter(function (name) { return !name.match(/^ps([-_].+|)$/); }) + .join(' '); }; var PerfectScrollbar$1 = { diff --git a/dist/vue2-perfect-scrollbar.umd.min.js b/dist/vue2-perfect-scrollbar.umd.min.js index 9c3ac5d..ad34816 100644 --- a/dist/vue2-perfect-scrollbar.umd.min.js +++ b/dist/vue2-perfect-scrollbar.umd.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Vue2PerfectScrollbar={})}(this,function(t){"use strict";function v(t){return getComputedStyle(t)}function d(t,e){for(var i in e){var r=e[i];"number"==typeof r&&(r+="px"),t.style[i]=r}return t}function p(t){var e=document.createElement("div");return e.className=t,e}var i="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector);function s(t,e){if(!i)throw new Error("No element matching method supported");return i.call(t,e)}function n(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function l(t,e){return Array.prototype.filter.call(t.children,function(t){return s(t,e)})}var m={main:"ps",rtl:"ps__rtl",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",clicking:"ps--clicking",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},o={x:null,y:null};function w(t,e){var i=t.element.classList,r=m.state.scrolling(e);i.contains(r)?clearTimeout(o[e]):i.add(r)}function Y(t,e){o[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(m.state.scrolling(e))},t.settings.scrollingThreshold)}var r=function(t){this.element=t,this.handlers={}},e={isEmpty:{configurable:!0}};r.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addEventListener(t,e,!1)},r.prototype.unbind=function(e,i){var r=this;this.handlers[e]=this.handlers[e].filter(function(t){return!(!i||t===i)||(r.element.removeEventListener(e,t,!1),!1)})},r.prototype.unbindAll=function(){for(var t in this.handlers)this.unbind(t)},e.isEmpty.get=function(){var e=this;return Object.keys(this.handlers).every(function(t){return 0===e.handlers[t].length})},Object.defineProperties(r.prototype,e);var f=function(){this.eventElements=[]};function b(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}function a(t,e,i,r,n){var l;if(void 0===r&&(r=!0),void 0===n&&(n=!1),"top"===e)l=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");l=["contentWidth","containerWidth","scrollLeft","x","left","right"]}!function(t,e,i,r,n){var l=i[0],o=i[1],s=i[2],a=i[3],c=i[4],h=i[5];void 0===r&&(r=!0);void 0===n&&(n=!1);var u=t.element;t.reach[a]=null,u[s]<1&&(t.reach[a]="start");u[s]>t[l]-t[o]-1&&(t.reach[a]="end");e&&(u.dispatchEvent(b("ps-scroll-"+a)),e<0?u.dispatchEvent(b("ps-scroll-"+c)):0=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),function(t,e){var i={width:e.railXWidth},r=Math.floor(t.scrollTop);e.isRtl?i.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth-e.contentWidth:i.left=t.scrollLeft;e.isScrollbarXUsingBottom?i.bottom=e.scrollbarXBottom-r:i.top=e.scrollbarXTop+r;d(e.scrollbarXRail,i);var n={top:r,height:e.railYHeight};e.isScrollbarYUsingRight?e.isRtl?n.right=e.contentWidth-(e.negativeScrollAdjustment+t.scrollLeft)-e.scrollbarYRight-e.scrollbarYOuterWidth-9:n.right=e.scrollbarYRight-t.scrollLeft:e.isRtl?n.left=e.negativeScrollAdjustment+t.scrollLeft+2*e.containerWidth-e.contentWidth-e.scrollbarYLeft-e.scrollbarYOuterWidth:n.left=e.scrollbarYLeft+t.scrollLeft;d(e.scrollbarYRail,n),d(e.scrollbarX,{left:e.scrollbarXLeft,width:e.scrollbarXWidth-e.railBorderXWidth}),d(e.scrollbarY,{top:e.scrollbarYTop,height:e.scrollbarYHeight-e.railBorderYWidth})}(e,t),t.scrollbarXActive?e.classList.add(m.state.active("x")):(e.classList.remove(m.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=!0===t.isRtl?t.contentWidth:0),t.scrollbarYActive?e.classList.add(m.state.active("y")):(e.classList.remove(m.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)}function c(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function h(i,t){var r=t[0],n=t[1],l=t[2],o=t[3],e=t[4],s=t[5],a=t[6],c=t[7],h=t[8],u=i.element,d=null,p=null,f=null;function b(t){t.touches&&t.touches[0]&&(t[l]=t.touches[0].pageY),u[a]=d+f*(t[l]-p),w(i,c),X(i),t.stopPropagation(),t.preventDefault()}function g(){Y(i,c),i[h].classList.remove(m.state.clicking),i.event.unbind(i.ownerDocument,"mousemove",b)}function v(t,e){d=u[a],e&&t.touches&&(t[l]=t.touches[0].pageY),p=t[l],f=(i[n]-i[r])/(i[o]-i[s]),e?i.event.bind(i.ownerDocument,"touchmove",b):(i.event.bind(i.ownerDocument,"mousemove",b),i.event.once(i.ownerDocument,"mouseup",g),t.preventDefault()),i[h].classList.add(m.state.clicking),t.stopPropagation()}i.event.bind(i[e],"mousedown",function(t){v(t)}),i.event.bind(i[e],"touchstart",function(t){v(t,!0)})}var W={"click-rail":function(i){i.element,i.event.bind(i.scrollbarY,"mousedown",function(t){return t.stopPropagation()}),i.event.bind(i.scrollbarYRail,"mousedown",function(t){var e=t.pageY-window.pageYOffset-i.scrollbarYRail.getBoundingClientRect().top>i.scrollbarYTop?1:-1;i.element.scrollTop+=e*i.containerHeight,X(i),t.stopPropagation()}),i.event.bind(i.scrollbarX,"mousedown",function(t){return t.stopPropagation()}),i.event.bind(i.scrollbarXRail,"mousedown",function(t){var e=t.pageX-window.pageXOffset-i.scrollbarXRail.getBoundingClientRect().left>i.scrollbarXLeft?1:-1;i.element.scrollLeft+=e*i.containerWidth,X(i),t.stopPropagation()})},"drag-thumb":function(t){h(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x","scrollbarXRail"]),h(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y","scrollbarYRail"])},keyboard:function(l){var o=l.element;l.event.bind(l.ownerDocument,"keydown",function(t){if(!(t.isDefaultPrevented&&t.isDefaultPrevented()||t.defaultPrevented)&&(s(o,":hover")||s(l.scrollbarX,":focus")||s(l.scrollbarY,":focus"))){var e,i=document.activeElement?document.activeElement:l.ownerDocument.activeElement;if(i){if("IFRAME"===i.tagName)i=i.contentDocument.activeElement;else for(;i.shadowRoot;)i=i.shadowRoot.activeElement;if(s(e=i,"input,[contenteditable]")||s(e,"select,[contenteditable]")||s(e,"textarea,[contenteditable]")||s(e,"button,[contenteditable]"))return}var r=0,n=0;switch(t.which){case 37:r=t.metaKey?-l.contentWidth:t.altKey?-l.containerWidth:-30;break;case 38:n=t.metaKey?l.contentHeight:t.altKey?l.containerHeight:30;break;case 39:r=t.metaKey?l.contentWidth:t.altKey?l.containerWidth:30;break;case 40:n=t.metaKey?-l.contentHeight:t.altKey?-l.containerHeight:-30;break;case 32:n=t.shiftKey?l.containerHeight:-l.containerHeight;break;case 33:n=l.containerHeight;break;case 34:n=-l.containerHeight;break;case 36:n=l.contentHeight;break;case 35:n=-l.contentHeight;break;default:return}l.settings.suppressScrollX&&0!==r||l.settings.suppressScrollY&&0!==n||(o.scrollTop-=n,o.scrollLeft+=r,X(l),function(t,e){var i=Math.floor(o.scrollTop);if(0===t){if(!l.scrollbarYActive)return!1;if(0===i&&0=l.contentHeight-l.containerHeight&&e<0)return!l.settings.wheelPropagation}var r=o.scrollLeft;if(0===e){if(!l.scrollbarXActive)return!1;if(0===r&&t<0||r>=l.contentWidth-l.containerWidth&&0Math.abs(s)?h||u:d||p)||!b.settings.wheelPropagation))&&!t.ctrlKey&&(t.stopPropagation(),t.preventDefault())}}void 0!==window.onwheel?b.event.bind(g,"wheel",t):void 0!==window.onmousewheel&&b.event.bind(g,"mousewheel",t)},touch:function(s){if(y.supportsTouch||y.supportsIePointer){var a=s.element,c={},h=0,u={},i=null;y.supportsTouch?(s.event.bind(a,"touchstart",t),s.event.bind(a,"touchmove",e),s.event.bind(a,"touchend",r)):y.supportsIePointer&&(window.PointerEvent?(s.event.bind(a,"pointerdown",t),s.event.bind(a,"pointermove",e),s.event.bind(a,"pointerup",r)):window.MSPointerEvent&&(s.event.bind(a,"MSPointerDown",t),s.event.bind(a,"MSPointerMove",e),s.event.bind(a,"MSPointerUp",r)))}function d(t,e){a.scrollTop-=e,a.scrollLeft-=t,X(s)}function p(t){return t.targetTouches?t.targetTouches[0]:t}function f(t){return!(t.pointerType&&"pen"===t.pointerType&&0===t.buttons||(!t.targetTouches||1!==t.targetTouches.length)&&(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE))}function t(t){if(f(t)){var e=p(t);c.pageX=e.pageX,c.pageY=e.pageY,h=(new Date).getTime(),null!==i&&clearInterval(i)}}function e(t){if(f(t)){var e=p(t),i={pageX:e.pageX,pageY:e.pageY},r=i.pageX-c.pageX,n=i.pageY-c.pageY;if(function(t,e,i){if(!a.contains(t))return!1;for(var r=t;r&&r!==a;){if(r.classList.contains(m.element.consuming))return!0;var n=v(r);if(i&&n.overflowY.match(/(scroll|auto)/)){var l=r.scrollHeight-r.clientHeight;if(0=this.contentWidth-this.containerWidth?"end":null,y:t.scrollTop<=0?"start":t.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return W[t](i)}),this.lastScrollTop=Math.floor(t.scrollTop),this.lastScrollLeft=t.scrollLeft,this.event.bind(this.element,"scroll",function(t){return i.onScroll(t)}),X(this)};u.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,d(this.scrollbarXRail,{display:"block"}),d(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=g(v(this.scrollbarXRail).marginLeft)+g(v(this.scrollbarXRail).marginRight),this.railYMarginHeight=g(v(this.scrollbarYRail).marginTop)+g(v(this.scrollbarYRail).marginBottom),d(this.scrollbarXRail,{display:"none"}),d(this.scrollbarYRail,{display:"none"}),X(this),a(this,"top",0,!1,!0),a(this,"left",0,!1,!0),d(this.scrollbarXRail,{display:""}),d(this.scrollbarYRail,{display:""}))},u.prototype.onScroll=function(t){this.isAlive&&(X(this),a(this,"top",this.element.scrollTop-this.lastScrollTop),a(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=Math.floor(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)},u.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),n(this.scrollbarX),n(this.scrollbarY),n(this.scrollbarXRail),n(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},u.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")};var L={name:"PerfectScrollbar",props:{options:{type:Object,required:!1,default:function(){}},tag:{type:String,required:!1,default:"div"},watchOptions:{type:Boolean,required:!1,default:!1}},data:function(){return{ps:null}},watch:{watchOptions:function(t){!t&&this.watcher?this.watcher():this.createWatcher()}},mounted:function(){this.create(),this.watchOptions&&this.createWatcher()},updated:function(){var t=this;this.$nextTick(function(){t.update()})},beforeDestroy:function(){this.destroy()},methods:{create:function(){this.ps&&this.$isServer||(this.ps=new u(this.$refs.container,this.options))},createWatcher:function(){var t=this;this.watcher=this.$watch("options",function(){t.destroy(),t.create()},{deep:!0})},update:function(){this.ps&&this.ps.update()},destroy:function(){this.ps&&(this.ps.destroy(),this.ps=null)}},render:function(t){return t(this.tag,{ref:"container",class:"ps",on:this.$listeners},this.$slots.default)}};function R(t,e){e&&(e.name&&"string"==typeof e.name&&(L.name=e.name),e.options&&"object"==typeof e.options&&(L.props.options.default=function(){return e.options}),e.tag&&"string"==typeof e.tag&&(L.props.tag.default=e.tag),e.watchOptions&&"boolean"==typeof e.watchOptions&&(L.props.watchOptions=e.watchOptions)),t.component(L.name,L)}t.install=R,t.PerfectScrollbar=L,t.default=R,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Vue2PerfectScrollbar={})}(this,function(t){"use strict";function v(t){return getComputedStyle(t)}function d(t,e){for(var i in e){var r=e[i];"number"==typeof r&&(r+="px"),t.style[i]=r}return t}function p(t){var e=document.createElement("div");return e.className=t,e}var i="undefined"!=typeof Element&&(Element.prototype.matches||Element.prototype.webkitMatchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector);function s(t,e){if(!i)throw new Error("No element matching method supported");return i.call(t,e)}function n(t){t.remove?t.remove():t.parentNode&&t.parentNode.removeChild(t)}function l(t,e){return Array.prototype.filter.call(t.children,function(t){return s(t,e)})}var m={main:"ps",rtl:"ps__rtl",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",clicking:"ps--clicking",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},o={x:null,y:null};function w(t,e){var i=t.element.classList,r=m.state.scrolling(e);i.contains(r)?clearTimeout(o[e]):i.add(r)}function Y(t,e){o[e]=setTimeout(function(){return t.isAlive&&t.element.classList.remove(m.state.scrolling(e))},t.settings.scrollingThreshold)}var r=function(t){this.element=t,this.handlers={}},e={isEmpty:{configurable:!0}};r.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addEventListener(t,e,!1)},r.prototype.unbind=function(e,i){var r=this;this.handlers[e]=this.handlers[e].filter(function(t){return!(!i||t===i)||(r.element.removeEventListener(e,t,!1),!1)})},r.prototype.unbindAll=function(){for(var t in this.handlers)this.unbind(t)},e.isEmpty.get=function(){var e=this;return Object.keys(this.handlers).every(function(t){return 0===e.handlers[t].length})},Object.defineProperties(r.prototype,e);var f=function(){this.eventElements=[]};function b(t){if("function"==typeof window.CustomEvent)return new CustomEvent(t);var e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,void 0),e}function a(t,e,i,r,n){var l;if(void 0===r&&(r=!0),void 0===n&&(n=!1),"top"===e)l=["contentHeight","containerHeight","scrollTop","y","up","down"];else{if("left"!==e)throw new Error("A proper axis should be provided");l=["contentWidth","containerWidth","scrollLeft","x","left","right"]}!function(t,e,i,r,n){var l=i[0],o=i[1],s=i[2],a=i[3],c=i[4],h=i[5];void 0===r&&(r=!0);void 0===n&&(n=!1);var u=t.element;t.reach[a]=null,u[s]<1&&(t.reach[a]="start");u[s]>t[l]-t[o]-1&&(t.reach[a]="end");e&&(u.dispatchEvent(b("ps-scroll-"+a)),e<0?u.dispatchEvent(b("ps-scroll-"+c)):0=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),function(t,e){var i={width:e.railXWidth},r=Math.floor(t.scrollTop);e.isRtl?i.left=e.negativeScrollAdjustment+t.scrollLeft+e.containerWidth-e.contentWidth:i.left=t.scrollLeft;e.isScrollbarXUsingBottom?i.bottom=e.scrollbarXBottom-r:i.top=e.scrollbarXTop+r;d(e.scrollbarXRail,i);var n={top:r,height:e.railYHeight};e.isScrollbarYUsingRight?e.isRtl?n.right=e.contentWidth-(e.negativeScrollAdjustment+t.scrollLeft)-e.scrollbarYRight-e.scrollbarYOuterWidth-9:n.right=e.scrollbarYRight-t.scrollLeft:e.isRtl?n.left=e.negativeScrollAdjustment+t.scrollLeft+2*e.containerWidth-e.contentWidth-e.scrollbarYLeft-e.scrollbarYOuterWidth:n.left=e.scrollbarYLeft+t.scrollLeft;d(e.scrollbarYRail,n),d(e.scrollbarX,{left:e.scrollbarXLeft,width:e.scrollbarXWidth-e.railBorderXWidth}),d(e.scrollbarY,{top:e.scrollbarYTop,height:e.scrollbarYHeight-e.railBorderYWidth})}(e,t),t.scrollbarXActive?e.classList.add(m.state.active("x")):(e.classList.remove(m.state.active("x")),t.scrollbarXWidth=0,t.scrollbarXLeft=0,e.scrollLeft=!0===t.isRtl?t.contentWidth:0),t.scrollbarYActive?e.classList.add(m.state.active("y")):(e.classList.remove(m.state.active("y")),t.scrollbarYHeight=0,t.scrollbarYTop=0,e.scrollTop=0)}function c(t,e){return t.settings.minScrollbarLength&&(e=Math.max(e,t.settings.minScrollbarLength)),t.settings.maxScrollbarLength&&(e=Math.min(e,t.settings.maxScrollbarLength)),e}function h(i,t){var r=t[0],n=t[1],l=t[2],o=t[3],e=t[4],s=t[5],a=t[6],c=t[7],h=t[8],u=i.element,d=null,p=null,f=null;function b(t){t.touches&&t.touches[0]&&(t[l]=t.touches[0].pageY),u[a]=d+f*(t[l]-p),w(i,c),X(i),t.stopPropagation(),t.preventDefault()}function g(){Y(i,c),i[h].classList.remove(m.state.clicking),i.event.unbind(i.ownerDocument,"mousemove",b)}function v(t,e){d=u[a],e&&t.touches&&(t[l]=t.touches[0].pageY),p=t[l],f=(i[n]-i[r])/(i[o]-i[s]),e?i.event.bind(i.ownerDocument,"touchmove",b):(i.event.bind(i.ownerDocument,"mousemove",b),i.event.once(i.ownerDocument,"mouseup",g),t.preventDefault()),i[h].classList.add(m.state.clicking),t.stopPropagation()}i.event.bind(i[e],"mousedown",function(t){v(t)}),i.event.bind(i[e],"touchstart",function(t){v(t,!0)})}var W={"click-rail":function(i){i.element,i.event.bind(i.scrollbarY,"mousedown",function(t){return t.stopPropagation()}),i.event.bind(i.scrollbarYRail,"mousedown",function(t){var e=t.pageY-window.pageYOffset-i.scrollbarYRail.getBoundingClientRect().top>i.scrollbarYTop?1:-1;i.element.scrollTop+=e*i.containerHeight,X(i),t.stopPropagation()}),i.event.bind(i.scrollbarX,"mousedown",function(t){return t.stopPropagation()}),i.event.bind(i.scrollbarXRail,"mousedown",function(t){var e=t.pageX-window.pageXOffset-i.scrollbarXRail.getBoundingClientRect().left>i.scrollbarXLeft?1:-1;i.element.scrollLeft+=e*i.containerWidth,X(i),t.stopPropagation()})},"drag-thumb":function(t){h(t,["containerWidth","contentWidth","pageX","railXWidth","scrollbarX","scrollbarXWidth","scrollLeft","x","scrollbarXRail"]),h(t,["containerHeight","contentHeight","pageY","railYHeight","scrollbarY","scrollbarYHeight","scrollTop","y","scrollbarYRail"])},keyboard:function(l){var o=l.element;l.event.bind(l.ownerDocument,"keydown",function(t){if(!(t.isDefaultPrevented&&t.isDefaultPrevented()||t.defaultPrevented)&&(s(o,":hover")||s(l.scrollbarX,":focus")||s(l.scrollbarY,":focus"))){var e,i=document.activeElement?document.activeElement:l.ownerDocument.activeElement;if(i){if("IFRAME"===i.tagName)i=i.contentDocument.activeElement;else for(;i.shadowRoot;)i=i.shadowRoot.activeElement;if(s(e=i,"input,[contenteditable]")||s(e,"select,[contenteditable]")||s(e,"textarea,[contenteditable]")||s(e,"button,[contenteditable]"))return}var r=0,n=0;switch(t.which){case 37:r=t.metaKey?-l.contentWidth:t.altKey?-l.containerWidth:-30;break;case 38:n=t.metaKey?l.contentHeight:t.altKey?l.containerHeight:30;break;case 39:r=t.metaKey?l.contentWidth:t.altKey?l.containerWidth:30;break;case 40:n=t.metaKey?-l.contentHeight:t.altKey?-l.containerHeight:-30;break;case 32:n=t.shiftKey?l.containerHeight:-l.containerHeight;break;case 33:n=l.containerHeight;break;case 34:n=-l.containerHeight;break;case 36:n=l.contentHeight;break;case 35:n=-l.contentHeight;break;default:return}l.settings.suppressScrollX&&0!==r||l.settings.suppressScrollY&&0!==n||(o.scrollTop-=n,o.scrollLeft+=r,X(l),function(t,e){var i=Math.floor(o.scrollTop);if(0===t){if(!l.scrollbarYActive)return!1;if(0===i&&0=l.contentHeight-l.containerHeight&&e<0)return!l.settings.wheelPropagation}var r=o.scrollLeft;if(0===e){if(!l.scrollbarXActive)return!1;if(0===r&&t<0||r>=l.contentWidth-l.containerWidth&&0Math.abs(s)?h||u:d||p)||!b.settings.wheelPropagation))&&!t.ctrlKey&&(t.stopPropagation(),t.preventDefault())}}void 0!==window.onwheel?b.event.bind(g,"wheel",t):void 0!==window.onmousewheel&&b.event.bind(g,"mousewheel",t)},touch:function(s){if(y.supportsTouch||y.supportsIePointer){var a=s.element,c={},h=0,u={},i=null;y.supportsTouch?(s.event.bind(a,"touchstart",t),s.event.bind(a,"touchmove",e),s.event.bind(a,"touchend",r)):y.supportsIePointer&&(window.PointerEvent?(s.event.bind(a,"pointerdown",t),s.event.bind(a,"pointermove",e),s.event.bind(a,"pointerup",r)):window.MSPointerEvent&&(s.event.bind(a,"MSPointerDown",t),s.event.bind(a,"MSPointerMove",e),s.event.bind(a,"MSPointerUp",r)))}function d(t,e){a.scrollTop-=e,a.scrollLeft-=t,X(s)}function p(t){return t.targetTouches?t.targetTouches[0]:t}function f(t){return!(t.pointerType&&"pen"===t.pointerType&&0===t.buttons||(!t.targetTouches||1!==t.targetTouches.length)&&(!t.pointerType||"mouse"===t.pointerType||t.pointerType===t.MSPOINTER_TYPE_MOUSE))}function t(t){if(f(t)){var e=p(t);c.pageX=e.pageX,c.pageY=e.pageY,h=(new Date).getTime(),null!==i&&clearInterval(i)}}function e(t){if(f(t)){var e=p(t),i={pageX:e.pageX,pageY:e.pageY},r=i.pageX-c.pageX,n=i.pageY-c.pageY;if(function(t,e,i){if(!a.contains(t))return!1;for(var r=t;r&&r!==a;){if(r.classList.contains(m.element.consuming))return!0;var n=v(r);if(i&&n.overflowY.match(/(scroll|auto)/)){var l=r.scrollHeight-r.clientHeight;if(0=this.contentWidth-this.containerWidth?"end":null,y:t.scrollTop<=0?"start":t.scrollTop>=this.contentHeight-this.containerHeight?"end":null},this.isAlive=!0,this.settings.handlers.forEach(function(t){return W[t](i)}),this.lastScrollTop=Math.floor(t.scrollTop),this.lastScrollLeft=t.scrollLeft,this.event.bind(this.element,"scroll",function(t){return i.onScroll(t)}),X(this)};u.prototype.update=function(){this.isAlive&&(this.negativeScrollAdjustment=this.isNegativeScroll?this.element.scrollWidth-this.element.clientWidth:0,d(this.scrollbarXRail,{display:"block"}),d(this.scrollbarYRail,{display:"block"}),this.railXMarginWidth=g(v(this.scrollbarXRail).marginLeft)+g(v(this.scrollbarXRail).marginRight),this.railYMarginHeight=g(v(this.scrollbarYRail).marginTop)+g(v(this.scrollbarYRail).marginBottom),d(this.scrollbarXRail,{display:"none"}),d(this.scrollbarYRail,{display:"none"}),X(this),a(this,"top",0,!1,!0),a(this,"left",0,!1,!0),d(this.scrollbarXRail,{display:""}),d(this.scrollbarYRail,{display:""}))},u.prototype.onScroll=function(t){this.isAlive&&(X(this),a(this,"top",this.element.scrollTop-this.lastScrollTop),a(this,"left",this.element.scrollLeft-this.lastScrollLeft),this.lastScrollTop=Math.floor(this.element.scrollTop),this.lastScrollLeft=this.element.scrollLeft)},u.prototype.destroy=function(){this.isAlive&&(this.event.unbindAll(),n(this.scrollbarX),n(this.scrollbarY),n(this.scrollbarXRail),n(this.scrollbarYRail),this.removePsClasses(),this.element=null,this.scrollbarX=null,this.scrollbarY=null,this.scrollbarXRail=null,this.scrollbarYRail=null,this.isAlive=!1)},u.prototype.removePsClasses=function(){this.element.className=this.element.className.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")};var L={name:"PerfectScrollbar",props:{options:{type:Object,required:!1,default:function(){}},tag:{type:String,required:!1,default:"div"},watchOptions:{type:Boolean,required:!1,default:!1}},data:function(){return{ps:null}},watch:{watchOptions:function(t){!t&&this.watcher?this.watcher():this.createWatcher()}},mounted:function(){this.create(),this.watchOptions&&this.createWatcher()},updated:function(){var t=this;this.$nextTick(function(){t.update()})},beforeDestroy:function(){this.destroy()},methods:{create:function(){this.ps&&this.$isServer||(this.ps=new u(this.$refs.container,this.options))},createWatcher:function(){var t=this;this.watcher=this.$watch("options",function(){t.destroy(),t.create()},{deep:!0})},update:function(){this.ps&&this.ps.update()},destroy:function(){this.ps&&(this.ps.destroy(),this.ps=null)}},render:function(t){return t(this.tag,{ref:"container",class:"ps",on:this.$listeners},this.$slots.default)}};function R(t,e){e&&(e.name&&"string"==typeof e.name&&(L.name=e.name),e.options&&"object"==typeof e.options&&(L.props.options.default=function(){return e.options}),e.tag&&"string"==typeof e.tag&&(L.props.tag.default=e.tag),e.watchOptions&&"boolean"==typeof e.watchOptions&&(L.props.watchOptions=e.watchOptions)),t.component(L.name,L)}t.install=R,t.PerfectScrollbar=L,t.default=R,Object.defineProperty(t,"__esModule",{value:!0})}); diff --git a/package.json b/package.json index 09df7dc..ac6fc47 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ }, "dependencies": { "cssnano": "^4.1.3", - "perfect-scrollbar": "^1.5.0", + "perfect-scrollbar": "^1.5.2", "postcss-import": "^12.0.0" } } diff --git a/yarn.lock b/yarn.lock index 38d962d..e5bf420 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4866,10 +4866,10 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" -perfect-scrollbar@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/perfect-scrollbar/-/perfect-scrollbar-1.5.0.tgz#821d224ed8ff61990c23f26db63048cdc75b6b83" - integrity sha512-NrNHJn5mUGupSiheBTy6x+6SXCFbLlm8fVZh9moIzw/LgqElN5q4ncR4pbCBCYuCJ8Kcl9mYM0NgDxvW+b4LxA== +perfect-scrollbar@^1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/perfect-scrollbar/-/perfect-scrollbar-1.5.2.tgz#41167ac6bc95e3a5e87a7402fa36fdacca9bc298" + integrity sha512-McHAinFkyzKbBZrFtb4MT2mxkehp15KvOX/UrjB8C5EZZXHTHgyETo5IGFYtHRTI2Pb2bsV0OE0YnkjT9Cw3aw== performance-now@^2.1.0: version "2.1.0"