├── .babelrc ├── .gitignore ├── README.md ├── dist └── build.js ├── index.html ├── package.json ├── src ├── App.vue ├── assets │ └── test.jpg ├── components │ └── scrollbar │ │ ├── index.js │ │ ├── perfect-scrollbar │ │ ├── index.js │ │ ├── lib │ │ │ ├── class.js │ │ │ ├── dom.js │ │ │ ├── event-manager.js │ │ │ ├── guid.js │ │ │ └── helper.js │ │ └── plugin │ │ │ ├── default-setting.js │ │ │ ├── destroy.js │ │ │ ├── handler │ │ │ ├── click-rail.js │ │ │ ├── drag-scrollbar.js │ │ │ ├── keyboard.js │ │ │ ├── mouse-wheel.js │ │ │ ├── native-scroll.js │ │ │ ├── selection.js │ │ │ └── touch.js │ │ │ ├── initialize.js │ │ │ ├── instances.js │ │ │ ├── update-geometry.js │ │ │ ├── update-scroll.js │ │ │ └── update.js │ │ └── scrollbar.vue └── main.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }] 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-perfect-scrollbar 2 | 3 | > A scrollbar beautify module, build with vuejs, rely on perfect-scroll.js. 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production with minification 15 | npm run build 16 | ``` 17 | 18 | For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader). 19 | -------------------------------------------------------------------------------- /dist/build.js: -------------------------------------------------------------------------------- 1 | !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=35)}([function(e,t,n){"use strict";function r(e){function t(){l.add(e,"ps-focus")}function n(){l.remove(e,"ps-focus")}var r=this;r.settings=s.clone(c),r.containerWidth=null,r.containerHeight=null,r.contentWidth=null,r.contentHeight=null,r.isRtl="rtl"===u.css(e,"direction"),r.isNegativeScroll=function(){var t=e.scrollLeft,n=null;return e.scrollLeft=-1,n=e.scrollLeft<0,e.scrollLeft=t,n}(),r.negativeScrollAdjustment=r.isNegativeScroll?e.scrollWidth-e.clientWidth:0,r.event=new d,r.ownerDocument=e.ownerDocument||document,r.scrollbarXRail=u.appendTo(u.e("div","ps-scrollbar-x-rail"),e),r.scrollbarX=u.appendTo(u.e("div","ps-scrollbar-x"),r.scrollbarXRail),r.scrollbarX.setAttribute("tabindex",0),r.event.bind(r.scrollbarX,"focus",t),r.event.bind(r.scrollbarX,"blur",n),r.scrollbarXActive=null,r.scrollbarXWidth=null,r.scrollbarXLeft=null,r.scrollbarXBottom=s.toInt(u.css(r.scrollbarXRail,"bottom")),r.isScrollbarXUsingBottom=r.scrollbarXBottom===r.scrollbarXBottom,r.scrollbarXTop=r.isScrollbarXUsingBottom?null:s.toInt(u.css(r.scrollbarXRail,"top")),r.railBorderXWidth=s.toInt(u.css(r.scrollbarXRail,"borderLeftWidth"))+s.toInt(u.css(r.scrollbarXRail,"borderRightWidth")),u.css(r.scrollbarXRail,"display","block"),r.railXMarginWidth=s.toInt(u.css(r.scrollbarXRail,"marginLeft"))+s.toInt(u.css(r.scrollbarXRail,"marginRight")),u.css(r.scrollbarXRail,"display",""),r.railXWidth=null,r.railXRatio=null,r.scrollbarYRail=u.appendTo(u.e("div","ps-scrollbar-y-rail"),e),r.scrollbarY=u.appendTo(u.e("div","ps-scrollbar-y"),r.scrollbarYRail),r.scrollbarY.setAttribute("tabindex",0),r.event.bind(r.scrollbarY,"focus",t),r.event.bind(r.scrollbarY,"blur",n),r.scrollbarYActive=null,r.scrollbarYHeight=null,r.scrollbarYTop=null,r.scrollbarYRight=s.toInt(u.css(r.scrollbarYRail,"right")),r.isScrollbarYUsingRight=r.scrollbarYRight===r.scrollbarYRight,r.scrollbarYLeft=r.isScrollbarYUsingRight?null:s.toInt(u.css(r.scrollbarYRail,"left")),r.scrollbarYOuterWidth=r.isRtl?s.outerWidth(r.scrollbarY):null,r.railBorderYWidth=s.toInt(u.css(r.scrollbarYRail,"borderTopWidth"))+s.toInt(u.css(r.scrollbarYRail,"borderBottomWidth")),u.css(r.scrollbarYRail,"display","block"),r.railYMarginHeight=s.toInt(u.css(r.scrollbarYRail,"marginTop"))+s.toInt(u.css(r.scrollbarYRail,"marginBottom")),u.css(r.scrollbarYRail,"display",""),r.railYHeight=null,r.railYRatio=null}function o(e){return e.getAttribute("data-ps-id")}function i(e,t){e.setAttribute("data-ps-id",t)}function a(e){e.removeAttribute("data-ps-id")}var s=n(1),l=n(5),c=n(16),u=n(4),d=n(14),p=n(15),f={};t.add=function(e){var t=p();return i(e,t),f[t]=new r(e),f[t]},t.remove=function(e){delete f[o(e)],a(e)},t.get=function(e){return f[o(e)]}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(5),i=n(4),a=t.toInt=function(e){return parseInt(e,10)||0},s=t.clone=function(e){if(null===e)return null;if(e.constructor===Array)return e.map(s);if("object"===("undefined"==typeof e?"undefined":r(e))){var t={};for(var n in e)t[n]=s(e[n]);return t}return e};t.extend=function(e,t){var n=s(e);for(var r in t)n[r]=s(t[r]);return n},t.isEditable=function(e){return i.matches(e,"input,[contenteditable]")||i.matches(e,"select,[contenteditable]")||i.matches(e,"textarea,[contenteditable]")||i.matches(e,"button,[contenteditable]")},t.removePsClasses=function(e){for(var t=o.list(e),n=0;n0&&n.forEach(function(e){s.remove(e)}),s.appendTo(t.scrollbarXRail,e)),e.contains(t.scrollbarYRail)||(n=s.queryChildren(e,".ps-scrollbar-y-rail"),n.length>0&&n.forEach(function(e){s.remove(e)}),s.appendTo(t.scrollbarYRail,e)),!t.settings.suppressScrollX&&t.containerWidth+t.settings.scrollXMarginOffset=t.railXWidth-t.scrollbarXWidth&&(t.scrollbarXLeft=t.railXWidth-t.scrollbarXWidth),t.scrollbarYTop>=t.railYHeight-t.scrollbarYHeight&&(t.scrollbarYTop=t.railYHeight-t.scrollbarYHeight),o(e,t),t.scrollbarXActive?a.add(e,"ps-active-x"):(a.remove(e,"ps-active-x"),t.scrollbarXWidth=0,t.scrollbarXLeft=0,c(e,"left",0)),t.scrollbarYActive?a.add(e,"ps-active-y"):(a.remove(e,"ps-active-y"),t.scrollbarYHeight=0,t.scrollbarYTop=0,c(e,"top",0))}},function(e,t,n){"use strict";var r,o,i=n(0),a=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!0),t};e.exports=function(e,t,n){if("undefined"==typeof e)throw"You must provide an element to the update-scroll function";if("undefined"==typeof t)throw"You must provide an axis to the update-scroll function";if("undefined"==typeof n)throw"You must provide a value to the update-scroll function";"top"===t&&n<=0&&(e.scrollTop=n=0,e.dispatchEvent(a("ps-y-reach-start"))),"left"===t&&n<=0&&(e.scrollLeft=n=0,e.dispatchEvent(a("ps-x-reach-start")));var s=i.get(e);"top"===t&&n>=s.contentHeight-s.containerHeight&&(n=s.contentHeight-s.containerHeight,n-e.scrollTop<=1?n=e.scrollTop:e.scrollTop=n,e.dispatchEvent(a("ps-y-reach-end"))),"left"===t&&n>=s.contentWidth-s.containerWidth&&(n=s.contentWidth-s.containerWidth,n-e.scrollLeft<=1?n=e.scrollLeft:e.scrollLeft=n,e.dispatchEvent(a("ps-x-reach-end"))),r||(r=e.scrollTop),o||(o=e.scrollLeft),"top"===t&&nr&&e.dispatchEvent(a("ps-scroll-down")),"left"===t&&no&&e.dispatchEvent(a("ps-scroll-right")),"top"===t&&(e.scrollTop=r=n,e.dispatchEvent(a("ps-scroll-y"))),"left"===t&&(e.scrollLeft=o=n,e.dispatchEvent(a("ps-scroll-x")))}},function(e,t){"use strict";function n(e,t){return window.getComputedStyle(e)[t]}function r(e,t,n){return"number"==typeof n&&(n=n.toString()+"px"),e.style[t]=n,e}function o(e,t){for(var n in t){var r=t[n];"number"==typeof r&&(r=r.toString()+"px"),e.style[n]=r}return e}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},a={};a.e=function(e,t){var n=document.createElement(e);return n.className=t,n},a.appendTo=function(e,t){return t.appendChild(e),e},a.css=function(e,t,a){return"object"===("undefined"==typeof t?"undefined":i(t))?o(e,t):"undefined"==typeof a?n(e,t):r(e,t,a)},a.matches=function(e,t){return"undefined"!=typeof e.matches?e.matches(t):"undefined"!=typeof e.matchesSelector?e.matchesSelector(t):"undefined"!=typeof e.webkitMatchesSelector?e.webkitMatchesSelector(t):"undefined"!=typeof e.mozMatchesSelector?e.mozMatchesSelector(t):"undefined"!=typeof e.msMatchesSelector?e.msMatchesSelector(t):void 0},a.remove=function(e){"undefined"!=typeof e.remove?e.remove():e.parentNode&&e.parentNode.removeChild(e)},a.queryChildren=function(e,t){return Array.prototype.filter.call(e.childNodes,function(e){return a.matches(e,t)})},e.exports=a},function(e,t){"use strict";function n(e,t){var n=e.className.split(" ");n.indexOf(t)<0&&n.push(t),e.className=n.join(" ")}function r(e,t){var n=e.className.split(" "),r=n.indexOf(t);r>=0&&n.splice(r,1),e.className=n.join(" ")}t.add=function(e,t){e.classList?e.classList.add(t):n(e,t)},t.remove=function(e,t){e.classList?e.classList.remove(t):r(e,t)},t.list=function(e){return e.classList?Array.prototype.slice.apply(e.classList):e.className.split(" ")}},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&m.splice(t,1)}function a(e){var t=document.createElement("style");return t.type="text/css",o(e,t),t}function s(e,t){var n,r,o;if(t.singleton){var s=v++;n=h||(h=a(t)),r=l.bind(null,n,s,!1),o=l.bind(null,n,s,!0)}else n=a(t),r=c.bind(null,n),o=function(){i(n)};return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}function l(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=g(t,o);else{var i=document.createTextNode(o),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(i,a[t]):e.appendChild(i)}}function c(e,t){var n=t.css,r=t.media,o=t.sourceMap;if(r&&e.setAttribute("media",r),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var u={},d=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},p=d(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),f=d(function(){return document.head||document.getElementsByTagName("head")[0]}),h=null,v=0,m=[];e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");t=t||{},"undefined"==typeof t.singleton&&(t.singleton=p()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var o=r(e);return n(o,t),function(e){for(var i=[],a=0;a-1)return e.splice(n,1)}}function i(e,t){return gr.call(e,t)}function a(e){return"string"==typeof e||"number"==typeof e}function s(e){var t=Object.create(null);return function(n){var r=t[n];return r||(t[n]=e(n))}}function l(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n}function c(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function u(e,t){for(var n in t)e[n]=t[n];return e}function d(e){return null!==e&&"object"==typeof e}function p(e){return kr.call(e)===Cr}function f(e){for(var t=e[0]||{},n=1;n$r._maxUpdateCount)){po("You may have an infinite update loop "+(e.user?'in watcher with expression "'+e.expression+'"':"in a component render function."),e.vm);break}}Lr&&$r.devtools&&Lr.emit("flush"),_()}function k(e){var t=e.id;if(null==Fr[t]){if(Fr[t]=!0,qr){for(var n=Ur.length-1;n>=0&&Ur[n].id>e.id;)n--;Ur.splice(Math.max(n,Jr)+1,0,e)}else Ur.push(e);Vr||(Vr=!0,jr(x))}}function C(e,t){var n,r;t||(t=Gr,t.clear());var o=Array.isArray(e),i=d(e);if((o||i)&&Object.isExtensible(e)){if(e.__ob__){var a=e.__ob__.dep.id;if(t.has(a))return;t.add(a)}if(o)for(n=e.length;n--;)C(e[n],t);else if(i)for(r=Object.keys(e),n=r.length;n--;)C(e[r[n]],t)}}function A(e,t){e.__proto__=t}function $(e,t,n){for(var r=0,o=n.length;r1?c(n):n;for(var r=c(arguments,1),o=0,i=n.length;o-1?Do[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Do[e]=/HTMLUnknownElement/.test(t.toString())}function ze(e){if("string"==typeof e){var t=e;if(e=document.querySelector(e),!e)return po("Cannot find element: "+t),document.createElement("div")}return e}function Ve(e){return document.createElement(e)}function qe(e,t){return document.createElementNS(Oo[e],t)}function Je(e){return document.createTextNode(e)}function Ke(e){return document.createComment(e)}function Ze(e,t,n){e.insertBefore(t,n)}function Ge(e,t){e.removeChild(t)}function Qe(e,t){e.appendChild(t)}function et(e){return e.parentNode}function tt(e){return e.nextSibling}function nt(e){return e.tagName}function rt(e,t){e.textContent=t}function ot(e){return e.childNodes}function it(e,t,n){e.setAttribute(t,n)}function at(e,t){var n=e.data.ref;if(n){var r=e.context,i=e.child||e.elm,a=r.$refs;t?Array.isArray(a[n])?o(a[n],i):a[n]===i&&(a[n]=void 0):e.data.refInFor?Array.isArray(a[n])?a[n].push(i):a[n]=[i]:a[n]=i}}function st(e){return null==e}function lt(e){return null!=e}function ct(e,t){return e.key===t.key&&e.tag===t.tag&&e.isComment===t.isComment&&!e.data==!t.data}function ut(e,t,n){var r,o,i={};for(r=t;r<=n;++r)o=e[r].key,lt(o)&&(i[o]=r);return i}function dt(t){function n(e){return new io(C.tagName(e).toLowerCase(),{},[],(void 0),e)}function r(e,t){function n(){0===--n.listeners&&o(e)}return n.listeners=t,n}function o(e){var t=C.parentNode(e);C.removeChild(t,e)}function i(e,t,n){var r,o,s=e.data;if(e.isRootInsert=!n,lt(s)&&(lt(r=s.hook)&<(r=r.init)&&r(e),lt(r=e.child)))return c(e,t),e.elm;var d=e.children,p=e.tag;if(lt(p)){if(e.ns||$r.ignoredElements&&$r.ignoredElements.indexOf(p)>-1||!$r.isUnknownElement(p)||po("Unknown custom element: <"+p+'> - did you register the component correctly? For recursive components, make sure to provide the "name" option.',e.context),o=e.elm=e.ns?C.createElementNS(e.ns,p):C.createElement(p),u(e),Array.isArray(d))for(r=0;rh?(c=st(n[b+1])?null:n[b+1].elm,d(e,c,n,p,b,r)):p>b&&f(e,t,u,h)}function m(e,t,n,r){if(e!==t){if(t.isStatic&&e.isStatic&&t.key===e.key&&t.isCloned)return void(t.elm=e.elm);var o,i,a=lt(o=t.data);a&<(i=o.hook)&<(o=i.prepatch)&&o(e,t);var l=t.elm=e.elm,c=e.children,u=t.children;if(a&&s(t)){for(o=0;o, or missing . Bailing hydration and performing full client-side render.")}e=n(e)}if(a=e.elm,l=C.parentNode(a),i(t,u),t.parent&&(t.parent.elm=t.elm,s(t)))for(var h=0;h-1?t.split(/\s+/).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+e.getAttribute("class")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function wt(e,t){if(e.classList)t.indexOf(" ")>-1?t.split(/\s+/).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t);else{for(var n=" "+e.getAttribute("class")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");e.setAttribute("class",n.trim())}}function _t(e){di(function(){di(e)})}function xt(e,t){(e._transitionClasses||(e._transitionClasses=[])).push(t),yt(e,t)}function kt(e,t){e._transitionClasses&&o(e._transitionClasses,t),wt(e,t)}function Ct(e,t,n){var r=At(e,t),o=r.type,i=r.timeout,a=r.propCount;if(!o)return n();var s=o===ii?li:ui,l=0,c=function(){e.removeEventListener(s,u),n()},u=function(t){t.target===e&&++l>=a&&c()};setTimeout(function(){l0&&(n=ii,u=a,d=i.length):t===ai?c>0&&(n=ai,u=c,d=l.length):(u=Math.max(a,c),n=u>0?a>c?ii:ai:null,d=n?n===ii?i.length:l.length:0);var p=n===ii&&pi.test(r[si+"Property"]);return{type:n,timeout:u,propCount:d,hasTransform:p}}function $t(e,t){return Math.max.apply(null,t.map(function(t,n){return St(t)+St(e[n])}))}function St(e){return 1e3*Number(e.slice(0,-1))}function Tt(e){var t=e.elm;t._leaveCb&&(t._leaveCb.cancelled=!0,t._leaveCb());var n=Lt(e.data.transition);if(n&&!t._enterCb&&1===t.nodeType){var r=n.css,o=n.type,i=n.enterClass,a=n.enterActiveClass,s=n.appearClass,l=n.appearActiveClass,c=n.beforeEnter,u=n.enter,d=n.afterEnter,p=n.enterCancelled,f=n.beforeAppear,h=n.appear,v=n.afterAppear,m=n.appearCancelled,g=so.$vnode,b=g&&g.parent?g.parent.context:so,y=!b._isMounted||!e.isRootInsert;if(!y||h||""===h){var w=y?s:i,_=y?l:a,x=y?f||c:c,k=y&&"function"==typeof h?h:u,C=y?v||d:d,A=y?m||p:p,$=r!==!1&&!Ho,S=k&&(k._length||k.length)>1,T=t._enterCb=Rt(function(){ 7 | $&&kt(t,_),T.cancelled?($&&kt(t,w),A&&A(t)):C&&C(t),t._enterCb=null});e.data.show||V(e.data.hook||(e.data.hook={}),"insert",function(){var n=t.parentNode,r=n&&n._pending&&n._pending[e.key];r&&r.tag===e.tag&&r.elm._leaveCb&&r.elm._leaveCb(),k&&k(t,T)}),x&&x(t),$&&(xt(t,w),xt(t,_),_t(function(){kt(t,w),T.cancelled||S||Ct(t,o,T)})),e.data.show&&k&&k(t,T),$||S||T()}}}function Ot(e,t){function n(){m.cancelled||(e.data.show||((r.parentNode._pending||(r.parentNode._pending={}))[e.key]=e),c&&c(r),h&&(xt(r,s),xt(r,l),_t(function(){kt(r,s),m.cancelled||v||Ct(r,a,m)})),u&&u(r,m),h||v||m())}var r=e.elm;r._enterCb&&(r._enterCb.cancelled=!0,r._enterCb());var o=Lt(e.data.transition);if(!o)return t();if(!r._leaveCb&&1===r.nodeType){var i=o.css,a=o.type,s=o.leaveClass,l=o.leaveActiveClass,c=o.beforeLeave,u=o.leave,d=o.afterLeave,p=o.leaveCancelled,f=o.delayLeave,h=i!==!1&&!Ho,v=u&&(u._length||u.length)>1,m=r._leaveCb=Rt(function(){r.parentNode&&r.parentNode._pending&&(r.parentNode._pending[e.key]=null),h&&kt(r,l),m.cancelled?(h&&kt(r,s),p&&p(r)):(t(),d&&d(r)),r._leaveCb=null});f?f(n):n()}}function Lt(e){if(e){if("object"==typeof e){var t={};return e.css!==!1&&u(t,fi(e.name||"v")),u(t,e),t}return"string"==typeof e?fi(e):void 0}}function Rt(e){var t=!1;return function(){t||(t=!0,e())}}function Et(e,t,n){var r=t.value,o=e.multiple;if(o&&!Array.isArray(r))return void po('