/*! * perfect-scrollbar v1.1.0 * (c) 2017 hyunje jun * @license mit */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.perfectscrollbar=e()}(this,function(){"use strict";function t(t){return getcomputedstyle(t)}function e(t,e){for(var i in e){var n=e[i];"number"==typeof n&&(n+="px"),t.style[i]=n}return t}function i(t){var e=document.createelement("div");return e.classname=t,e}function n(t,e){if(!v)throw new error("no element matching method supported");return v.call(t,e)}function r(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 n(t,e)})}function o(t,e){var i=t.element.classlist,n=m.state.scrolling(e);i.contains(n)?cleartimeout(w[e]):i.add(n)}function s(t,e){w[e]=settimeout(function(){return t.element.classlist.remove(m.state.scrolling(e))},t.settings.scrollingthreshold)}function a(t,e){o(t,e),s(t,e)}function c(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 h(t,e,i,n){var r=i[0],l=i[1],o=i[2],s=i[3],h=i[4],u=i[5],d=t.element,p=!1;t.reach[s]=null,e<=0&&(e=0,t.reach[s]="start"),e>=t[r]-t[l]&&((e=t[r]-t[l])-d[o]<=2&&(p=!0),t.reach[s]="end");var f=d[o]-e;f&&(d.dispatchevent(c("ps-scroll-"+s)),f>0?d.dispatchevent(c("ps-scroll-"+h)):d.dispatchevent(c("ps-scroll-"+u)),p||(d[o]=e),t.reach[s]&&d.dispatchevent(c("ps-"+s+"-reach-"+t.reach[s])),n&&a(t,s))}function u(t){return parseint(t,10)||0}function d(t){return n(t,"input,[contenteditable]")||n(t,"select,[contenteditable]")||n(t,"textarea,[contenteditable]")||n(t,"button,[contenteditable]")}function p(e){var i=t(e);return u(i.width)+u(i.paddingleft)+u(i.paddingright)+u(i.borderleftwidth)+u(i.borderrightwidth)}function f(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 b(t,i){var n={width:i.railxwidth};i.isrtl?n.left=i.negativescrolladjustment+t.scrollleft+i.containerwidth-i.contentwidth:n.left=t.scrollleft,i.isscrollbarxusingbottom?n.bottom=i.scrollbarxbottom-t.scrolltop:n.top=i.scrollbarxtop+t.scrolltop,e(i.scrollbarxrail,n);var r={top:t.scrolltop,height:i.railyheight};i.isscrollbaryusingright?i.isrtl?r.right=i.contentwidth-(i.negativescrolladjustment+t.scrollleft)-i.scrollbaryright-i.scrollbaryouterwidth:r.right=i.scrollbaryright-t.scrollleft:i.isrtl?r.left=i.negativescrolladjustment+t.scrollleft+2*i.containerwidth-i.contentwidth-i.scrollbaryleft-i.scrollbaryouterwidth:r.left=i.scrollbaryleft+t.scrollleft,e(i.scrollbaryrail,r),e(i.scrollbarx,{left:i.scrollbarxleft,width:i.scrollbarxwidth-i.railborderxwidth}),e(i.scrollbary,{top:i.scrollbarytop,height:i.scrollbaryheight-i.railborderywidth})}function g(t,e){function i(e){y(t,p,g+m*(e[a]-v),!1),o(t,f),l(t),e.stoppropagation(),e.preventdefault()}function n(){s(t,f),t.event.unbind(t.ownerdocument,"mousemove",i)}var r=e[0],l=e[1],a=e[2],c=e[3],h=e[4],u=e[5],d=e[6],p=e[7],f=e[8],b=t.element,g=null,v=null,m=null;t.event.bind(t[h],"mousedown",function(e){g=b[d],v=e[a],m=(t[l]-t[r])/(t[c]-t[u]),t.event.bind(t.ownerdocument,"mousemove",i),t.event.once(t.ownerdocument,"mouseup",n),e.stoppropagation(),e.preventdefault()})}var v=element.prototype.matches||element.prototype.webkitmatchesselector||element.prototype.msmatchesselector,m={main:"ps",element:{thumb:function(t){return"ps__thumb-"+t},rail:function(t){return"ps__rail-"+t},consuming:"ps__child--consume"},state:{focus:"ps--focus",active:function(t){return"ps--active-"+t},scrolling:function(t){return"ps--scrolling-"+t}}},w={x:null,y:null},y=function(t){this.element=t,this.handlers={}},x={isempty:{configurable:!0}};y.prototype.bind=function(t,e){void 0===this.handlers[t]&&(this.handlers[t]=[]),this.handlers[t].push(e),this.element.addeventlistener(t,e,!1)},y.prototype.unbind=function(t,e){var i=this;this.handlers[t]=this.handlers[t].filter(function(n){return!(!e||n===e)||(i.element.removeeventlistener(t,n,!1),!1)})},y.prototype.unbindall=function(){var t=this;for(var e in t.handlers)t.unbind(e)},x.isempty.get=function(){var t=this;return object.keys(this.handlers).every(function(e){return 0===t.handlers[e].length})},object.defineproperties(y.prototype,x);var w=function(){this.eventelements=[]};w.prototype.eventelement=function(t){var e=this.eventelements.filter(function(e){return e.element===t})[0];return e||(e=new y(t),this.eventelements.push(e)),e},w.prototype.bind=function(t,e,i){this.eventelement(t).bind(e,i)},w.prototype.unbind=function(t,e,i){var n=this.eventelement(t);n.unbind(e,i),n.isempty&&this.eventelements.splice(this.eventelements.indexof(n),1)},w.prototype.unbindall=function(){this.eventelements.foreach(function(t){return t.unbindall()}),this.eventelements=[]},w.prototype.once=function(t,e,i){var n=this.eventelement(t),r=function(t){n.unbind(e,r),i(t)};n.bind(e,r)};var y=function(t,e,i,n){void 0===n&&(n=!0);var r;if("top"===e)r=["contentheight","containerheight","scrolltop","y","up","down"];else{if("left"!==e)throw new error("a proper axis should be provided");r=["contentwidth","containerwidth","scrollleft","x","left","right"]}h(t,i,r,n)},r={iswebkit:document&&"webkitappearance"in document.documentelement.style,supportstouch:window&&("ontouchstart"in window||window.documenttouch&&document instanceof window.documenttouch),supportsiepointer:navigator&&navigator.msmaxtouchpoints},l=function(t){var e=t.element;t.containerwidth=e.clientwidth,t.containerheight=e.clientheight,t.contentwidth=e.scrollwidth,t.contentheight=e.scrollheight,e.contains(t.scrollbarxrail)||(l(e,m.element.rail("x")).foreach(function(t){return r(t)}),e.appendchild(t.scrollbarxrail)),e.contains(t.scrollbaryrail)||(l(e,m.element.rail("y")).foreach(function(t){return r(t)}),e.appendchild(t.scrollbaryrail)),!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),b(e,t),t.scrollbarxactive?e.classlist.add(m.state.active("x")):(e.classlist.remove(m.state.active("x")),t.scrollbarxwidth=0,t.scrollbarxleft=0,y(t,"left",0)),t.scrollbaryactive?e.classlist.add(m.state.active("y")):(e.classlist.remove(m.state.active("y")),t.scrollbaryheight=0,t.scrollbarytop=0,y(t,"top",0))},h={"click-rail":function(t){var e=t.element;t.event.bind(t.scrollbary,"mousedown",function(t){return t.stoppropagation()}),t.event.bind(t.scrollbaryrail,"mousedown",function(i){var n=i.pagey-window.pageyoffset-t.scrollbaryrail.getboundingclientrect().top>t.scrollbarytop?1:-1;y(t,"top",e.scrolltop+n*t.containerheight),l(t),i.stoppropagation()}),t.event.bind(t.scrollbarx,"mousedown",function(t){return t.stoppropagation()}),t.event.bind(t.scrollbarxrail,"mousedown",function(i){var n=i.pagex-window.pagexoffset-t.scrollbarxrail.getboundingclientrect().left>t.scrollbarxleft?1:-1;y(t,"left",e.scrollleft+n*t.containerwidth),l(t),i.stoppropagation()})},"drag-thumb":function(t){g(t,["containerwidth","contentwidth","pagex","railxwidth","scrollbarx","scrollbarxwidth","scrollleft","left","x"]),g(t,["containerheight","contentheight","pagey","railyheight","scrollbary","scrollbaryheight","scrolltop","top","y"])},keyboard:function(t){function e(e,n){var r=i.scrolltop;if(0===e){if(!t.scrollbaryactive)return!1;if(0===r&&n>0||r>=t.contentheight-t.containerheight&&n<0)return!t.settings.wheelpropagation}var l=i.scrollleft;if(0===n){if(!t.scrollbarxactive)return!1;if(0===l&&e<0||l>=t.contentwidth-t.containerwidth&&e>0)return!t.settings.wheelpropagation}return!0}var i=t.element,r=function(){return n(i,":hover")},l=function(){return n(t.scrollbarx,":focus")||n(t.scrollbary,":focus")};t.event.bind(t.ownerdocument,"keydown",function(n){if(!(n.isdefaultprevented&&n.isdefaultprevented()||n.defaultprevented)&&(r()||l())){var o=document.activeelement?document.activeelement:t.ownerdocument.activeelement;if(o){if("iframe"===o.tagname)o=o.contentdocument.activeelement;else for(;o.shadowroot;)o=o.shadowroot.activeelement;if(d(o))return}var s=0,a=0;switch(n.which){case 37:s=n.metakey?-t.contentwidth:n.altkey?-t.containerwidth:-30;break;case 38:a=n.metakey?t.contentheight:n.altkey?t.containerheight:30;break;case 39:s=n.metakey?t.contentwidth:n.altkey?t.containerwidth:30;break;case 40:a=n.metakey?-t.contentheight:n.altkey?-t.containerheight:-30;break;case 32:a=n.shiftkey?t.containerheight:-t.containerheight;break;case 33:a=t.containerheight;break;case 34:a=-t.containerheight;break;case 36:a=t.contentheight;break;case 35:a=-t.contentheight;break;default:return}t.settings.suppressscrollx&&0!==s||t.settings.suppressscrolly&&0!==a||(y(t,"top",i.scrolltop-a),y(t,"left",i.scrollleft+s),l(t),e(s,a)&&n.preventdefault())}})},wheel:function(e){function i(t,i){var n=o.scrolltop;if(0===t){if(!e.scrollbaryactive)return!1;if(0===n&&i>0||n>=e.contentheight-e.containerheight&&i<0)return!e.settings.wheelpropagation}var r=o.scrollleft;if(0===i){if(!e.scrollbarxactive)return!1;if(0===r&&t<0||r>=e.contentwidth-e.containerwidth&&t>0)return!e.settings.wheelpropagation}return!0}function n(t){var e=t.deltax,i=-1*t.deltay;return void 0!==e&&void 0!==i||(e=-1*t.wheeldeltax/6,i=t.wheeldeltay/6),t.deltamode&&1===t.deltamode&&(e*=10,i*=10),e!==e&&i!==i&&(e=0,i=t.wheeldelta),t.shiftkey?[-i,-e]:[e,i]}function r(e,i,n){if(!r.iswebkit&&o.queryselector("select:focus"))return!0;if(!o.contains(e))return!1;for(var r=e;r&&r!==o;){if(r.classlist.contains(m.element.consuming))return!0;var l=t(r);if([l.overflow,l.overflowx,l.overflowy].join("").match(/(scroll|auto)/)){var s=r.scrollheight-r.clientheight;if(s>0&&!(0===r.scrolltop&&n>0||r.scrolltop===s&&n<0))return!0;var a=r.scrollleft-r.clientwidth;if(a>0&&!(0===r.scrollleft&&i<0||r.scrollleft===a&&i>0))return!0}r=r.parentnode}return!1}function l(t){var l=n(t),s=l[0],a=l[1];if(!r(t.target,s,a)){var c=!1;e.settings.usebothwheelaxes?e.scrollbaryactive&&!e.scrollbarxactive?(a?y(e,"top",o.scrolltop-a*e.settings.wheelspeed):y(e,"top",o.scrolltop+s*e.settings.wheelspeed),c=!0):e.scrollbarxactive&&!e.scrollbaryactive&&(s?y(e,"left",o.scrollleft+s*e.settings.wheelspeed):y(e,"left",o.scrollleft-a*e.settings.wheelspeed),c=!0):(y(e,"top",o.scrolltop-a*e.settings.wheelspeed),y(e,"left",o.scrollleft+s*e.settings.wheelspeed)),l(e),(c=c||i(s,a))&&(t.stoppropagation(),t.preventdefault())}}var o=e.element;void 0!==window.onwheel?e.event.bind(o,"wheel",l):void 0!==window.onmousewheel&&e.event.bind(o,"mousewheel",l)},touch:function(t){function e(e,i){var n=h.scrolltop,r=h.scrollleft,l=math.abs(e),o=math.abs(i);if(o>l){if(i<0&&n===t.contentheight-t.containerheight||i>0&&0===n)return{stop:!t.settings.swipepropagation,prevent:0===window.scrolly}}else if(l>o&&(e<0&&r===t.contentwidth-t.containerwidth||e>0&&0===r))return{stop:!t.settings.swipepropagation,prevent:!0};return{stop:!0,prevent:!0}}function i(e,i){y(t,"top",h.scrolltop-i),y(t,"left",h.scrollleft-e),l(t)}function n(){b=!0}function r(){b=!1}function l(t){return t.targettouches?t.targettouches[0]:t}function o(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 s(t){if(o(t)){g=!0;var e=l(t);u.pagex=e.pagex,u.pagey=e.pagey,d=(new date).gettime(),null!==f&&clearinterval(f),t.stoppropagation()}}function a(n){if(!g&&t.settings.swipepropagation&&s(n),!b&&g&&o(n)){var r=l(n),a={pagex:r.pagex,pagey:r.pagey},c=a.pagex-u.pagex,h=a.pagey-u.pagey;i(c,h),u=a;var f=(new date).gettime(),v=f-d;v>0&&(p.x=c/v,p.y=h/v,d=f);var m=e(c,h),w=m.stop,y=m.prevent;w&&n.stoppropagation(),y&&n.preventdefault()}}function c(){!b&&g&&(g=!1,t.settings.swipeeasing&&(clearinterval(f),f=setinterval(function(){t.isinitialized?clearinterval(f):p.x||p.y?math.abs(p.x)<.01&&math.abs(p.y)<.01?clearinterval(f):(i(30*p.x,30*p.y),p.x*=.8,p.y*=.8):clearinterval(f)},10)))}if(r.supportstouch||r.supportsiepointer){var h=t.element,u={},d=0,p={},f=null,b=!1,g=!1;r.supportstouch?(t.event.bind(window,"touchstart",n),t.event.bind(window,"touchend",r),t.event.bind(h,"touchstart",s),t.event.bind(h,"touchmove",a),t.event.bind(h,"touchend",c)):r.supportsiepointer&&(window.pointerevent?(t.event.bind(window,"pointerdown",n),t.event.bind(window,"pointerup",r),t.event.bind(h,"pointerdown",s),t.event.bind(h,"pointermove",a),t.event.bind(h,"pointerup",c)):window.mspointerevent&&(t.event.bind(window,"mspointerdown",n),t.event.bind(window,"mspointerup",r),t.event.bind(h,"mspointerdown",s),t.event.bind(h,"mspointermove",a),t.event.bind(h,"mspointerup",c)))}}},t=function(n,r){var l=this;if(void 0===r&&(r={}),"string"==typeof n&&(n=document.queryselector(n)),!n||!n.nodename)throw new error("no element is specified to initialize perfectscrollbar");this.element=n,n.classlist.add(m.main),this.settings={handlers:["click-rail","drag-thumb","keyboard","wheel","touch"],maxscrollbarlength:null,minscrollbarlength:null,scrollingthreshold:1e3,scrollxmarginoffset:0,scrollymarginoffset:0,suppressscrollx:!1,suppressscrolly:!1,swipepropagation:!0,swipeeasing:!0,usebothwheelaxes:!1,wheelpropagation:!1,wheelspeed:1};for(var o in r)l.settings[o]=r[o];this.containerwidth=null,this.containerheight=null,this.contentwidth=null,this.contentheight=null;var s=function(){return n.classlist.add(m.state.focus)},a=function(){return n.classlist.remove(m.state.focus)};this.isrtl="rtl"===t(n).direction,this.isnegativescroll=function(){var t=n.scrollleft,e=null;return n.scrollleft=-1,e=n.scrollleft<0,n.scrollleft=t,e}(),this.negativescrolladjustment=this.isnegativescroll?n.scrollwidth-n.clientwidth:0,this.event=new w,this.ownerdocument=n.ownerdocument||document,this.scrollbarxrail=i(m.element.rail("x")),n.appendchild(this.scrollbarxrail),this.scrollbarx=i(m.element.thumb("x")),this.scrollbarxrail.appendchild(this.scrollbarx),this.scrollbarx.setattribute("tabindex",0),this.event.bind(this.scrollbarx,"focus",s),this.event.bind(this.scrollbarx,"blur",a),this.scrollbarxactive=null,this.scrollbarxwidth=null,this.scrollbarxleft=null;var c=t(this.scrollbarxrail);this.scrollbarxbottom=parseint(c.bottom,10),isnan(this.scrollbarxbottom)?(this.isscrollbarxusingbottom=!1,this.scrollbarxtop=u(c.top)):this.isscrollbarxusingbottom=!0,this.railborderxwidth=u(c.borderleftwidth)+u(c.borderrightwidth),e(this.scrollbarxrail,{display:"block"}),this.railxmarginwidth=u(c.marginleft)+u(c.marginright),e(this.scrollbarxrail,{display:""}),this.railxwidth=null,this.railxratio=null,this.scrollbaryrail=i(m.element.rail("y")),n.appendchild(this.scrollbaryrail),this.scrollbary=i(m.element.thumb("y")),this.scrollbaryrail.appendchild(this.scrollbary),this.scrollbary.setattribute("tabindex",0),this.event.bind(this.scrollbary,"focus",s),this.event.bind(this.scrollbary,"blur",a),this.scrollbaryactive=null,this.scrollbaryheight=null,this.scrollbarytop=null;var h=t(this.scrollbaryrail);this.scrollbaryright=parseint(h.right,10),isnan(this.scrollbaryright)?(this.isscrollbaryusingright=!1,this.scrollbaryleft=u(h.left)):this.isscrollbaryusingright=!0,this.scrollbaryouterwidth=this.isrtl?p(this.scrollbary):null,this.railborderywidth=u(h.bordertopwidth)+u(h.borderbottomwidth),e(this.scrollbaryrail,{display:"block"}),this.railymarginheight=u(h.margintop)+u(h.marginbottom),e(this.scrollbaryrail,{display:""}),this.railyheight=null,this.railyratio=null,this.reach={x:n.scrollleft<=0?"start":n.scrollleft>=this.contentwidth-this.containerwidth?"end":null,y:n.scrolltop<=0?"start":n.scrolltop>=this.contentheight-this.containerheight?"end":null},this.settings.handlers.foreach(function(t){return h[t](l)}),this.event.bind(this.element,"scroll",function(){return l(l)}),l(this)},e={isinitialized:{configurable:!0}};return e.isinitialized.get=function(){return this.element.classlist.contains(m.main)},t.prototype.update=function(){this.isinitialized&&(this.negativescrolladjustment=this.isnegativescroll?this.element.scrollwidth-this.element.clientwidth:0,e(this.scrollbarxrail,{display:"block"}),e(this.scrollbaryrail,{display:"block"}),this.railxmarginwidth=u(t(this.scrollbarxrail).marginleft)+u(t(this.scrollbarxrail).marginright),this.railymarginheight=u(t(this.scrollbaryrail).margintop)+u(t(this.scrollbaryrail).marginbottom),e(this.scrollbarxrail,{display:"none"}),e(this.scrollbaryrail,{display:"none"}),l(this),e(this.scrollbarxrail,{display:""}),e(this.scrollbaryrail,{display:""}))},t.prototype.destroy=function(){this.isinitialized&&(this.event.unbindall(),r(this.scrollbarx),r(this.scrollbary),r(this.scrollbarxrail),r(this.scrollbaryrail),this.removepsclasses(),this.element=null,this.scrollbarx=null,this.scrollbary=null,this.scrollbarxrail=null,this.scrollbaryrail=null)},t.prototype.removepsclasses=function(){this.element.classname=this.element.classname.split(" ").filter(function(t){return!t.match(/^ps([-_].+|)$/)}).join(" ")},object.defineproperties(t.prototype,e),t});