2014-10-24 19:06:04 +08:00
|
|
|
(function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e){"use strict";function o(e){return"string"==typeof e?parseInt(e,10):~~e}var t={wheelSpeed:1,wheelPropagation:!1,minScrollbarLength:null,maxScrollbarLength:null,useBothWheelAxes:!1,useKeyboard:!0,suppressScrollX:!1,suppressScrollY:!1,scrollXMarginOffset:0,scrollYMarginOffset:0,includePadding:!1},n=function(){var e=0;return function(){var o=e;return e+=1,".perfect-scrollbar-"+o}}();e.fn.perfectScrollbar=function(r,l){return this.each(function(){function i(e,t){var n=e+t,r=P-k;C=0>n?0:n>r?r:n;var l=o(C*(x-P)/(P-k));L.scrollTop(l)}function a(e,t){var n=e+t,r=S-E;X=0>n?0:n>r?r:n;var l=o(X*(D-S)/(S-E));L.scrollLeft(l)}function s(e){return y.minScrollbarLength&&(e=Math.max(e,y.minScrollbarLength)),y.maxScrollbarLength&&(e=Math.min(e,y.maxScrollbarLength)),e}function c(){var e={width:S,display:M?"inherit":"none"};e.left=W?L.scrollLeft()+S-D:L.scrollLeft(),B?e.bottom=q-L.scrollTop():e.top=R+L.scrollTop(),K.css(e);var o={top:L.scrollTop(),height:P,display:Y?"inherit":"none"};z?o.right=W?D-L.scrollLeft()-Q-U.outerWidth():Q-L.scrollLeft():o.left=W?L.scrollLeft()+2*S-D-F-U.outerWidth():F+L.scrollLeft(),H.css(o),O.css({left:X,width:E-A}),U.css({top:C,height:k-G})}function d(){K.hide(),H.hide(),S=y.includePadding?L.innerWidth():L.width(),P=y.includePadding?L.innerHeight():L.height(),D=L.prop("scrollWidth"),x=L.prop("scrollHeight"),!y.suppressScrollX&&D>S+y.scrollXMarginOffset?(M=!0,E=s(o(S*S/D)),X=o(L.scrollLeft()*(S-E)/(D-S))):(M=!1,E=0,X=0,L.scrollLeft(0)),!y.suppressScrollY&&x>P+y.scrollYMarginOffset?(Y=!0,k=s(o(P*P/x)),C=o(L.scrollTop()*(P-k)/(x-P))):(Y=!1,k=0,C=0,L.scrollTop(0)),X>=S-E&&(X=S-E),C>=P-k&&(C=P-k),c(),M?L.addClass("ps-active-x"):L.removeClass("ps-active-x"),Y?L.addClass("ps-active-y"):L.removeClass("ps-active-y"),y.suppressScrollX||K.show(),y.suppressScrollY||H.show()}function p(){var o,t;O.bind("mousedown"+j,function(e){t=e.pageX,o=O.position().left,K.addClass("in-scrolling"),e.stopPropagation(),e.preventDefault()}),e(I).bind("mousemove"+j,function(e){K.hasClass("in-scrolling")&&(a(o,e.pageX-t),d(),e.stopPropagation(),e.preventDefault())}),e(I).bind("mouseup"+j,function(){K.hasClass("in-scrolling")&&K.removeClass("in-scrolling")}),o=t=null}function u(){var o,t;U.bind("mousedown"+j,function(e){t=e.pageY,o=U.position().top,H.addClass("in-scrolling"),e.stopPropagation(),e.preventDefault()}),e(I).bind("mousemove"+j,function(e){H.hasClass("in-scrolling")&&(i(o,e.pageY-t),d(),e.stopPropagation(),e.preventDefault())}),e(I).bind("mouseup"+j,function(){H.hasClass("in-scrolling")&&H.removeClass("in-scrolling")}),o=t=null}function f(e,o){var t=L.scrollTop();if(0===e){if(!Y)return!1;if(0===t&&o>0||t>=x-P&&0>o)return!y.wheelPropagation}var n=L.scrollLeft();if(0===o){if(!M)return!1;if(0===n&&0>e||n>=D-S&&e>0)return!y.wheelPropagation}return!0}function v(){function e(e){var o=e.originalEvent.deltaX,t=-1*e.originalEvent.deltaY;return(o===void 0||t===void 0)&&(o=-1*e.originalEvent.wheelDeltaX/6,t=e.originalEvent.wheelDeltaY/6),e.originalEvent.deltaMode&&1===e.originalEvent.deltaMode&&(o*=10,t*=10),o!==o&&t!==t&&(o=0,t=e.originalEvent.wheelDelta),[o,t]}function o(o){var n=e(o),r=n[0],l=n[1];t=!1,y.useBothWheelAxes?Y&&!M?(l?L.scrollTop(L.scrollTop()-l*y.wheelSpeed):L.scrollTop(L.scrollTop()+r*y.wheelSpeed),t=!0):M&&!Y&&(r?L.scrollLeft(L.scrollLeft()+r*y.wheelSpeed):L.scrollLeft(L.scrollLeft()-l*y.wheelSpeed),t=!0):(L.scrollTop(L.scrollTop()-l*y.wheelSpeed),L.scrollLeft(L.scrollLeft()+r*y.wheelSpeed)),d(),t=t||f(r,l),t&&(o.stopPropagation(),o.preventDefault())}var t=!1;window.onwheel!==void 0?L.bind("wheel"+j,o):window.onmousewheel!==void 0&&L.bind("mousewheel"+j,o)}function h(){var o=!1;L.bind("mouseenter"+j,function(){o=!0}),L.bind("mouseleave"+j,function(){o=!1});var t=!1;e(I).bind("keydown"+j,function(n){if((!n.isDefaultPrevented||!n.isDefaultPrevented())&&o){for(var r=document.activeElement?document.activeElement:I.activeElement;r.shadowRoot;)r=r.shadowRoot.activeElement;if(!e(r)
|