katoikia-app/web-ui/web-react/node_modules/primereact/scrollpanel/scrollpanel.min.js

2 lines
6.7 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.scrollpanel=function(e,t,o){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function p(e,t){if(t&&("object"===u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var m,f,v,y=function(e){c(v,e);var t,n,l,u,m,f=(t=v,n=d(),function(){var e,o=h(t);if(n){var r=h(this).constructor;e=Reflect.construct(o,arguments,r)}else e=o.apply(this,arguments);return p(this,e)});function v(e){var t;return a(this,v),(t=f.call(this,e)).moveBar=t.moveBar.bind(s(t)),t.onXBarMouseDown=t.onXBarMouseDown.bind(s(t)),t.onYBarMouseDown=t.onYBarMouseDown.bind(s(t)),t.onDocumentMouseMove=t.onDocumentMouseMove.bind(s(t)),t.onDocumentMouseUp=t.onDocumentMouseUp.bind(s(t)),t}return l=v,(u=[{key:"calculateContainerHeight",value:function(){var e=getComputedStyle(this.container),t=getComputedStyle(this.xBar),n=o.DomHandler.getHeight(this.container)-parseInt(t.height,10);"none"!==e["max-height"]&&0===n&&(this.container.style.height=this.content.offsetHeight+parseInt(t.height,10)>parseInt(e["max-height"],10)?e["max-height"]:this.content.offsetHeight+parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)+parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth)+"px")}},{key:"moveBar",value:function(){var e=this,t=this.content.scrollWidth,n=-1*(this.container.clientHeight-this.xBar.clientHeight);this.scrollXRatio=this.content.clientWidth/t;var r=this.content.scrollHeight,a=-1*(this.container.clientWidth-this.yBar.clientWidth);this.scrollYRatio=this.content.clientHeight/r,this.frame=this.requestAnimationFrame((function(){e.scrollXRatio>=1?o.DomHandler.addClass(e.xBar,"p-scrollpanel-hidden"):(o.DomHandler.removeClass(e.xBar,"p-scrollpanel-hidden"),e.xBar.style.cssText="width:"+Math.max(100*e.scrollXRatio,10)+"%; left:"+e.content.scrollLeft/t*100+"%;bottom:"+n+"px;"),e.scrollYRatio>=1?o.DomHandler.addClass(e.yBar,"p-scrollpanel-hidden"):(o.DomHandler.removeClass(e.yBar,"p-scrollpanel-hidden"),e.yBar.style.cssText="height:"+Math.max(100*e.scrollYRatio,10)+"%; top: calc("+e.content.scrollTop/r*100+"% - "+e.xBar.clientHeight+"px);right:"+a+"px;")}))}},{key:"onYBarMouseDown",value:function(e){this.isYBarClicked=!0,this.lastPageY=e.pageY,o.DomHandler.addClass(this.yBar,"p-scrollpanel-grabbed"),o.DomHandler.addClass(document.body,"p-scrollpanel-grabbed"),document.addEventListener("mousemove",this.onDocumentMouseMove),document.addEventListener("mouseup",this.onDocumentMouseUp),e.preventDefault()}},{key:"onXBarMouseDown",value:function(e){this.isXBarClicked=!0,this.lastPageX=e.pageX,o.DomHandler.addClass(this.xBar,"p-scrollpanel-grabbed"),o.DomHandler.addClass(document.body,"p-scrollpanel-grabbed"),document.addEventListener("mousemove",this.onDocumentMouseMove),document.addEventListener("mouseup",this.onDocumentMouseUp),e.preventDefault()}},{key:"onDocumentMouseMove",value:function(e){this.isXBarClicked?this.onMouseMoveForXBar(e):(this.isYBarClicked||this.onMouseMoveForXBar(e),this.onMouseMoveForYBar(e))}},{key:"onMouseMoveForXBar",value:function(e){var t=this,o=e.pageX-this.lastPageX;this.lastPageX=e.pageX,this.frame=this.requestAnimationFrame((function(){t.content.scrollLeft+=o/t.scrollXRatio}))}},{key:"onMouseMoveForYBar",value:function(e){var t=this,o=e.pageY-this.lastPageY;this.lastPageY=e.pageY,this.frame=this.requestAnimationFrame((function(){t.content.scrollTop+=o/t.scrollYRatio}))}},{key:"onDocumentMouseUp",value:function(e){o.DomHandler.removeClass(this.yBar,"p-scrollpanel-grabbed"),o.DomHandler.removeClass(this.xBar,"p-scrollpanel-grabbed"),o.DomHandler.removeClass(document.body,"p-scrollpanel-grabbed"),document.removeEventListener("mousemove",this.onDocumentMouseMove),document.removeEventListener("mouseup",this.onDocumentMouseUp),this.isXBarClicked=!1,this.isYBarClicked=!1}},{key:"requestAnimationFrame",value:function(e){return(window.requestAnimationFrame||this.timeoutFrame)(e)}},{key:"refresh",value:function(){this.moveBar()}},{key:"componentDidMount",value:function(){this.moveBar(),this.moveBar=this.moveBar.bind(this),window.addEventListener("resize",this.moveBar),this.calculateContainerHeight(),this.initialized=!0}},{key:"componentWillUnmount",value:function(){this.initialized&&window.removeEventListener("resize",this.moveBar),this.frame&&window.cancelAnimationFrame(this.frame)}},{key:"render",value:function(){var e=this,t=o.classNames("p-scrollpanel p-component",this.props.className);return r.default.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:t,style:this.props.style},r.default.createElement("div",{className:"p-scrollpanel-wrapper"},r.default.createElement("div",{ref:function(t){return e.content=t},className:"p-scrollpanel-content",onScroll:this.moveBar,onMouseEnter:this.moveBar},this.props.children)),r.default.createElement("div",{ref:function(t){return e.xBar=t},className:"p-scrollpanel-bar p-scrollpanel-bar-x",onMouseDown:this.onXBarMouseDown}),r.default.createElement("div",{ref:function(t){return e.yBar=t},className:"p-scrollpanel-bar p-scrollpanel-bar-y",onMouseDown:this.onYBarMouseDown}))}}])&&i(l.prototype,u),m&&i(l,m),Object.defineProperty(l,"prototype",{writable:!1}),v}(t.Component);return v={id:null,style:null,className:null},(f="defaultProps")in(m=y)?Object.defineProperty(m,f,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[f]=v,e.ScrollPanel=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils);