react-pannable
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t=t||self).ReactPannable={},t.React)}(this,function(t,h){"use strict";function u(t,e){if(null==t)return{};var n,i,o={},r=Object.keys(t);for(i=0;i<r.length;i++)e.indexOf(n=r[i])<0&&(o[n]=t[n]);return o}function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}h=h&&h.hasOwnProperty("default")?h.default:h;var e,g={create:function(t){var e,n=t.transformTranslate;return f({},u(t,["transformTranslate"]),(e=n)?{transform:"translate3d("+e[0]+"px, "+e[1]+"px, 0)",WebkitTransform:"translate3d("+e[0]+"px, "+e[1]+"px, 0)",msTransform:"translate("+e[0]+"px, "+e[1]+"px)"}:null)}},p=function(i){function t(){for(var o,t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return(o=i.call.apply(i,[this].concat(e))||this).state={target:null,translation:null,velocity:null,startXY:null,moveXY:null,moveT:null},o.elemRef=h.createRef(),o._onTouchStart=function(t){var e=o.props,n=e.onTouchStart;t.touches&&1===t.touches.length&&e.enabled&&o._track(t.touches[0]),n&&n(t)},o._onTouchMove=function(t){var e=o.props.onTouchMove;t.touches&&1===t.touches.length&&o._move(t.touches[0]),e&&e(t)},o._onTouchEnd=function(t){var e=o.props.onTouchEnd;t.changedTouches&&1===t.changedTouches.length&&o._end(),e&&e(t)},o._onTouchCancel=function(t){var e=o.props.onTouchCancel;t.changedTouches&&1===t.changedTouches.length&&o._end(),e&&e(t)},o._onMouseDown=function(t){var e=o.props,n=e.enabled,i=e.onMouseDown;(o._shouldPreventClick=n)&&(o._addMousePanListener(),o._track(t)),i&&i(t)},o._onMouseMove=function(t){t.preventDefault(),o._move(t)},o._onMouseUp=function(t){t.preventDefault(),o._removeMousePanListener(),o._end()},o._onClick=function(t){var e=o.props.onClick;o._shouldPreventClick&&t.preventDefault(),o._shouldPreventClick=!1,e&&e(t)},o}r(t,i);var e=t.prototype;return e.componentDidUpdate=function(t){var e=this.props.enabled;t.enabled===e||e||this._cancel()},e.componentWillUnmount=function(){this._removeMousePanListener()},e._track=function(t){this.setState({startXY:{x:t.pageX,y:t.pageY},moveXY:{x:t.pageX,y:t.pageY},moveT:(new Date).getTime()})},e._move=function(h){h={target:h.target,pageX:h.pageX,pageY:h.pageY},this.setState(function(t,e){var n=e.shouldStart,i=e.onStart,o=e.onMove,r=t.target,a=t.startXY,s=t.moveXY,l=t.moveT,c=(new Date).getTime(),d=c-l;if(!a)return null;var u={translation:{x:h.pageX-a.x,y:h.pageY-a.y},velocity:{x:(h.pageX-s.x)/d,y:(h.pageY-s.y)/d},moveXY:{x:h.pageX,y:h.pageY},moveT:c};return r?o({target:r,translation:u.translation,velocity:u.velocity}):0<Math.sqrt(u.translation.x*u.translation.x+u.translation.y*u.translation.y)&&("function"==typeof n?n({target:h.target,translation:u.translation,velocity:u.velocity}):n)&&(u.target=h.target,u.startXY={x:h.pageX,y:h.pageY},u.translation={x:0,y:0},i({target:u.target,translation:u.translation,velocity:u.velocity})),u})},e._end=function(){this.setState(function(t,e){var n=t.target;return n&&e.onEnd({target:n,translation:t.translation,velocity:t.velocity}),{target:null,translation:null,velocity:null,startXY:null,moveXY:null,moveT:null}})},e._cancel=function(){this.setState(function(t,e){var n=t.target;return n&&e.onCancel({target:n,translation:t.translation,velocity:t.velocity}),{target:null,translation:null,velocity:null,startXY:null,moveXY:null,moveT:null}})},e._addMousePanListener=function(){var t=document.documentElement;t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("mouseup",this._onMouseUp,!1)},e._removeMousePanListener=function(){var t=document.documentElement;t.removeEventListener("mousemove",this._onMouseMove,!1),t.removeEventListener("mouseup",this._onMouseUp,!1)},e.render=function(){var t=this.props,e=t.enabled,n=t.style,i=u(t,["enabled","shouldStart","onStart","onMove","onEnd","onCancel","style"]),o=g.create(f({touchAction:e?"none":"auto"},n));return h.createElement("div",f({},i,{ref:this.elemRef,style:o,onTouchStart:this._onTouchStart,onTouchEnd:this._onTouchEnd,onTouchMove:this._onTouchMove,onTouchCancel:this._onTouchCancel,onMouseDown:this._onMouseDown,onClick:this._onClick}))},t}(h.PureComponent);p.defaultProps={enabled:!0,shouldStart:!0,onStart:function(){},onMove:function(){},onEnd:function(){},onCancel:function(){}};var c=(e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.msRequestAnimationFrame||e.setTimeout&&function(t){return e.setTimeout(t,20)}||function(){},d=e.cancelAnimationFrame||e.webkitCancelAnimationFrame||e.mozCancelAnimationFrame||e.clearTimeout||function(){};function v(t,e,n){return n?e?e*Math.round(t/e):0:{x:v(t.x,e.width,"x"),y:v(t.y,e.height,"y")}}function m(t,e){var n=e.x,i=e.y,o=Math.sqrt(n*n+i*i);return{x:t*(n/o),y:t*(i/o)}}var n=function(n){function t(t){var e;return(e=n.call(this,t)||this)._onDragStart=function(t){var r=t.translation,a=t.velocity;e.setState(function(t,e){var n=t.contentOffset,i=e.directionalLockEnabled?Math.abs(a.y)<Math.abs(a.x)?"x":"y":"xy",o={x:n.x+("y"===i?0:r.x),y:n.y+("x"===i?0:r.y)};return{contentOffset:o,contentVelocity:{x:"y"===i?0:a.x,y:"x"===i?0:a.y},dragging:!0,dragStartOffset:o,dragDirection:i,decelerating:!1,decelerationEndOffset:null,decelerationRate:0}})},e._onDragMove=function(t){var i=t.translation,o=t.velocity;e.setState(function(t){var e=t.dragStartOffset,n=t.dragDirection;return{contentOffset:{x:e.x+("y"===n?0:i.x),y:e.y+("x"===n?0:i.y)},contentVelocity:{x:"y"===n?0:o.x,y:"x"===n?0:o.y}}})},e._onDragEnd=function(t){var d=t.translation,u=t.velocity;e.setState(function(t,e){var n=t.dragStartOffset,i=t.dragDirection,o=t.size,r=e.pagingEnabled,a={x:n.x+("y"===i?0:d.x),y:n.y+("x"===i?0:d.y)},s={x:"y"===i?0:u.x,y:"x"===i?0:u.y},l=r?.02:.002;r&&(s=function t(e,n,i,o){if(o){if(!i)return 0;var r=i<0?-1:1;return r*Math.min(Math.abs(e),Math.sqrt(r*i*n))}return i=m(i,e),{x:t(e.x,n.width,i.x,"x"),y:t(e.y,n.height,i.y,"y")}}(s,o,l));var c=function t(e,n,i,o){return o?i?e+.5*n*(n/i):e:(i=m(i,n),{x:t(e.x,n.x,i.x,"x"),y:t(e.y,n.y,i.y,"y")})}(a,s,l);return r&&(c=v(c,o)),{contentOffset:a,contentVelocity:s,dragging:!1,dragStartOffset:null,dragDirection:"xy",decelerating:!0,decelerationEndOffset:c,decelerationRate:l}})},e._onDragCancel=function(t){var r=t.translation,a=t.velocity;e.setState(function(t,e){var n=t.dragStartOffset,i={x:n.x+r.x,y:n.y+r.y},o=n;return e.pagingEnabled&&(o=v(o,t.size)),{contentOffset:i,contentVelocity:a,dragging:!1,dragStartOffset:null,dragDirection:"xy",decelerating:!0,decelerationEndOffset:o,decelerationRate:.01}})},e.state={size:{width:t.width,height:t.height},contentSize:{width:t.contentWidth,height:t.contentHeight},contentOffset:{x:0,y:0},contentVelocity:{x:0,y:0},prevContentOffset:null,dragging:!1,decelerating:!1,dragStartOffset:null,dragDirection:"xy",decelerationEndOffset:null,decelerationRate:0},e.boundingRef=h.createRef(),e.contentRef=h.createRef(),e.setContentSize=e.setContentSize.bind(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)),e}r(t,n),t.getDerivedStateFromProps=function(t,e){var n=e.size,i=e.contentSize,o=e.contentOffset,r=e.contentVelocity,a=e.dragging,s=e.decelerating,l=e.decelerationEndOffset,c={};if(e.prevContentOffset!==o){var d=function t(e,n,i,o){return o?Math.max(Math.min(n-i,0),Math.min(e,0)):{x:t(e.x,n.width,i.width,"x"),y:t(e.y,n.height,i.height,"y")}}(o,n,i),u=r,h=s,f=l;d.x===o.x&&d.y===o.y?d=o:(u={x:d.x!==o.x?0:u.x,y:d.y!==o.y?0:u.y},f&&(f={x:d.x!==o.x?d.x:f.x,y:d.y!==o.y?d.y:f.y})),f&&d.x===f.x&&d.y===f.y&&0===u.x&&0===u.y&&(h=!1,f=null,c.decelerationRate=0),c.prevContentOffset=o,c.contentOffset=d,u!==r&&(c.contentVelocity=u),h!==s&&(c.decelerating=h),f!==l&&(c.decelerationEndOffset=f),t.onScroll({contentOffset:d,contentVelocity:u,decelerating:h,dragging:a,size:n,contentSize:i})}return c};var e=t.prototype;return e.componentDidUpdate=function(t,e){var n=this,i=this.props,o=i.width,r=i.height,a=i.contentWidth,s=i.contentHeight;if(t.width===o&&t.height===r||this.setState(function(t){return{size:{width:o,height:r},contentOffset:f({},t.contentOffset)}}),t.contentWidth===a&&t.contentHeight===s||this.setState(function(t){return{contentSize:{width:a,height:s},contentOffset:f({},t.contentOffset)}}),e.contentOffset!==this.state.contentOffset&&this.state.decelerationEndOffset){var l=(new Date).getTime();this._deceleratingTimer&&d(this._deceleratingTimer),this._deceleratingTimer=c(function(){n._deceleratingTimer=void 0,n._decelerate((new Date).getTime()-l)})}},e.componentWillUnmount=function(){this._deceleratingTimer&&(d(this._deceleratingTimer),this._deceleratingTimer=void 0)},e.getSize=function(){return this.state.size},e.getContentSize=function(){return this.state.contentSize},e.getContentOffset=function(){return this.state.contentOffset},e.isDragging=function(){return this.state.dragging},e.isDecelerating=function(){return this.state.decelerating},e.setContentSize=function(e){this.setState(function(t){return{contentSize:e,contentOffset:f({},t.contentOffset)}})},e.scrollTo=function(t){var i=t.offset,o=t.animated;this.setState(function(t,e){var n=t.contentOffset;return t.dragging?null:o?(e.pagingEnabled&&(i=v(i,t.size)),{contentOffset:f({},n),decelerating:!0,decelerationEndOffset:i,decelerationRate:.01}):{contentOffset:i,contentVelocity:{x:0,y:0},decelerating:!1,decelerationEndOffset:null,decelerationRate:0}})},e.scrollToRect=function(t){var e=t.rect,n=t.align,i=t.animated,o=this.state,r=function t(e,n,i,o,r,a){if(a){var s;if("auto"===i){var l=r<n?-1:1;s=l*Math.max(0,Math.min(l*(e+o),l*(r-n)))-e}else"start"===i?i=0:"center"===i?i=.5:"end"===i&&(i=1),("number"!=typeof i||isNaN(i))&&(i=.5),s=i*(r-n)-e;return s}return"object"!=typeof i&&(i={x:i,y:i}),{x:t(e.x,n.width,i.x,o.x,r.width,"x"),y:t(e.y,n.height,i.y,o.y,r.height,"y")}}({x:e.x,y:e.y},{width:e.width,height:e.height},void 0===n?"auto":n,o.contentOffset,o.size);this.scrollTo({offset:r,animated:i})},e._decelerate=function(i){this.setState(function(t){var e=t.decelerationEndOffset;if(!e)return null;var n=function t(e,n,i,o,r,a){if(a){if(!n)return{offset:r,velocity:0};var s=(n<0?-1:1)*Math.sqrt(.5*o*o+n*(r-i)),l=n?(s-o)/n:0;return(n?(2*s-o)/n:0)<e?{offset:r,velocity:0}:{offset:i+.5*(o+s)*l-.5*(2*s-n*Math.abs(l-e))*(l-e),velocity:s-n*Math.abs(l-e)}}var c=t(e,(n=m(n,{x:r.x-i.x,y:r.y-i.y})).x,i.x,o.x,r.x,"x"),d=t(e,n.y,i.y,o.y,r.y,"y");return{offset:{x:c.offset,y:d.offset},velocity:{x:c.velocity,y:d.velocity}}}(i,t.decelerationRate,t.contentOffset,t.contentVelocity,e);return{contentOffset:n.offset,contentVelocity:n.velocity}})},e.render=function(){var t=this.props,e=t.scrollEnabled,n=t.style,i=t.children,o=u(t,["width","height","contentWidth","contentHeight","scrollEnabled","pagingEnabled","directionalLockEnabled","style","children"]),r=this.state,a=r.size,s=r.contentSize,l=r.contentOffset,c=g.create(f({overflow:"hidden",position:"relative",boxSizing:"border-box",width:a.width,height:a.height},n)),d=g.create({position:"relative",boxSizing:"border-box",width:s.width,height:s.height,transformTranslate:[l.x,l.y]});return h.createElement(p,f({},o,{ref:this.boundingRef,style:c,enabled:e,onStart:this._onDragStart,onMove:this._onDragMove,onEnd:this._onDragEnd,onCancel:this._onDragCancel}),h.createElement("div",{ref:this.contentRef,style:d},"function"==typeof i?i(this):i))},t}(h.PureComponent);function s(t){var e=window.getComputedStyle(t)||{},n=t.offsetWidth||0,i=t.offsetHeight||0;return e.paddingLeft&&(n-=parseInt(e.paddingLeft,10)),e.paddingRight&&(n-=parseInt(e.paddingRight,10)),e.borderLeftWidth&&(n-=parseInt(e.borderLeftWidth,10)),e.borderRightWidth&&(n-=parseInt(e.borderRightWidth,10)),e.paddingTop&&(i-=parseInt(e.paddingTop,10)),e.paddingBottom&&(i-=parseInt(e.paddingBottom,10)),e.borderTopWidth&&(i-=parseInt(e.borderTopWidth,10)),e.borderBottomWidth&&(i-=parseInt(e.borderBottomWidth,10)),{width:n,height:i}}function i(t,e){return t(e={exports:{}},e.exports),e.exports}n.defaultProps={children:null,width:0,height:0,contentWidth:0,contentHeight:0,scrollEnabled:!0,pagingEnabled:!1,directionalLockEnabled:!1,onScroll:function(){}};var o=i(function(t){(t.exports={}).forEach=function(t,e){for(var n=0;n<t.length;n++){var i=e(t[n]);if(i)return i}}}),y=i(function(t){var e=t.exports={};e.isIE=function(t){return(-1!=(e=navigator.userAgent.toLowerCase()).indexOf("msie")||-1!=e.indexOf("trident")||-1!=e.indexOf(" edge/"))&&(!t||t===function(){for(var t=3,e=document.createElement("div"),n=e.getElementsByTagName("i");e.innerHTML="\x3c!--[if gt IE "+ ++t+"]><i></i><![endif]--\x3e",n[0];);return 4<t?t:void 0}());var e},e.isLegacyOpera=function(){return!!window.opera}}),w=i(function(t){(t.exports={}).getOption=function(t,e,n){var i=t[e];return null!=i||void 0===n?i:n}}),x=function(t){var e=(t=t||{}).reporter,n=w.getOption(t,"async",!0),i=w.getOption(t,"auto",!0);i&&!n&&(e&&e.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),n=!0);var o,r=b(),a=!1;function s(){for(a=!0;r.size();){var t=r;r=b(),t.process()}a=!1}function l(){o=setTimeout(s,0)}return{add:function(t,e){!a&&i&&n&&0===r.size()&&l(),r.add(t,e)},force:function(t){a||(void 0===t&&(t=n),o&&(clearTimeout(o),o=null),t?l():s())}}};function b(){var i={},n=0,o=0,r=0;return{add:function(t,e){e||(e=t,t=0),o<t?o=t:t<r&&(r=t),i[t]||(i[t]=[]),i[t].push(e),n++},process:function(){for(var t=r;t<=o;t++)for(var e=i[t],n=0;n<e.length;n++)(0,e[n])()},size:function(){return n}}}var a="_erd";function l(t){return t[a]}var S={initState:function(t){return t[a]={},l(t)},getState:l,cleanState:function(t){delete t[a]}},D=o.forEach,z=function(t){var b=(t=t||{}).reporter,S=t.batchProcessor,z=t.stateHandler.getState,E=t.idHandler;if(!S)throw Error("Missing required dependency: batchProcessor");if(!b)throw Error("Missing required dependency: reporter.");var _=function(){var t=document.createElement("div");t.style.cssText="position: absolute; width: 1000px; height: 1000px; visibility: hidden; margin: 0; padding: 0;";var e=document.createElement("div");e.style.cssText="position: absolute; width: 500px; height: 500px; overflow: scroll; visibility: none; top: -1500px; left: -1500px; visibility: hidden; margin: 0; padding: 0;",e.appendChild(t),document.body.insertBefore(e,document.body.firstChild);var n=500-e.clientWidth,i=500-e.clientHeight;return document.body.removeChild(e),{width:n,height:i}}(),T="erd_scroll_detection_container";function O(t,e,n){if(t.addEventListener)t.addEventListener(e,n);else{if(!t.attachEvent)return b.error("[scroll] Don't know how to add event listeners.");t.attachEvent("on"+e,n)}}function n(t,e,n){if(t.removeEventListener)t.removeEventListener(e,n);else{if(!t.detachEvent)return b.error("[scroll] Don't know how to remove event listeners.");t.detachEvent("on"+e,n)}}function C(t){return z(t).container.childNodes[0].childNodes[0].childNodes[0]}function M(t){return z(t).container.childNodes[0].childNodes[0].childNodes[1]}return function(i,t){if(!document.getElementById(i)){var e=t+"_animation",n=t+"_animation_active",o="/* Created by the element-resize-detector library. */\n";o+="."+t+" > div::-webkit-scrollbar { display: none; }\n\n",o+="."+n+" { -webkit-animation-duration: 0.1s; animation-duration: 0.1s; -webkit-animation-name: "+e+"; animation-name: "+e+"; }\n",o+="@-webkit-keyframes "+e+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }\n",function(t,e){e=e||function(t){document.head.appendChild(t)};var n=document.createElement("style");n.innerHTML=t,n.id=i,e(n)}(o+="@keyframes "+e+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }")}}("erd_scroll_detection_scrollbar_style",T),{makeDetectable:function(a,v,t){function m(){if(a.debug){var t=Array.prototype.slice.call(arguments);if(t.unshift(E.get(v),"Scroll: "),b.log.apply)b.log.apply(null,t);else for(var e=0;e<t.length;e++)b.log(t[e])}}function s(t){var e=z(t).container.childNodes[0],n=window.getComputedStyle(e);return!n.width||-1==n.width.indexOf("px")}function e(){var t=window.getComputedStyle(v),e={};return e.position=t.position,e.width=v.offsetWidth,e.height=v.offsetHeight,e.top=t.top,e.right=t.right,e.bottom=t.bottom,e.left=t.left,e.widthCSS=t.width,e.heightCSS=t.height,e}function n(){if(m("storeStyle invoked."),z(v)){var t=e();z(v).style=t}else m("Aborting because element has been uninstalled")}function l(t,e,n){z(t).lastWidth=e,z(t).lastHeight=n}function c(){return 2*_.width+1}function d(){return 2*_.height+1}function u(t){return t+10+c()}function h(t){return t+10+d()}function f(t,e,n){var i=C(t),o=M(t),r=u(e),a=h(n),s=2*e+c(),l=2*n+d();i.scrollLeft=r,i.scrollTop=a,o.scrollLeft=s,o.scrollTop=l}function y(){var t=z(v).container;if(!t){(t=document.createElement("div")).className=T,t.style.cssText="visibility: hidden; display: inline; width: 0px; height: 0px; z-index: -1; overflow: hidden; margin: 0; padding: 0;",(z(v).container=t).className+=" "+T+"_animation_active",v.appendChild(t);var e=function(){z(v).onRendered&&z(v).onRendered()};O(t,"animationstart",e),z(v).onAnimationStart=e}return t}function i(){if(m("Injecting elements"),z(v)){!function(){var t=z(v).style;if("static"===t.position){v.style.position="relative";var e=function(t,e,n,i){var o=n[i];"auto"!==o&&"0"!==o.replace(/[^-\d\.]/g,"")&&(t.warn("An element that is positioned static has style."+i+"="+o+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",e),e.style[i]=0)};e(b,v,t,"top"),e(b,v,t,"right"),e(b,v,t,"bottom"),e(b,v,t,"left")}}();var t=z(v).container;t||(t=y());var e,n,i,o,r=_.width,a=_.height,s="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; left: "+(e=(e=-(1+r))?e+"px":"0")+"; top: "+(n=(n=-(1+a))?n+"px":"0")+"; right: "+(o=(o=-r)?o+"px":"0")+"; bottom: "+(i=(i=-a)?i+"px":"0")+";",l=document.createElement("div"),c=document.createElement("div"),d=document.createElement("div"),u=document.createElement("div"),h=document.createElement("div"),f=document.createElement("div");l.dir="ltr",l.style.cssText="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; width: 100%; height: 100%; left: 0px; top: 0px;",c.className=l.className=T,c.style.cssText=s,d.style.cssText="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",u.style.cssText="position: absolute; left: 0; top: 0;",h.style.cssText="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",f.style.cssText="position: absolute; width: 200%; height: 200%;",d.appendChild(u),h.appendChild(f),c.appendChild(d),c.appendChild(h),l.appendChild(c),t.appendChild(l),O(d,"scroll",g),O(h,"scroll",p),z(v).onExpandScroll=g,z(v).onShrinkScroll=p}else m("Aborting because element has been uninstalled");function g(){z(v).onExpand&&z(v).onExpand()}function p(){z(v).onShrink&&z(v).onShrink()}}function o(){function i(t,e,n){var i=C(t).childNodes[0],o=u(e),r=h(n);i.style.width=o+"px",i.style.height=r+"px"}function n(t){var e=v.offsetWidth,n=v.offsetHeight;m("Storing current size",e,n),l(v,e,n),S.add(0,function(){z(v)?o()?(a.debug&&(v.offsetWidth===e&&v.offsetHeight===n||b.warn(E.get(v),"Scroll: Size changed before updating detector elements.")),i(v,e,n)):m("Aborting because element container has not been initialized"):m("Aborting because element has been uninstalled")}),S.add(1,function(){z(v)?o()?f(v,e,n):m("Aborting because element container has not been initialized"):m("Aborting because element has been uninstalled")}),t&&S.add(2,function(){z(v)?o()?t():m("Aborting because element container has not been initialized"):m("Aborting because element has been uninstalled")})}function o(){return!!z(v).container}function r(){m("notifyListenersIfNeeded invoked");var t=z(v);return void 0===z(v).lastNotifiedWidth&&t.lastWidth===t.startSize.width&&t.lastHeight===t.startSize.height?m("Not notifying: Size is the same as the start size, and there has been no notification yet."):t.lastWidth===t.lastNotifiedWidth&&t.lastHeight===t.lastNotifiedHeight?m("Not notifying: Size already notified"):(m("Current size not notified, notifying..."),t.lastNotifiedWidth=t.lastWidth,t.lastNotifiedHeight=t.lastHeight,void D(z(v).listeners,function(t){t(v)}))}function t(){if(m("Scroll detected."),s(v))m("Scroll event fired while unrendered. Ignoring...");else{var t=v.offsetWidth,e=v.offsetHeight;t!==z(v).lastWidth||e!==z(v).lastHeight?(m("Element size changed."),n(r)):m("Element size has not changed ("+t+"x"+e+").")}}if(m("registerListenersAndPositionElements invoked."),z(v)){z(v).onRendered=function(){if(m("startanimation triggered."),s(v))m("Ignoring since element is still unrendered...");else{m("Element rendered.");var t=C(v),e=M(v);0!==t.scrollLeft&&0!==t.scrollTop&&0!==e.scrollLeft&&0!==e.scrollTop||(m("Scrollbars out of sync. Updating detector elements..."),n(r))}},z(v).onExpand=t,z(v).onShrink=t;var e=z(v).style;i(v,e.width,e.height)}else m("Aborting because element has been uninstalled")}function r(){if(m("finalizeDomMutation invoked."),z(v)){var t=z(v).style;l(v,t.width,t.height),f(v,t.width,t.height)}else m("Aborting because element has been uninstalled")}function g(){t(v)}function p(){var t;m("Installing..."),z(v).listeners=[],t=e(),z(v).startSize={width:t.width,height:t.height},m("Element start size",z(v).startSize),S.add(0,n),S.add(1,i),S.add(2,o),S.add(3,r),S.add(4,g)}var w,x;t||(t=v,v=a,a=null),a=a||{},m("Making detectable..."),(x=w=v)!==x.ownerDocument.body&&!x.ownerDocument.body.contains(x)||null===window.getComputedStyle(w)?(m("Element is detached"),y(),m("Waiting until element is attached..."),z(v).onRendered=function(){m("Element is now attached"),p()}):p()},addListener:function(t,e){if(!z(t).listeners.push)throw Error("Cannot add listener to an element that is not detectable.");z(t).listeners.push(e)},uninstall:function(t){var e=z(t);e&&(e.onExpandScroll&&n(C(t),"scroll",e.onExpandScroll),e.onShrinkScroll&&n(M(t),"scroll",e.onShrinkScroll),e.onAnimationStart&&n(e.container,"animationstart",e.onAnimationStart),e.container&&t.removeChild(e.container))}}},E=o.forEach;function _(t){return Array.isArray(t)||void 0!==t.length}function T(t){if(Array.isArray(t))return t;var e=[];return E(t,function(t){e.push(t)}),e}function O(t){return t&&1===t.nodeType}function C(t,e,n){var i=t[e];return null==i&&void 0!==n?n:i}var M=function(e){var u,t,i,o,n;if((e=e||{}).idHandler)u={get:function(t){return e.idHandler.get(t,!0)},set:e.idHandler.set};else{var r=(n=1,{generate:function(){return n++}}),a=(i=(t={idGenerator:r,stateHandler:S}).idGenerator,o=t.stateHandler.getState,{get:function(t){var e=o(t);return e&&void 0!==e.id?e.id:null},set:function(t){var e=o(t);if(!e)throw Error("setId required the element to have a resize detection state.");var n=i.generate();return e.id=n}});u=a}var h=e.reporter;h||(h=function(t){function e(){}var n={log:e,warn:e,error:e};if(!t&&window.console){var i=function(t,n){t[n]=function(){var t=console[n];if(t.apply)t.apply(console,arguments);else for(var e=0;e<arguments.length;e++)t(arguments[e])}};i(n,"log"),i(n,"warn"),i(n,"error")}return n}(!1===h));var s=C(e,"batchProcessor",x({reporter:h})),f={};f.callOnAdd=!!C(e,"callOnAdd",!0),f.debug=!!C(e,"debug",!1);var l,g,p=function(i){var o={};function r(t){var e=i.get(t);return void 0===e?[]:o[e]||[]}return{get:r,add:function(t,e){var n=i.get(t);o[n]||(o[n]=[]),o[n].push(e)},removeListener:function(t,e){for(var n=r(t),i=0,o=n.length;i<o;++i)if(n[i]===e){n.splice(i,1);break}},removeAllListeners:function(t){var e=r(t);e&&(e.length=0)}}}(u),v=(l={stateHandler:S}.stateHandler.getState,{isDetectable:function(t){var e=l(t);return e&&!!e.isDetectable},markAsDetectable:function(t){l(t).isDetectable=!0},isBusy:function(t){return!!l(t).busy},markBusy:function(t,e){l(t).busy=!!e}}),c=C(e,"strategy","object"),d={reporter:h,batchProcessor:s,stateHandler:S,idHandler:u};if("scroll"===c&&(y.isLegacyOpera()?(h.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),c="object"):y.isIE(9)&&(h.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),c="object")),"scroll"===c)g=z(d);else{if("object"!==c)throw Error("Invalid strategy name: "+c);g=function(t){var s=(t=t||{}).reporter,l=t.batchProcessor,c=t.stateHandler.getState;if(!s)throw Error("Missing required dependency: reporter.");function i(t){return c(t).object}return{makeDetectable:function(t,e,n){n||(n=e,e=t,t=null),t=t||{},y.isIE(8)?n(e):function(n,i){var o=!1,r=window.getComputedStyle(n),t=n.offsetWidth,e=n.offsetHeight;function a(){function t(){if("static"===r.position){n.style.position="relative";var t=function(t,e,n,i){var o=n[i];"auto"!==o&&"0"!==o.replace(/[^-\d\.]/g,"")&&(t.warn("An element that is positioned static has style."+i+"="+o+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",e),e.style[i]=0)};t(s,n,r,"top"),t(s,n,r,"right"),t(s,n,r,"bottom"),t(s,n,r,"left")}}""!==r.position&&(t(),o=!0);var e=document.createElement("object");e.style.cssText="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",e.tabIndex=-1,e.type="text/html",e.setAttribute("aria-hidden","true"),e.onload=function(){o||t(),function t(e,n){e.contentDocument?n(e.contentDocument):setTimeout(function(){t(e,n)},100)}(this,function(t){i(n)})},y.isIE()||(e.data="about:blank"),n.appendChild(e),c(n).object=e,y.isIE()&&(e.data="about:blank")}c(n).startSize={width:t,height:e},l?l.add(a):a()}(e,n)},addListener:function(t,e){if(!i(t))throw Error("Element is not detectable by this strategy.");function n(){e(t)}y.isIE(8)?(c(t).object={proxy:n},t.attachEvent("onresize",n)):i(t).contentDocument.defaultView.addEventListener("resize",n)},uninstall:function(t){y.isIE(8)?t.detachEvent("onresize",c(t).object.proxy):t.removeChild(i(t)),delete c(t).object}}}(d)}var m={};return{listenTo:function(t,i,o){function r(e){var t=p.get(e);E(t,function(t){t(e)})}function a(t,e,n){p.add(e,n),t&&n(e)}if(o||(o=i,i=t,t={}),!i)throw Error("At least one element required.");if(!o)throw Error("Listener required.");if(O(i))i=[i];else{if(!_(i))return h.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");i=T(i)}var s=0,l=C(t,"callOnAdd",f.callOnAdd),c=C(t,"onReady",function(){}),d=C(t,"debug",f.debug);E(i,function(t){S.getState(t)||(S.initState(t),u.set(t));var n=u.get(t);if(d&&h.log("Attaching listener to element",n,t),!v.isDetectable(t))return d&&h.log(n,"Not detectable."),v.isBusy(t)?(d&&h.log(n,"System busy making it detectable"),a(l,t,o),m[n]=m[n]||[],void m[n].push(function(){++s===i.length&&c()})):(d&&h.log(n,"Making detectable..."),v.markBusy(t,!0),g.makeDetectable({debug:d},t,function(t){if(d&&h.log(n,"onElementDetectable"),S.getState(t)){v.markAsDetectable(t),v.markBusy(t,!1),g.addListener(t,r),a(l,t,o);var e=S.getState(t);e&&e.startSize&&(e.startSize.width===t.offsetWidth&&e.startSize.height===t.offsetHeight||r(t)),m[n]&&E(m[n],function(t){t()})}else d&&h.log(n,"Element uninstalled before being detectable.");delete m[n],++s===i.length&&c()}));d&&h.log(n,"Already detecable, adding listener."),a(l,t,o),s++}),s===i.length&&c()},removeListener:p.removeListener,removeAllListeners:p.removeAllListeners,uninstall:function(t){if(!t)return h.error("At least one element is required.");if(O(t))t=[t];else{if(!_(t))return h.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");t=T(t)}E(t,function(t){p.removeAllListeners(t),g.uninstall(t),S.cleanState(t)})}}}({strategy:"scroll"}),A=function(o){function t(){for(var t,e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return(t=o.call.apply(o,[this].concat(n))||this).resizeRef=h.createRef(),t}r(t,o);var e=t.prototype;return e.componentDidMount=function(){this._calculateSize()},e.componentDidUpdate=function(t){t.width===this.props.width&&t.height===this.props.height||this._calculateSize()},e.componentWillUnmount=function(){this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0)},e._calculateSize=function(){var t,e=this,n=this.props,i=n.width,o=n.height,r=n.onResize;if(i<0||o<0){if(!this._resizeNode){var a=this.resizeRef.current;if(!a)return;return void M.listenTo(this._resizeNode=a,function(){return e._calculateSize()})}t=s(this._resizeNode)}else this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0),t={width:i,height:o};r(t)},e.render=function(){var t=this.props,e=t.width,n=t.height,i=t.children;return h.createElement("div",{ref:this.resizeRef,style:{position:"absolute",width:e<0?"auto":e,height:n<0?"auto":n}},"function"==typeof i?i(this):i)},t}(h.PureComponent);A.defaultProps={width:-1,height:-1,onResize:function(){}};var k=function(o){function t(){for(var t,e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return(t=o.call.apply(o,[this].concat(n))||this).state={size:{width:0,height:0},layoutAttrs:[],count:{row:0,column:0}},t}r(t,o);var e=t.prototype;return e.getSize=function(){return this.state.size},e.getCount=function(){return this.state.count},e.componentDidMount=function(){this._calculateLayout()},e.componentDidUpdate=function(t){var e=this.props;t.direction===e.direction&&t.width===e.width&&t.height===e.height&&t.rowSpacing===e.rowSpacing&&t.columnSpacing===e.columnSpacing&&t.itemCount===e.itemCount&&t.itemWidth===e.itemWidth&&t.itemHeight===e.itemHeight||this._calculateLayout()},e._calculateLayout=function(){this.setState(function(t,e){var n=e.onResize,i=function t(e,n,i,o,r){if(!r){var a=o.width,s=0,l=0,c=0,d=[];if(a<0?(a=n*e.width,1<n&&(a+=(n-1)*i.column),l=n):0===e.width&&0===i.column?l=n:(l=1,e.width<a&&(l+=Math.floor((a-e.width)/(e.width+i.column)))),0<l&&(c=Math.ceil(n/l)),0<c){for(var u=0;u<c;u++){0<u&&(s+=i.row+e.height);for(var h=0;h<l;h++){var f=h+u*l,g=0;1<l&&(g+=Math.round(h*((a-e.width)/(l-1)))),f<n&&d.push({x:g,y:s,width:e.width,height:e.height,rowIndex:u,columnIndex:h,itemIndex:f})}}s+=e.height}return{count:{row:c,column:l},size:{width:a,height:s},layoutAttrs:d}}{if("vertical"===r)return t(e,n,i,o);if("horizontal"===r){var p=t({width:e.height,height:e.width},n,{row:i.column,column:i.row},{width:o.height,height:o.width});return{size:{width:p.size.height,height:p.size.width},count:{row:p.count.column,column:p.count.row},layoutAttrs:p.layoutAttrs.map(function(t){return{x:t.y,y:t.x,width:t.height,height:t.width,rowIndex:t.columnIndex,columnIndex:t.rowIndex,itemIndex:t.itemIndex}})}}}}({width:e.itemWidth,height:e.itemHeight},e.itemCount,{row:e.rowSpacing,column:e.columnSpacing},{width:e.width,height:e.height},e.direction);return t.size.width===i.size.width&&t.size.height===i.size.height||n(i.size),i})},e.getItemRect=function(t){var e=t.itemIndex,n=t.rowIndex,i=t.columnIndex,o=this.state,r=o.layoutAttrs;void 0!==n&&void 0!==i&&(e=function t(e,n,i){if(!i)return e.column+e.row*n.column;{if("vertical"===i)return t(e,n);if("horizontal"===i)return t({row:e.column,column:e.row},{row:n.column,column:n.row})}}({row:n,column:i},o.count,this.props.direction));var a=r[e];return a?{x:a.x,y:a.y,width:a.width,height:a.height}:null},e.render=function(){var t=this.props,e=t.itemCount,n=t.visibleRect,i=t.renderItem,o=t.children,r=this.state.layoutAttrs;if("function"==typeof o)return o(this);for(var a=[],s=0;s<e;s++){var l=r[s];if(l&&R(l,n)){var c=i(l),d=c.key||l.itemIndex,u=f({position:"absolute",left:l.x,top:l.y,width:l.width,height:l.height},c.props.style);c=h.cloneElement(c,{key:d,style:u}),a.push(c)}}return h.createElement(h.Fragment,null,a)},t}(h.PureComponent);function R(t,e,n){if(n){var i=t.x-e.x;return-.25*e.width<i+t.width&&i<1.25*e.width}return R(t,e,"x")&&R({x:t.y,y:t.x,width:t.height,height:t.width},{x:e.y,y:e.x,width:e.height,height:e.width},"y")}k.defaultProps={direction:"vertical",width:-1,height:-1,rowSpacing:0,columnSpacing:0,itemCount:0,itemWidth:0,itemHeight:0,renderItem:function(){return null},visibleRect:{x:0,y:0,width:0,height:0},onResize:function(){}};var L=function(o){function t(){for(var t,e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return(t=o.call.apply(o,[this].concat(n))||this).state={size:{width:0,height:0}},t.resizeRef=h.createRef(),t}r(t,o);var e=t.prototype;return e.componentDidMount=function(){this._calculateSize()},e.componentDidUpdate=function(t){t.width===this.props.width&&t.height===this.props.height||this._calculateSize()},e.componentWillUnmount=function(){this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0)},e._calculateSize=function(){var t,e=this,n=this.props,i=n.width,o=n.height;if(i<0||o<0){if(!this._resizeNode){var r=this.resizeRef.current;if(!r)return;return void M.listenTo(this._resizeNode=r,function(){return e._calculateSize()})}t=s(this._resizeNode)}else this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0),t={width:i,height:o};this.setState({size:t})},e.render=function(){var t=this.props,e=t.width,n=t.height;return h.createElement("div",{ref:this.resizeRef,style:{width:e<0?"100%":e,height:n<0?"100%":n}},(0,t.children)(this.state.size))},t}(h.Component);L.defaultProps={children:function(){return null},width:-1,height:-1},t.Pad=n,t.Pannable=p,t.GeneralContent=A,t.GridContent=k,t.AutoResizing=L,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t=t||self).ReactPannable={},t.React)}(this,function(t,h){"use strict";function u(t,e){if(null==t)return{};var n,i,o={},r=Object.keys(t);for(i=0;i<r.length;i++)e.indexOf(n=r[i])<0&&(o[n]=t[n]);return o}function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}h=h&&h.hasOwnProperty("default")?h.default:h;var e,g={create:function(t){var e,n=t.transformTranslate;return f({},u(t,["transformTranslate"]),(e=n)?{transform:"translate3d("+e[0]+"px, "+e[1]+"px, 0)",WebkitTransform:"translate3d("+e[0]+"px, "+e[1]+"px, 0)",msTransform:"translate("+e[0]+"px, "+e[1]+"px)"}:null)}},p=function(i){function t(){for(var o,t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return(o=i.call.apply(i,[this].concat(e))||this).state={target:null,translation:null,velocity:null,startXY:null,moveXY:null,moveT:null},o.elemRef=h.createRef(),o._onTouchStart=function(t){var e=o.props,n=e.onTouchStart;t.touches&&1===t.touches.length&&e.enabled&&o._track(t.touches[0]),n&&n(t)},o._onTouchMove=function(t){var e=o.props.onTouchMove;t.touches&&1===t.touches.length&&o._move(t.touches[0]),e&&e(t)},o._onTouchEnd=function(t){var e=o.props.onTouchEnd;t.changedTouches&&1===t.changedTouches.length&&o._end(),e&&e(t)},o._onTouchCancel=function(t){var e=o.props.onTouchCancel;t.changedTouches&&1===t.changedTouches.length&&o._end(),e&&e(t)},o._onMouseDown=function(t){var e=o.props,n=e.enabled,i=e.onMouseDown;(o._shouldPreventClick=n)&&(o._addMousePanListener(),o._track(t)),i&&i(t)},o._onMouseMove=function(t){t.preventDefault(),o._move(t)},o._onMouseUp=function(t){t.preventDefault(),o._removeMousePanListener(),o._end()},o._onClick=function(t){var e=o.props.onClick;o._shouldPreventClick&&t.preventDefault(),o._shouldPreventClick=!1,e&&e(t)},o}r(t,i);var e=t.prototype;return e.componentDidUpdate=function(t){var e=this.props.enabled;t.enabled===e||e||this._cancel()},e.componentWillUnmount=function(){this._removeMousePanListener()},e._track=function(t){this.setState({startXY:{x:t.pageX,y:t.pageY},moveXY:{x:t.pageX,y:t.pageY},moveT:(new Date).getTime()})},e._move=function(h){h={target:h.target,pageX:h.pageX,pageY:h.pageY},this.setState(function(t,e){var n=e.shouldStart,i=e.onStart,o=e.onMove,r=t.target,a=t.startXY,s=t.moveXY,l=t.moveT,c=(new Date).getTime(),d=c-l;if(!a)return null;var u={translation:{x:h.pageX-a.x,y:h.pageY-a.y},velocity:{x:(h.pageX-s.x)/d,y:(h.pageY-s.y)/d},moveXY:{x:h.pageX,y:h.pageY},moveT:c};return r?o({target:r,translation:u.translation,velocity:u.velocity}):0<Math.sqrt(u.translation.x*u.translation.x+u.translation.y*u.translation.y)&&("function"==typeof n?n({target:h.target,translation:u.translation,velocity:u.velocity}):n)&&(u.target=h.target,u.startXY={x:h.pageX,y:h.pageY},u.translation={x:0,y:0},i({target:u.target,translation:u.translation,velocity:u.velocity})),u})},e._end=function(){this.setState(function(t,e){var n=t.target;return n&&e.onEnd({target:n,translation:t.translation,velocity:t.velocity}),{target:null,translation:null,velocity:null,startXY:null,moveXY:null,moveT:null}})},e._cancel=function(){this.setState(function(t,e){var n=t.target;return n&&e.onCancel({target:n,translation:t.translation,velocity:t.velocity}),{target:null,translation:null,velocity:null,startXY:null,moveXY:null,moveT:null}})},e._addMousePanListener=function(){var t=document.documentElement;t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("mouseup",this._onMouseUp,!1)},e._removeMousePanListener=function(){var t=document.documentElement;t.removeEventListener("mousemove",this._onMouseMove,!1),t.removeEventListener("mouseup",this._onMouseUp,!1)},e.render=function(){var t=this.props,e=t.enabled,n=t.style,i=u(t,["enabled","shouldStart","onStart","onMove","onEnd","onCancel","style"]),o=g.create(f({touchAction:e?"none":"auto"},n));return h.createElement("div",f({},i,{ref:this.elemRef,style:o,onTouchStart:this._onTouchStart,onTouchEnd:this._onTouchEnd,onTouchMove:this._onTouchMove,onTouchCancel:this._onTouchCancel,onMouseDown:this._onMouseDown,onClick:this._onClick}))},t}(h.PureComponent);p.defaultProps={enabled:!0,shouldStart:!0,onStart:function(){},onMove:function(){},onEnd:function(){},onCancel:function(){}};var c=(e="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.msRequestAnimationFrame||e.setTimeout&&function(t){return e.setTimeout(t,20)}||function(){},d=e.cancelAnimationFrame||e.webkitCancelAnimationFrame||e.mozCancelAnimationFrame||e.clearTimeout||function(){};function v(t,e,n){if(n){var i="y"===n?["y","height"]:["x","width"],o=i[1];return e[o]?e[o]*Math.round(t[i[0]]/e[o]):0}return{x:v(t,e,"x"),y:v(t,e,"y")}}function y(t,e){var n=e.x,i=e.y,o=Math.sqrt(n*n+i*i);return{x:t*(n/o),y:t*(i/o)}}var n=function(n){function t(t){var e;return(e=n.call(this,t)||this)._onDragStart=function(t){var r=t.translation,a=t.velocity;e.setState(function(t,e){var n=t.contentOffset,i=e.directionalLockEnabled?Math.abs(a.y)<Math.abs(a.x)?"x":"y":"xy",o={x:n.x+("y"===i?0:r.x),y:n.y+("x"===i?0:r.y)};return{contentOffset:o,contentVelocity:{x:"y"===i?0:a.x,y:"x"===i?0:a.y},dragging:!0,dragStartOffset:o,dragDirection:i,decelerating:!1,decelerationEndOffset:null,decelerationRate:0}})},e._onDragMove=function(t){var i=t.translation,o=t.velocity;e.setState(function(t){var e=t.dragStartOffset,n=t.dragDirection;return{contentOffset:{x:e.x+("y"===n?0:i.x),y:e.y+("x"===n?0:i.y)},contentVelocity:{x:"y"===n?0:o.x,y:"x"===n?0:o.y}}})},e._onDragEnd=function(t){var d=t.translation,u=t.velocity;e.setState(function(t,e){var n=t.dragStartOffset,i=t.dragDirection,o=t.size,r=e.pagingEnabled,a={x:n.x+("y"===i?0:d.x),y:n.y+("x"===i?0:d.y)},s={x:"y"===i?0:u.x,y:"x"===i?0:u.y},l=r?.02:.002;r&&(s=function t(e,n,i,o){if(o){var r="y"===o?["y","height"]:["x","width"],a=r[0],s=r[1];if(!i[a])return 0;var l=i[a]<0?-1:1;return l*Math.min(Math.abs(e[a]),Math.sqrt(l*i[a]*n[s]))}return"number"==typeof i&&(i=y(i,e)),{x:t(e,n,i,"x"),y:t(e,n,i,"y")}}(s,o,l));var c=function t(e,n,i,o){if(o)return i[o]?e[o]+.5*n[o]*(n[o]/i[o]):e[o];return"number"==typeof i&&(i=y(i,n)),{x:t(e,n,i,"x"),y:t(e,n,i,"y")}}(a,s,l);return r&&(c=v(c,o)),{contentOffset:a,contentVelocity:s,dragging:!1,dragStartOffset:null,dragDirection:"xy",decelerating:!0,decelerationEndOffset:c,decelerationRate:l}})},e._onDragCancel=function(t){var r=t.translation,a=t.velocity;e.setState(function(t,e){var n=t.dragStartOffset,i={x:n.x+r.x,y:n.y+r.y},o=n;return e.pagingEnabled&&(o=v(o,t.size)),{contentOffset:i,contentVelocity:a,dragging:!1,dragStartOffset:null,dragDirection:"xy",decelerating:!0,decelerationEndOffset:o,decelerationRate:.01}})},e.state={size:{width:t.width,height:t.height},contentSize:{width:t.contentWidth,height:t.contentHeight},contentOffset:{x:0,y:0},contentVelocity:{x:0,y:0},prevContentOffset:null,dragging:!1,decelerating:!1,dragStartOffset:null,dragDirection:"xy",decelerationEndOffset:null,decelerationRate:0},e.boundingRef=h.createRef(),e.contentRef=h.createRef(),e.setContentSize=e.setContentSize.bind(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)),e}r(t,n),t.getDerivedStateFromProps=function(t,e){var n=e.size,i=e.contentSize,o=e.contentOffset,r=e.contentVelocity,a=e.dragging,s=e.decelerating,l=e.decelerationEndOffset,c={};if(e.prevContentOffset!==o){var d=function t(e,n,i,o){if(o){var r="y"===o?["y","height"]:["x","width"],a=r[0],s=r[1];return Math.max(Math.min(n[s]-i[s],0),Math.min(e[a],0))}return{x:t(e,n,i,"x"),y:t(e,n,i,"y")}}(o,n,i),u=r,h=s,f=l;d.x===o.x&&d.y===o.y?d=o:(u={x:d.x!==o.x?0:u.x,y:d.y!==o.y?0:u.y},f&&(f={x:d.x!==o.x?d.x:f.x,y:d.y!==o.y?d.y:f.y})),f&&d.x===f.x&&d.y===f.y&&0===u.x&&0===u.y&&(h=!1,f=null,c.decelerationRate=0),c.prevContentOffset=o,c.contentOffset=d,u!==r&&(c.contentVelocity=u),h!==s&&(c.decelerating=h),f!==l&&(c.decelerationEndOffset=f),t.onScroll({contentOffset:d,contentVelocity:u,decelerating:h,dragging:a,size:n,contentSize:i})}return c};var e=t.prototype;return e.componentDidUpdate=function(t,e){var n=this,i=this.props,o=i.width,r=i.height,a=i.contentWidth,s=i.contentHeight;if(t.width===o&&t.height===r||this.setState(function(t){return{size:{width:o,height:r},contentOffset:f({},t.contentOffset)}}),t.contentWidth===a&&t.contentHeight===s||this.setState(function(t){return{contentSize:{width:a,height:s},contentOffset:f({},t.contentOffset)}}),e.contentOffset!==this.state.contentOffset&&this.state.decelerationEndOffset){var l=(new Date).getTime();this._deceleratingTimer&&d(this._deceleratingTimer),this._deceleratingTimer=c(function(){n._deceleratingTimer=void 0,n._decelerate((new Date).getTime()-l)})}},e.componentWillUnmount=function(){this._deceleratingTimer&&(d(this._deceleratingTimer),this._deceleratingTimer=void 0)},e.getSize=function(){return this.state.size},e.getContentSize=function(){return this.state.contentSize},e.getContentOffset=function(){return this.state.contentOffset},e.isDragging=function(){return this.state.dragging},e.isDecelerating=function(){return this.state.decelerating},e.setContentSize=function(e){this.setState(function(t){return{contentSize:e,contentOffset:f({},t.contentOffset)}})},e.scrollTo=function(t){var i=t.offset,o=t.animated;this.setState(function(t,e){var n=t.contentOffset;return t.dragging?null:o?(e.pagingEnabled&&(i=v(i,t.size)),{contentOffset:f({},n),decelerating:!0,decelerationEndOffset:i,decelerationRate:.01}):{contentOffset:i,contentVelocity:{x:0,y:0},decelerating:!1,decelerationEndOffset:null,decelerationRate:0}})},e.scrollToRect=function(t){var e=t.rect,n=t.align,i=t.animated,o=this.state,r=function t(e,n,i,o,r,a){if(a){var s,l="y"===a?["y","height"]:["x","width"],c=l[0],d=l[1];if("auto"===i[c]){var u=r[d]<n[d]?-1:1;s=u*Math.max(0,Math.min(u*(e[c]+o[c]),u*(r[d]-n[d])))-e[c]}else"start"===i[c]?i[c]=0:"center"===i[c]?i[c]=.5:"end"===i[c]&&(i[c]=1),("number"!=typeof i[c]||isNaN(i[c]))&&(i[c]=.5),s=i[c]*(r[d]-n[d])-e[c];return s}return"object"!=typeof i&&(i={x:i,y:i}),{x:t(e,n,i,o,r,"x"),y:t(e,n,i,o,r,"y")}}({x:e.x,y:e.y},{width:e.width,height:e.height},void 0===n?"auto":n,o.contentOffset,o.size);this.scrollTo({offset:r,animated:i})},e._decelerate=function(i){this.setState(function(t){var e=t.decelerationEndOffset;if(!e)return null;var n=function t(e,n,i,o,r,a){if(a){var s=a;if(!n[s])return{offset:r[s],velocity:0};var l=(n[s]<0?-1:1)*Math.sqrt(.5*o[s]*o[s]+n[s]*(r[s]-i[s])),c=n[s]?(l-o[s])/n[s]:0;return(n[s]?(2*l-o[s])/n[s]:0)<e?{offset:r[s],velocity:0}:{offset:i[s]+.5*(o[s]+l)*c-.5*(2*l-n[s]*Math.abs(c-e))*(c-e),velocity:l-n[s]*Math.abs(c-e)}}"number"==typeof n&&(n=y(n,{x:r.x-i.x,y:r.y-i.y}));var d=t(e,n,i,o,r,"x"),u=t(e,n,i,o,r,"y");return{offset:{x:d.offset,y:u.offset},velocity:{x:d.velocity,y:u.velocity}}}(i,t.decelerationRate,t.contentOffset,t.contentVelocity,e);return{contentOffset:n.offset,contentVelocity:n.velocity}})},e.render=function(){var t=this.props,e=t.scrollEnabled,n=t.style,i=t.children,o=u(t,["width","height","contentWidth","contentHeight","scrollEnabled","pagingEnabled","directionalLockEnabled","style","children"]),r=this.state,a=r.size,s=r.contentSize,l=r.contentOffset,c=g.create(f({overflow:"hidden",position:"relative",boxSizing:"border-box",width:a.width,height:a.height},n)),d=g.create({position:"relative",boxSizing:"border-box",width:s.width,height:s.height,transformTranslate:[l.x,l.y]});return h.createElement(p,f({},o,{ref:this.boundingRef,style:c,enabled:e,onStart:this._onDragStart,onMove:this._onDragMove,onEnd:this._onDragEnd,onCancel:this._onDragCancel}),h.createElement("div",{ref:this.contentRef,style:d},"function"==typeof i?i(this):i))},t}(h.PureComponent);function s(t){var e=window.getComputedStyle(t)||{},n=t.offsetWidth||0,i=t.offsetHeight||0;return e.paddingLeft&&(n-=parseInt(e.paddingLeft,10)),e.paddingRight&&(n-=parseInt(e.paddingRight,10)),e.borderLeftWidth&&(n-=parseInt(e.borderLeftWidth,10)),e.borderRightWidth&&(n-=parseInt(e.borderRightWidth,10)),e.paddingTop&&(i-=parseInt(e.paddingTop,10)),e.paddingBottom&&(i-=parseInt(e.paddingBottom,10)),e.borderTopWidth&&(i-=parseInt(e.borderTopWidth,10)),e.borderBottomWidth&&(i-=parseInt(e.borderBottomWidth,10)),{width:n,height:i}}function i(t,e){return t(e={exports:{}},e.exports),e.exports}n.defaultProps={children:null,width:0,height:0,contentWidth:0,contentHeight:0,scrollEnabled:!0,pagingEnabled:!1,directionalLockEnabled:!1,onScroll:function(){}};var o=i(function(t){(t.exports={}).forEach=function(t,e){for(var n=0;n<t.length;n++){var i=e(t[n]);if(i)return i}}}),m=i(function(t){var e=t.exports={};e.isIE=function(t){return(-1!=(e=navigator.userAgent.toLowerCase()).indexOf("msie")||-1!=e.indexOf("trident")||-1!=e.indexOf(" edge/"))&&(!t||t===function(){for(var t=3,e=document.createElement("div"),n=e.getElementsByTagName("i");e.innerHTML="\x3c!--[if gt IE "+ ++t+"]><i></i><![endif]--\x3e",n[0];);return 4<t?t:void 0}());var e},e.isLegacyOpera=function(){return!!window.opera}}),b=i(function(t){(t.exports={}).getOption=function(t,e,n){var i=t[e];return null!=i||void 0===n?i:n}}),x=function(t){var e=(t=t||{}).reporter,n=b.getOption(t,"async",!0),i=b.getOption(t,"auto",!0);i&&!n&&(e&&e.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),n=!0);var o,r=w(),a=!1;function s(){for(a=!0;r.size();){var t=r;r=w(),t.process()}a=!1}function l(){o=setTimeout(s,0)}return{add:function(t,e){!a&&i&&n&&0===r.size()&&l(),r.add(t,e)},force:function(t){a||(void 0===t&&(t=n),o&&(clearTimeout(o),o=null),t?l():s())}}};function w(){var i={},n=0,o=0,r=0;return{add:function(t,e){e||(e=t,t=0),o<t?o=t:t<r&&(r=t),i[t]||(i[t]=[]),i[t].push(e),n++},process:function(){for(var t=r;t<=o;t++)for(var e=i[t],n=0;n<e.length;n++)(0,e[n])()},size:function(){return n}}}var a="_erd";function l(t){return t[a]}var S={initState:function(t){return t[a]={},l(t)},getState:l,cleanState:function(t){delete t[a]}},D=o.forEach,z=function(t){var w=(t=t||{}).reporter,S=t.batchProcessor,z=t.stateHandler.getState,E=t.idHandler;if(!S)throw Error("Missing required dependency: batchProcessor");if(!w)throw Error("Missing required dependency: reporter.");var _=function(){var t=document.createElement("div");t.style.cssText="position: absolute; width: 1000px; height: 1000px; visibility: hidden; margin: 0; padding: 0;";var e=document.createElement("div");e.style.cssText="position: absolute; width: 500px; height: 500px; overflow: scroll; visibility: none; top: -1500px; left: -1500px; visibility: hidden; margin: 0; padding: 0;",e.appendChild(t),document.body.insertBefore(e,document.body.firstChild);var n=500-e.clientWidth,i=500-e.clientHeight;return document.body.removeChild(e),{width:n,height:i}}(),T="erd_scroll_detection_container";function O(t,e,n){if(t.addEventListener)t.addEventListener(e,n);else{if(!t.attachEvent)return w.error("[scroll] Don't know how to add event listeners.");t.attachEvent("on"+e,n)}}function n(t,e,n){if(t.removeEventListener)t.removeEventListener(e,n);else{if(!t.detachEvent)return w.error("[scroll] Don't know how to remove event listeners.");t.detachEvent("on"+e,n)}}function C(t){return z(t).container.childNodes[0].childNodes[0].childNodes[0]}function M(t){return z(t).container.childNodes[0].childNodes[0].childNodes[1]}return function(i,t){if(!document.getElementById(i)){var e=t+"_animation",n=t+"_animation_active",o="/* Created by the element-resize-detector library. */\n";o+="."+t+" > div::-webkit-scrollbar { display: none; }\n\n",o+="."+n+" { -webkit-animation-duration: 0.1s; animation-duration: 0.1s; -webkit-animation-name: "+e+"; animation-name: "+e+"; }\n",o+="@-webkit-keyframes "+e+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }\n",function(t,e){e=e||function(t){document.head.appendChild(t)};var n=document.createElement("style");n.innerHTML=t,n.id=i,e(n)}(o+="@keyframes "+e+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }")}}("erd_scroll_detection_scrollbar_style",T),{makeDetectable:function(a,v,t){function y(){if(a.debug){var t=Array.prototype.slice.call(arguments);if(t.unshift(E.get(v),"Scroll: "),w.log.apply)w.log.apply(null,t);else for(var e=0;e<t.length;e++)w.log(t[e])}}function s(t){var e=z(t).container.childNodes[0],n=window.getComputedStyle(e);return!n.width||-1==n.width.indexOf("px")}function e(){var t=window.getComputedStyle(v),e={};return e.position=t.position,e.width=v.offsetWidth,e.height=v.offsetHeight,e.top=t.top,e.right=t.right,e.bottom=t.bottom,e.left=t.left,e.widthCSS=t.width,e.heightCSS=t.height,e}function n(){if(y("storeStyle invoked."),z(v)){var t=e();z(v).style=t}else y("Aborting because element has been uninstalled")}function l(t,e,n){z(t).lastWidth=e,z(t).lastHeight=n}function c(){return 2*_.width+1}function d(){return 2*_.height+1}function u(t){return t+10+c()}function h(t){return t+10+d()}function f(t,e,n){var i=C(t),o=M(t),r=u(e),a=h(n),s=2*e+c(),l=2*n+d();i.scrollLeft=r,i.scrollTop=a,o.scrollLeft=s,o.scrollTop=l}function m(){var t=z(v).container;if(!t){(t=document.createElement("div")).className=T,t.style.cssText="visibility: hidden; display: inline; width: 0px; height: 0px; z-index: -1; overflow: hidden; margin: 0; padding: 0;",(z(v).container=t).className+=" "+T+"_animation_active",v.appendChild(t);var e=function(){z(v).onRendered&&z(v).onRendered()};O(t,"animationstart",e),z(v).onAnimationStart=e}return t}function i(){if(y("Injecting elements"),z(v)){!function(){var t=z(v).style;if("static"===t.position){v.style.position="relative";var e=function(t,e,n,i){var o=n[i];"auto"!==o&&"0"!==o.replace(/[^-\d\.]/g,"")&&(t.warn("An element that is positioned static has style."+i+"="+o+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",e),e.style[i]=0)};e(w,v,t,"top"),e(w,v,t,"right"),e(w,v,t,"bottom"),e(w,v,t,"left")}}();var t=z(v).container;t||(t=m());var e,n,i,o,r=_.width,a=_.height,s="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; left: "+(e=(e=-(1+r))?e+"px":"0")+"; top: "+(n=(n=-(1+a))?n+"px":"0")+"; right: "+(o=(o=-r)?o+"px":"0")+"; bottom: "+(i=(i=-a)?i+"px":"0")+";",l=document.createElement("div"),c=document.createElement("div"),d=document.createElement("div"),u=document.createElement("div"),h=document.createElement("div"),f=document.createElement("div");l.dir="ltr",l.style.cssText="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; width: 100%; height: 100%; left: 0px; top: 0px;",c.className=l.className=T,c.style.cssText=s,d.style.cssText="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",u.style.cssText="position: absolute; left: 0; top: 0;",h.style.cssText="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",f.style.cssText="position: absolute; width: 200%; height: 200%;",d.appendChild(u),h.appendChild(f),c.appendChild(d),c.appendChild(h),l.appendChild(c),t.appendChild(l),O(d,"scroll",g),O(h,"scroll",p),z(v).onExpandScroll=g,z(v).onShrinkScroll=p}else y("Aborting because element has been uninstalled");function g(){z(v).onExpand&&z(v).onExpand()}function p(){z(v).onShrink&&z(v).onShrink()}}function o(){function i(t,e,n){var i=C(t).childNodes[0],o=u(e),r=h(n);i.style.width=o+"px",i.style.height=r+"px"}function n(t){var e=v.offsetWidth,n=v.offsetHeight;y("Storing current size",e,n),l(v,e,n),S.add(0,function(){z(v)?o()?(a.debug&&(v.offsetWidth===e&&v.offsetHeight===n||w.warn(E.get(v),"Scroll: Size changed before updating detector elements.")),i(v,e,n)):y("Aborting because element container has not been initialized"):y("Aborting because element has been uninstalled")}),S.add(1,function(){z(v)?o()?f(v,e,n):y("Aborting because element container has not been initialized"):y("Aborting because element has been uninstalled")}),t&&S.add(2,function(){z(v)?o()?t():y("Aborting because element container has not been initialized"):y("Aborting because element has been uninstalled")})}function o(){return!!z(v).container}function r(){y("notifyListenersIfNeeded invoked");var t=z(v);return void 0===z(v).lastNotifiedWidth&&t.lastWidth===t.startSize.width&&t.lastHeight===t.startSize.height?y("Not notifying: Size is the same as the start size, and there has been no notification yet."):t.lastWidth===t.lastNotifiedWidth&&t.lastHeight===t.lastNotifiedHeight?y("Not notifying: Size already notified"):(y("Current size not notified, notifying..."),t.lastNotifiedWidth=t.lastWidth,t.lastNotifiedHeight=t.lastHeight,void D(z(v).listeners,function(t){t(v)}))}function t(){if(y("Scroll detected."),s(v))y("Scroll event fired while unrendered. Ignoring...");else{var t=v.offsetWidth,e=v.offsetHeight;t!==z(v).lastWidth||e!==z(v).lastHeight?(y("Element size changed."),n(r)):y("Element size has not changed ("+t+"x"+e+").")}}if(y("registerListenersAndPositionElements invoked."),z(v)){z(v).onRendered=function(){if(y("startanimation triggered."),s(v))y("Ignoring since element is still unrendered...");else{y("Element rendered.");var t=C(v),e=M(v);0!==t.scrollLeft&&0!==t.scrollTop&&0!==e.scrollLeft&&0!==e.scrollTop||(y("Scrollbars out of sync. Updating detector elements..."),n(r))}},z(v).onExpand=t,z(v).onShrink=t;var e=z(v).style;i(v,e.width,e.height)}else y("Aborting because element has been uninstalled")}function r(){if(y("finalizeDomMutation invoked."),z(v)){var t=z(v).style;l(v,t.width,t.height),f(v,t.width,t.height)}else y("Aborting because element has been uninstalled")}function g(){t(v)}function p(){var t;y("Installing..."),z(v).listeners=[],t=e(),z(v).startSize={width:t.width,height:t.height},y("Element start size",z(v).startSize),S.add(0,n),S.add(1,i),S.add(2,o),S.add(3,r),S.add(4,g)}var b,x;t||(t=v,v=a,a=null),a=a||{},y("Making detectable..."),(x=b=v)!==x.ownerDocument.body&&!x.ownerDocument.body.contains(x)||null===window.getComputedStyle(b)?(y("Element is detached"),m(),y("Waiting until element is attached..."),z(v).onRendered=function(){y("Element is now attached"),p()}):p()},addListener:function(t,e){if(!z(t).listeners.push)throw Error("Cannot add listener to an element that is not detectable.");z(t).listeners.push(e)},uninstall:function(t){var e=z(t);e&&(e.onExpandScroll&&n(C(t),"scroll",e.onExpandScroll),e.onShrinkScroll&&n(M(t),"scroll",e.onShrinkScroll),e.onAnimationStart&&n(e.container,"animationstart",e.onAnimationStart),e.container&&t.removeChild(e.container))}}},E=o.forEach;function _(t){return Array.isArray(t)||void 0!==t.length}function T(t){if(Array.isArray(t))return t;var e=[];return E(t,function(t){e.push(t)}),e}function O(t){return t&&1===t.nodeType}function C(t,e,n){var i=t[e];return null==i&&void 0!==n?n:i}var M=function(e){var u,t,i,o,n;if((e=e||{}).idHandler)u={get:function(t){return e.idHandler.get(t,!0)},set:e.idHandler.set};else{var r=(n=1,{generate:function(){return n++}}),a=(i=(t={idGenerator:r,stateHandler:S}).idGenerator,o=t.stateHandler.getState,{get:function(t){var e=o(t);return e&&void 0!==e.id?e.id:null},set:function(t){var e=o(t);if(!e)throw Error("setId required the element to have a resize detection state.");var n=i.generate();return e.id=n}});u=a}var h=e.reporter;h||(h=function(t){function e(){}var n={log:e,warn:e,error:e};if(!t&&window.console){var i=function(t,n){t[n]=function(){var t=console[n];if(t.apply)t.apply(console,arguments);else for(var e=0;e<arguments.length;e++)t(arguments[e])}};i(n,"log"),i(n,"warn"),i(n,"error")}return n}(!1===h));var s=C(e,"batchProcessor",x({reporter:h})),f={};f.callOnAdd=!!C(e,"callOnAdd",!0),f.debug=!!C(e,"debug",!1);var l,g,p=function(i){var o={};function r(t){var e=i.get(t);return void 0===e?[]:o[e]||[]}return{get:r,add:function(t,e){var n=i.get(t);o[n]||(o[n]=[]),o[n].push(e)},removeListener:function(t,e){for(var n=r(t),i=0,o=n.length;i<o;++i)if(n[i]===e){n.splice(i,1);break}},removeAllListeners:function(t){var e=r(t);e&&(e.length=0)}}}(u),v=(l={stateHandler:S}.stateHandler.getState,{isDetectable:function(t){var e=l(t);return e&&!!e.isDetectable},markAsDetectable:function(t){l(t).isDetectable=!0},isBusy:function(t){return!!l(t).busy},markBusy:function(t,e){l(t).busy=!!e}}),c=C(e,"strategy","object"),d={reporter:h,batchProcessor:s,stateHandler:S,idHandler:u};if("scroll"===c&&(m.isLegacyOpera()?(h.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),c="object"):m.isIE(9)&&(h.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),c="object")),"scroll"===c)g=z(d);else{if("object"!==c)throw Error("Invalid strategy name: "+c);g=function(t){var s=(t=t||{}).reporter,l=t.batchProcessor,c=t.stateHandler.getState;if(!s)throw Error("Missing required dependency: reporter.");function i(t){return c(t).object}return{makeDetectable:function(t,e,n){n||(n=e,e=t,t=null),t=t||{},m.isIE(8)?n(e):function(n,i){var o=!1,r=window.getComputedStyle(n),t=n.offsetWidth,e=n.offsetHeight;function a(){function t(){if("static"===r.position){n.style.position="relative";var t=function(t,e,n,i){var o=n[i];"auto"!==o&&"0"!==o.replace(/[^-\d\.]/g,"")&&(t.warn("An element that is positioned static has style."+i+"="+o+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+i+" will be set to 0. Element: ",e),e.style[i]=0)};t(s,n,r,"top"),t(s,n,r,"right"),t(s,n,r,"bottom"),t(s,n,r,"left")}}""!==r.position&&(t(),o=!0);var e=document.createElement("object");e.style.cssText="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",e.tabIndex=-1,e.type="text/html",e.setAttribute("aria-hidden","true"),e.onload=function(){o||t(),function t(e,n){e.contentDocument?n(e.contentDocument):setTimeout(function(){t(e,n)},100)}(this,function(t){i(n)})},m.isIE()||(e.data="about:blank"),n.appendChild(e),c(n).object=e,m.isIE()&&(e.data="about:blank")}c(n).startSize={width:t,height:e},l?l.add(a):a()}(e,n)},addListener:function(t,e){if(!i(t))throw Error("Element is not detectable by this strategy.");function n(){e(t)}m.isIE(8)?(c(t).object={proxy:n},t.attachEvent("onresize",n)):i(t).contentDocument.defaultView.addEventListener("resize",n)},uninstall:function(t){m.isIE(8)?t.detachEvent("onresize",c(t).object.proxy):t.removeChild(i(t)),delete c(t).object}}}(d)}var y={};return{listenTo:function(t,i,o){function r(e){var t=p.get(e);E(t,function(t){t(e)})}function a(t,e,n){p.add(e,n),t&&n(e)}if(o||(o=i,i=t,t={}),!i)throw Error("At least one element required.");if(!o)throw Error("Listener required.");if(O(i))i=[i];else{if(!_(i))return h.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");i=T(i)}var s=0,l=C(t,"callOnAdd",f.callOnAdd),c=C(t,"onReady",function(){}),d=C(t,"debug",f.debug);E(i,function(t){S.getState(t)||(S.initState(t),u.set(t));var n=u.get(t);if(d&&h.log("Attaching listener to element",n,t),!v.isDetectable(t))return d&&h.log(n,"Not detectable."),v.isBusy(t)?(d&&h.log(n,"System busy making it detectable"),a(l,t,o),y[n]=y[n]||[],void y[n].push(function(){++s===i.length&&c()})):(d&&h.log(n,"Making detectable..."),v.markBusy(t,!0),g.makeDetectable({debug:d},t,function(t){if(d&&h.log(n,"onElementDetectable"),S.getState(t)){v.markAsDetectable(t),v.markBusy(t,!1),g.addListener(t,r),a(l,t,o);var e=S.getState(t);e&&e.startSize&&(e.startSize.width===t.offsetWidth&&e.startSize.height===t.offsetHeight||r(t)),y[n]&&E(y[n],function(t){t()})}else d&&h.log(n,"Element uninstalled before being detectable.");delete y[n],++s===i.length&&c()}));d&&h.log(n,"Already detecable, adding listener."),a(l,t,o),s++}),s===i.length&&c()},removeListener:p.removeListener,removeAllListeners:p.removeAllListeners,uninstall:function(t){if(!t)return h.error("At least one element is required.");if(O(t))t=[t];else{if(!_(t))return h.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");t=T(t)}E(t,function(t){p.removeAllListeners(t),g.uninstall(t),S.cleanState(t)})}}}({strategy:"scroll"}),A=function(o){function t(){for(var t,e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return(t=o.call.apply(o,[this].concat(n))||this).resizeRef=h.createRef(),t}r(t,o);var e=t.prototype;return e.componentDidMount=function(){this._calculateSize()},e.componentDidUpdate=function(t){t.width===this.props.width&&t.height===this.props.height||this._calculateSize()},e.componentWillUnmount=function(){this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0)},e._calculateSize=function(){var t,e=this,n=this.props,i=n.width,o=n.height,r=n.onResize;if(i<0||o<0){if(!this._resizeNode){var a=this.resizeRef.current;if(!a)return;return void M.listenTo(this._resizeNode=a,function(){return e._calculateSize()})}t=s(this._resizeNode)}else this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0),t={width:i,height:o};r(t)},e.render=function(){var t=this.props,e=t.width,n=t.height,i=t.children;return h.createElement("div",{ref:this.resizeRef,style:{position:"absolute",width:e<0?"auto":e,height:n<0?"auto":n}},"function"==typeof i?i(this):i)},t}(h.PureComponent);A.defaultProps={width:-1,height:-1,onResize:function(){}};var k=function(o){function t(){for(var t,e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return(t=o.call.apply(o,[this].concat(n))||this).state={size:{width:0,height:0},layoutAttrs:[],count:{row:0,column:0}},t}r(t,o);var e=t.prototype;return e.getSize=function(){return this.state.size},e.getCount=function(){return this.state.count},e.componentDidMount=function(){this._calculateLayout()},e.componentDidUpdate=function(t){var e=this.props;t.direction===e.direction&&t.width===e.width&&t.height===e.height&&t.rowSpacing===e.rowSpacing&&t.columnSpacing===e.columnSpacing&&t.itemCount===e.itemCount&&t.itemWidth===e.itemWidth&&t.itemHeight===e.itemHeight||this._calculateLayout()},e._calculateLayout=function(){this.setState(function(t,e){var n=e.onResize,i=function(t,e,n,i,o){var r,a,s="horizontal"===o?["y","x","height","width","column","row"]:["x","y","width","height","row","column"],l=s[0],c=s[1],d=s[2],u=s[3],h=s[4],f=s[5],g=i[d],p=0,v=0,y=0,m=[];g<0?(g=e*t[d],1<e&&(g+=(e-1)*n[f]),y=e):0===t[d]&&0===n[f]?y=e:(y=1,t[d]<g&&(y+=Math.floor((g-t[d])/(t[d]+n[f]))));0<y&&(v=Math.ceil(e/y));if(0<v){for(var b=0;b<v;b++){0<b&&(p+=n[h]+t[u]);for(var x=0;x<y;x++){var w,S=x+b*y,z=0;if(1<y&&(z+=Math.round(x*((g-t[d])/(y-1)))),S<e)m.push(((w={})[l]=z,w[c]=p,w[d]=t[d],w[u]=t[u],w[h+"Index"]=b,w[f+"Index"]=x,w.itemIndex=S,w))}}p+=t[u]}return{count:(r={},r[h]=v,r[f]=y,r),size:(a={},a[d]=g,a[u]=p,a),layoutAttrs:m}}({width:e.itemWidth,height:e.itemHeight},e.itemCount,{row:e.rowSpacing,column:e.columnSpacing},{width:e.width,height:e.height},e.direction);return t.size.width===i.size.width&&t.size.height===i.size.height||n(i.size),i})},e.getItemRect=function(t){var e,n,i,o=t.itemIndex,r=t.rowIndex,a=t.columnIndex,s=this.state;void 0!==r&&void 0!==a&&(o=(e={row:r,column:a})[i=(n="horizontal"===this.props.direction?["column","row"]:["row","column"])[1]]+e[n[0]]*s.count[i]);var l=s.layoutAttrs[o];return l?{x:l.x,y:l.y,width:l.width,height:l.height}:null},e.render=function(){var t=this.props,e=t.itemCount,n=t.visibleRect,i=t.renderItem,o=t.children,r=this.state.layoutAttrs;if("function"==typeof o)return o(this);for(var a=[],s=0;s<e;s++){var l=r[s];if(l&&R(l,n)){var c=i(l),d=c.key||l.itemIndex,u=f({position:"absolute",left:l.x,top:l.y,width:l.width,height:l.height},c.props.style);c=h.cloneElement(c,{key:d,style:u}),a.push(c)}}return h.createElement(h.Fragment,null,a)},t}(h.PureComponent);function R(t,e,n){if(n){var i="y"===n?["y","height"]:["x","width"],o=i[0],r=i[1],a=t[o]-e[o];return-.25*e[r]<a+t[r]&&a<1.25*e[r]}return R(t,e,"x")&&R(t,e,"y")}k.defaultProps={direction:"vertical",width:-1,height:-1,rowSpacing:0,columnSpacing:0,itemCount:0,itemWidth:0,itemHeight:0,renderItem:function(){return null},visibleRect:{x:0,y:0,width:0,height:0},onResize:function(){}};var L=function(o){function t(){for(var t,e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return(t=o.call.apply(o,[this].concat(n))||this).state={size:{width:0,height:0}},t.resizeRef=h.createRef(),t}r(t,o);var e=t.prototype;return e.componentDidMount=function(){this._calculateSize()},e.componentDidUpdate=function(t){t.width===this.props.width&&t.height===this.props.height||this._calculateSize()},e.componentWillUnmount=function(){this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0)},e._calculateSize=function(){var t,e=this,n=this.props,i=n.width,o=n.height;if(i<0||o<0){if(!this._resizeNode){var r=this.resizeRef.current;if(!r)return;return void M.listenTo(this._resizeNode=r,function(){return e._calculateSize()})}t=s(this._resizeNode)}else this._resizeNode&&(M.uninstall(this._resizeNode),this._resizeNode=void 0),t={width:i,height:o};this.setState({size:t})},e.render=function(){var t=this.props,e=t.width,n=t.height;return h.createElement("div",{ref:this.resizeRef,style:{width:e<0?"100%":e,height:n<0?"100%":n}},(0,t.children)(this.state.size))},t}(h.Component);L.defaultProps={children:function(){return null},width:-1,height:-1},t.Pad=n,t.Pannable=p,t.GeneralContent=A,t.GridContent=k,t.AutoResizing=L,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -189,148 +189,92 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
if (name) { | ||
var dx = rect.x - vRect.x; | ||
return -0.25 * vRect.width < dx + rect.width && dx < 1.25 * vRect.width; | ||
var _ref2 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref2[0], | ||
width = _ref2[1]; | ||
var dx = rect[x] - vRect[x]; | ||
return -0.25 * vRect[width] < dx + rect[width] && dx < 1.25 * vRect[width]; | ||
} | ||
return needsRender(rect, vRect, 'x') && needsRender({ | ||
x: rect.y, | ||
y: rect.x, | ||
width: rect.height, | ||
height: rect.width | ||
}, { | ||
x: vRect.y, | ||
y: vRect.x, | ||
width: vRect.height, | ||
height: vRect.width | ||
}, 'y'); | ||
return needsRender(rect, vRect, 'x') && needsRender(rect, vRect, 'y'); | ||
} | ||
function calculateItemIndex(index, count, direction) { | ||
if (!direction) { | ||
return index.column + index.row * count.column; | ||
} | ||
var _ref3 = direction === 'horizontal' ? ['column', 'row'] : ['row', 'column'], | ||
row = _ref3[0], | ||
column = _ref3[1]; | ||
if (direction === 'vertical') { | ||
return calculateItemIndex(index, count); | ||
} else if (direction === 'horizontal') { | ||
return calculateItemIndex({ | ||
row: index.column, | ||
column: index.row | ||
}, { | ||
row: count.column, | ||
column: count.row | ||
}); | ||
} | ||
return index[column] + index[row] * count[column]; | ||
} | ||
function calculateLayout(itemSize, itemCount, spacing, size, direction) { | ||
if (!direction) { | ||
var sizeWidth = size.width; | ||
var sizeHeight = 0; | ||
var columnCount = 0; | ||
var rowCount = 0; | ||
var layoutAttrs = []; | ||
var _count, _size; | ||
if (sizeWidth < 0) { | ||
sizeWidth = itemCount * itemSize.width; | ||
var _ref4 = direction === 'horizontal' ? ['y', 'x', 'height', 'width', 'column', 'row'] : ['x', 'y', 'width', 'height', 'row', 'column'], | ||
x = _ref4[0], | ||
y = _ref4[1], | ||
width = _ref4[2], | ||
height = _ref4[3], | ||
row = _ref4[4], | ||
column = _ref4[5]; | ||
if (itemCount > 1) { | ||
sizeWidth += (itemCount - 1) * spacing.column; | ||
} | ||
var sizeWidth = size[width]; | ||
var sizeHeight = 0; | ||
var countRow = 0; | ||
var countColumn = 0; | ||
var layoutAttrs = []; | ||
columnCount = itemCount; | ||
if (sizeWidth < 0) { | ||
sizeWidth = itemCount * itemSize[width]; | ||
if (itemCount > 1) { | ||
sizeWidth += (itemCount - 1) * spacing[column]; | ||
} | ||
countColumn = itemCount; | ||
} else { | ||
if (itemSize[width] === 0 && spacing[column] === 0) { | ||
countColumn = itemCount; | ||
} else { | ||
if (itemSize.width === 0 && spacing.column === 0) { | ||
columnCount = itemCount; | ||
} else { | ||
columnCount = 1; | ||
countColumn = 1; | ||
if (itemSize.width < sizeWidth) { | ||
columnCount += Math.floor((sizeWidth - itemSize.width) / (itemSize.width + spacing.column)); | ||
} | ||
if (itemSize[width] < sizeWidth) { | ||
countColumn += Math.floor((sizeWidth - itemSize[width]) / (itemSize[width] + spacing[column])); | ||
} | ||
} | ||
} | ||
if (columnCount > 0) { | ||
rowCount = Math.ceil(itemCount / columnCount); | ||
} | ||
if (countColumn > 0) { | ||
countRow = Math.ceil(itemCount / countColumn); | ||
} | ||
if (rowCount > 0) { | ||
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { | ||
if (rowIndex > 0) { | ||
sizeHeight += spacing.row + itemSize.height; | ||
if (countRow > 0) { | ||
for (var rowIndex = 0; rowIndex < countRow; rowIndex++) { | ||
if (rowIndex > 0) { | ||
sizeHeight += spacing[row] + itemSize[height]; | ||
} | ||
for (var columnIndex = 0; columnIndex < countColumn; columnIndex++) { | ||
var itemIndex = columnIndex + rowIndex * countColumn; | ||
var attrX = 0; | ||
if (countColumn > 1) { | ||
attrX += Math.round(columnIndex * ((sizeWidth - itemSize[width]) / (countColumn - 1))); | ||
} | ||
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) { | ||
var itemIndex = columnIndex + rowIndex * columnCount; | ||
var x = 0; | ||
if (itemIndex < itemCount) { | ||
var _layoutAttrs$push; | ||
if (columnCount > 1) { | ||
x += Math.round(columnIndex * ((sizeWidth - itemSize.width) / (columnCount - 1))); | ||
} | ||
if (itemIndex < itemCount) { | ||
layoutAttrs.push({ | ||
x: x, | ||
y: sizeHeight, | ||
width: itemSize.width, | ||
height: itemSize.height, | ||
rowIndex: rowIndex, | ||
columnIndex: columnIndex, | ||
itemIndex: itemIndex | ||
}); | ||
} | ||
layoutAttrs.push((_layoutAttrs$push = {}, _layoutAttrs$push[x] = attrX, _layoutAttrs$push[y] = sizeHeight, _layoutAttrs$push[width] = itemSize[width], _layoutAttrs$push[height] = itemSize[height], _layoutAttrs$push[row + 'Index'] = rowIndex, _layoutAttrs$push[column + 'Index'] = columnIndex, _layoutAttrs$push.itemIndex = itemIndex, _layoutAttrs$push)); | ||
} | ||
} | ||
sizeHeight += itemSize.height; | ||
} | ||
return { | ||
count: { | ||
row: rowCount, | ||
column: columnCount | ||
}, | ||
size: { | ||
width: sizeWidth, | ||
height: sizeHeight | ||
}, | ||
layoutAttrs: layoutAttrs | ||
}; | ||
sizeHeight += itemSize[height]; | ||
} | ||
if (direction === 'vertical') { | ||
return calculateLayout(itemSize, itemCount, spacing, size); | ||
} else if (direction === 'horizontal') { | ||
var layout = calculateLayout({ | ||
width: itemSize.height, | ||
height: itemSize.width | ||
}, itemCount, { | ||
row: spacing.column, | ||
column: spacing.row | ||
}, { | ||
width: size.height, | ||
height: size.width | ||
}); | ||
return { | ||
size: { | ||
width: layout.size.height, | ||
height: layout.size.width | ||
}, | ||
count: { | ||
row: layout.count.column, | ||
column: layout.count.row | ||
}, | ||
layoutAttrs: layout.layoutAttrs.map(function (attrs) { | ||
return { | ||
x: attrs.y, | ||
y: attrs.x, | ||
width: attrs.height, | ||
height: attrs.width, | ||
rowIndex: attrs.columnIndex, | ||
columnIndex: attrs.rowIndex, | ||
itemIndex: attrs.itemIndex | ||
}; | ||
}) | ||
}; | ||
} | ||
return { | ||
count: (_count = {}, _count[row] = countRow, _count[column] = countColumn, _count), | ||
size: (_size = {}, _size[width] = sizeWidth, _size[height] = sizeHeight, _size), | ||
layoutAttrs: layoutAttrs | ||
}; | ||
} |
@@ -25,3 +25,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
itemHashList: [], | ||
itemHashDict: {} | ||
itemSizeDict: {} | ||
}; | ||
@@ -67,7 +67,7 @@ return _this; | ||
var itemHashList = state.itemHashList, | ||
itemHashDict = state.itemHashDict; | ||
itemSizeDict = state.itemSizeDict; | ||
var nextState = calculateLayout({ | ||
width: estimatedItemWidth, | ||
height: estimatedItemHeight | ||
}, itemHashList, itemHashDict, itemCount, spacing, { | ||
}, itemHashList, itemSizeDict, itemCount, spacing, { | ||
width: width, | ||
@@ -149,8 +149,15 @@ height: height | ||
function needsRender() {} | ||
function needsRender(rect, vRect, name) { | ||
if (name) { | ||
var _ref = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref[0], | ||
width = _ref[1]; | ||
function calculateLayout(itemSize, itemHashList, itemHashDict, itemCount, spacing, size, direction) { | ||
if (!direction) {} else if (direction === 'vertical') { | ||
return calculateLayout(itemSize, itemHashList, itemHashDict, itemCount, spacing, size); | ||
} else if (direction === 'horizontal') {} | ||
} | ||
var dx = rect[x] - vRect[x]; | ||
return -0.25 * vRect[width] < dx + rect[width] && dx < 1.25 * vRect[width]; | ||
} | ||
return needsRender(rect, vRect, 'x') && needsRender(rect, vRect, 'y'); | ||
} | ||
function calculateLayout(itemSize, itemHashList, itemSizeDict, itemCount, spacing, size, direction) {} |
export function getAdjustedContentOffset(offset, size, cSize, name) { | ||
if (name) { | ||
return Math.max(Math.min(size - cSize, 0), Math.min(offset, 0)); | ||
var _ref = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref[0], | ||
width = _ref[1]; | ||
return Math.max(Math.min(size[width] - cSize[width], 0), Math.min(offset[x], 0)); | ||
} | ||
return { | ||
x: getAdjustedContentOffset(offset.x, size.width, cSize.width, 'x'), | ||
y: getAdjustedContentOffset(offset.y, size.height, cSize.height, 'y') | ||
x: getAdjustedContentOffset(offset, size, cSize, 'x'), | ||
y: getAdjustedContentOffset(offset, size, cSize, 'y') | ||
}; | ||
@@ -13,14 +17,18 @@ } | ||
if (name) { | ||
return size ? size * Math.round(offset / size) : 0; | ||
var _ref2 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref2[0], | ||
width = _ref2[1]; | ||
return size[width] ? size[width] * Math.round(offset[x] / size[width]) : 0; | ||
} | ||
return { | ||
x: getAdjustedPagingOffset(offset.x, size.width, 'x'), | ||
y: getAdjustedPagingOffset(offset.y, size.height, 'y') | ||
x: getAdjustedPagingOffset(offset, size, 'x'), | ||
y: getAdjustedPagingOffset(offset, size, 'y') | ||
}; | ||
} | ||
function getAcc(rate, _ref) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
function getAcc(rate, _ref3) { | ||
var x = _ref3.x, | ||
y = _ref3.y; | ||
var r = Math.sqrt(x * x + y * y); | ||
@@ -35,14 +43,21 @@ return { | ||
if (name) { | ||
if (!acc) { | ||
var _ref4 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref4[0], | ||
width = _ref4[1]; | ||
if (!acc[x]) { | ||
return 0; | ||
} | ||
var direction = acc < 0 ? -1 : 1; | ||
return direction * Math.min(Math.abs(velocity), Math.sqrt(direction * acc * size)); | ||
var direction = acc[x] < 0 ? -1 : 1; | ||
return direction * Math.min(Math.abs(velocity[x]), Math.sqrt(direction * acc[x] * size[width])); | ||
} | ||
acc = getAcc(acc, velocity); | ||
if (typeof acc === 'number') { | ||
acc = getAcc(acc, velocity); | ||
} | ||
return { | ||
x: getAdjustedPagingVelocity(velocity.x, size.width, acc.x, 'x'), | ||
y: getAdjustedPagingVelocity(velocity.y, size.height, acc.y, 'y') | ||
x: getAdjustedPagingVelocity(velocity, size, acc, 'x'), | ||
y: getAdjustedPagingVelocity(velocity, size, acc, 'y') | ||
}; | ||
@@ -52,13 +67,18 @@ } | ||
if (name) { | ||
if (!acc) { | ||
return offset; | ||
var x = name; | ||
if (!acc[x]) { | ||
return offset[x]; | ||
} | ||
return offset + 0.5 * velocity * (velocity / acc); | ||
return offset[x] + 0.5 * velocity[x] * (velocity[x] / acc[x]); | ||
} | ||
acc = getAcc(acc, velocity); | ||
if (typeof acc === 'number') { | ||
acc = getAcc(acc, velocity); | ||
} | ||
return { | ||
x: getDecelerationEndOffset(offset.x, velocity.x, acc.x, 'x'), | ||
y: getDecelerationEndOffset(offset.y, velocity.y, acc.y, 'y') | ||
x: getDecelerationEndOffset(offset, velocity, acc, 'x'), | ||
y: getDecelerationEndOffset(offset, velocity, acc, 'y') | ||
}; | ||
@@ -68,5 +88,7 @@ } | ||
if (name) { | ||
if (!acc) { | ||
var x = name; | ||
if (!acc[x]) { | ||
return { | ||
offset: offsetEnd, | ||
offset: offsetEnd[x], | ||
velocity: 0 | ||
@@ -76,11 +98,11 @@ }; | ||
var dist = offsetEnd - offset; | ||
var direction = acc < 0 ? -1 : 1; | ||
var velocityH = direction * Math.sqrt(0.5 * velocity * velocity + acc * dist); | ||
var timeH = acc ? (velocityH - velocity) / acc : 0; | ||
var time = acc ? (2 * velocityH - velocity) / acc : 0; | ||
var dist = offsetEnd[x] - offset[x]; | ||
var direction = acc[x] < 0 ? -1 : 1; | ||
var velocityH = direction * Math.sqrt(0.5 * velocity[x] * velocity[x] + acc[x] * dist); | ||
var timeH = acc[x] ? (velocityH - velocity[x]) / acc[x] : 0; | ||
var time = acc[x] ? (2 * velocityH - velocity[x]) / acc[x] : 0; | ||
if (time < interval) { | ||
return { | ||
offset: offsetEnd, | ||
offset: offsetEnd[x], | ||
velocity: 0 | ||
@@ -91,13 +113,16 @@ }; | ||
return { | ||
offset: offset + 0.5 * (velocity + velocityH) * timeH - 0.5 * (2 * velocityH - acc * Math.abs(timeH - interval)) * (timeH - interval), | ||
velocity: velocityH - acc * Math.abs(timeH - interval) | ||
offset: offset[x] + 0.5 * (velocity[x] + velocityH) * timeH - 0.5 * (2 * velocityH - acc[x] * Math.abs(timeH - interval)) * (timeH - interval), | ||
velocity: velocityH - acc[x] * Math.abs(timeH - interval) | ||
}; | ||
} | ||
acc = getAcc(acc, { | ||
x: offsetEnd.x - offset.x, | ||
y: offsetEnd.y - offset.y | ||
}); | ||
var nextX = calculateDeceleration(interval, acc.x, offset.x, velocity.x, offsetEnd.x, 'x'); | ||
var nextY = calculateDeceleration(interval, acc.y, offset.y, velocity.y, offsetEnd.y, 'y'); | ||
if (typeof acc === 'number') { | ||
acc = getAcc(acc, { | ||
x: offsetEnd.x - offset.x, | ||
y: offsetEnd.y - offset.y | ||
}); | ||
} | ||
var nextX = calculateDeceleration(interval, acc, offset, velocity, offsetEnd, 'x'); | ||
var nextY = calculateDeceleration(interval, acc, offset, velocity, offsetEnd, 'y'); | ||
return { | ||
@@ -116,21 +141,25 @@ offset: { | ||
if (name) { | ||
var _ref5 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref5[0], | ||
width = _ref5[1]; | ||
var nOffset; | ||
if (align === 'auto') { | ||
var direction = size < rSize ? -1 : 1; | ||
nOffset = -rOrigin + direction * Math.max(0, Math.min(direction * (rOrigin + offset), direction * (size - rSize))); | ||
if (align[x] === 'auto') { | ||
var direction = size[width] < rSize[width] ? -1 : 1; | ||
nOffset = -rOrigin[x] + direction * Math.max(0, Math.min(direction * (rOrigin[x] + offset[x]), direction * (size[width] - rSize[width]))); | ||
} else { | ||
if (align === 'start') { | ||
align = 0; | ||
} else if (align === 'center') { | ||
align = 0.5; | ||
} else if (align === 'end') { | ||
align = 1; | ||
if (align[x] === 'start') { | ||
align[x] = 0; | ||
} else if (align[x] === 'center') { | ||
align[x] = 0.5; | ||
} else if (align[x] === 'end') { | ||
align[x] = 1; | ||
} | ||
if (typeof align !== 'number' || isNaN(align)) { | ||
align = 0.5; | ||
if (typeof align[x] !== 'number' || isNaN(align[x])) { | ||
align[x] = 0.5; | ||
} | ||
nOffset = -rOrigin + align * (size - rSize); | ||
nOffset = -rOrigin[x] + align[x] * (size[width] - rSize[width]); | ||
} | ||
@@ -149,5 +178,5 @@ | ||
return { | ||
x: calculateRectOffset(rOrigin.x, rSize.width, align.x, offset.x, size.width, 'x'), | ||
y: calculateRectOffset(rOrigin.y, rSize.height, align.y, offset.y, size.height, 'y') | ||
x: calculateRectOffset(rOrigin, rSize, align, offset, size, 'x'), | ||
y: calculateRectOffset(rOrigin, rSize, align, offset, size, 'y') | ||
}; | ||
} |
@@ -196,148 +196,92 @@ "use strict"; | ||
if (name) { | ||
var dx = rect.x - vRect.x; | ||
return -0.25 * vRect.width < dx + rect.width && dx < 1.25 * vRect.width; | ||
var _ref2 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref2[0], | ||
width = _ref2[1]; | ||
var dx = rect[x] - vRect[x]; | ||
return -0.25 * vRect[width] < dx + rect[width] && dx < 1.25 * vRect[width]; | ||
} | ||
return needsRender(rect, vRect, 'x') && needsRender({ | ||
x: rect.y, | ||
y: rect.x, | ||
width: rect.height, | ||
height: rect.width | ||
}, { | ||
x: vRect.y, | ||
y: vRect.x, | ||
width: vRect.height, | ||
height: vRect.width | ||
}, 'y'); | ||
return needsRender(rect, vRect, 'x') && needsRender(rect, vRect, 'y'); | ||
} | ||
function calculateItemIndex(index, count, direction) { | ||
if (!direction) { | ||
return index.column + index.row * count.column; | ||
} | ||
var _ref3 = direction === 'horizontal' ? ['column', 'row'] : ['row', 'column'], | ||
row = _ref3[0], | ||
column = _ref3[1]; | ||
if (direction === 'vertical') { | ||
return calculateItemIndex(index, count); | ||
} else if (direction === 'horizontal') { | ||
return calculateItemIndex({ | ||
row: index.column, | ||
column: index.row | ||
}, { | ||
row: count.column, | ||
column: count.row | ||
}); | ||
} | ||
return index[column] + index[row] * count[column]; | ||
} | ||
function calculateLayout(itemSize, itemCount, spacing, size, direction) { | ||
if (!direction) { | ||
var sizeWidth = size.width; | ||
var sizeHeight = 0; | ||
var columnCount = 0; | ||
var rowCount = 0; | ||
var layoutAttrs = []; | ||
var _count, _size; | ||
if (sizeWidth < 0) { | ||
sizeWidth = itemCount * itemSize.width; | ||
var _ref4 = direction === 'horizontal' ? ['y', 'x', 'height', 'width', 'column', 'row'] : ['x', 'y', 'width', 'height', 'row', 'column'], | ||
x = _ref4[0], | ||
y = _ref4[1], | ||
width = _ref4[2], | ||
height = _ref4[3], | ||
row = _ref4[4], | ||
column = _ref4[5]; | ||
if (itemCount > 1) { | ||
sizeWidth += (itemCount - 1) * spacing.column; | ||
} | ||
var sizeWidth = size[width]; | ||
var sizeHeight = 0; | ||
var countRow = 0; | ||
var countColumn = 0; | ||
var layoutAttrs = []; | ||
columnCount = itemCount; | ||
if (sizeWidth < 0) { | ||
sizeWidth = itemCount * itemSize[width]; | ||
if (itemCount > 1) { | ||
sizeWidth += (itemCount - 1) * spacing[column]; | ||
} | ||
countColumn = itemCount; | ||
} else { | ||
if (itemSize[width] === 0 && spacing[column] === 0) { | ||
countColumn = itemCount; | ||
} else { | ||
if (itemSize.width === 0 && spacing.column === 0) { | ||
columnCount = itemCount; | ||
} else { | ||
columnCount = 1; | ||
countColumn = 1; | ||
if (itemSize.width < sizeWidth) { | ||
columnCount += Math.floor((sizeWidth - itemSize.width) / (itemSize.width + spacing.column)); | ||
} | ||
if (itemSize[width] < sizeWidth) { | ||
countColumn += Math.floor((sizeWidth - itemSize[width]) / (itemSize[width] + spacing[column])); | ||
} | ||
} | ||
} | ||
if (columnCount > 0) { | ||
rowCount = Math.ceil(itemCount / columnCount); | ||
} | ||
if (countColumn > 0) { | ||
countRow = Math.ceil(itemCount / countColumn); | ||
} | ||
if (rowCount > 0) { | ||
for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { | ||
if (rowIndex > 0) { | ||
sizeHeight += spacing.row + itemSize.height; | ||
if (countRow > 0) { | ||
for (var rowIndex = 0; rowIndex < countRow; rowIndex++) { | ||
if (rowIndex > 0) { | ||
sizeHeight += spacing[row] + itemSize[height]; | ||
} | ||
for (var columnIndex = 0; columnIndex < countColumn; columnIndex++) { | ||
var itemIndex = columnIndex + rowIndex * countColumn; | ||
var attrX = 0; | ||
if (countColumn > 1) { | ||
attrX += Math.round(columnIndex * ((sizeWidth - itemSize[width]) / (countColumn - 1))); | ||
} | ||
for (var columnIndex = 0; columnIndex < columnCount; columnIndex++) { | ||
var itemIndex = columnIndex + rowIndex * columnCount; | ||
var x = 0; | ||
if (itemIndex < itemCount) { | ||
var _layoutAttrs$push; | ||
if (columnCount > 1) { | ||
x += Math.round(columnIndex * ((sizeWidth - itemSize.width) / (columnCount - 1))); | ||
} | ||
if (itemIndex < itemCount) { | ||
layoutAttrs.push({ | ||
x: x, | ||
y: sizeHeight, | ||
width: itemSize.width, | ||
height: itemSize.height, | ||
rowIndex: rowIndex, | ||
columnIndex: columnIndex, | ||
itemIndex: itemIndex | ||
}); | ||
} | ||
layoutAttrs.push((_layoutAttrs$push = {}, _layoutAttrs$push[x] = attrX, _layoutAttrs$push[y] = sizeHeight, _layoutAttrs$push[width] = itemSize[width], _layoutAttrs$push[height] = itemSize[height], _layoutAttrs$push[row + 'Index'] = rowIndex, _layoutAttrs$push[column + 'Index'] = columnIndex, _layoutAttrs$push.itemIndex = itemIndex, _layoutAttrs$push)); | ||
} | ||
} | ||
sizeHeight += itemSize.height; | ||
} | ||
return { | ||
count: { | ||
row: rowCount, | ||
column: columnCount | ||
}, | ||
size: { | ||
width: sizeWidth, | ||
height: sizeHeight | ||
}, | ||
layoutAttrs: layoutAttrs | ||
}; | ||
sizeHeight += itemSize[height]; | ||
} | ||
if (direction === 'vertical') { | ||
return calculateLayout(itemSize, itemCount, spacing, size); | ||
} else if (direction === 'horizontal') { | ||
var layout = calculateLayout({ | ||
width: itemSize.height, | ||
height: itemSize.width | ||
}, itemCount, { | ||
row: spacing.column, | ||
column: spacing.row | ||
}, { | ||
width: size.height, | ||
height: size.width | ||
}); | ||
return { | ||
size: { | ||
width: layout.size.height, | ||
height: layout.size.width | ||
}, | ||
count: { | ||
row: layout.count.column, | ||
column: layout.count.row | ||
}, | ||
layoutAttrs: layout.layoutAttrs.map(function (attrs) { | ||
return { | ||
x: attrs.y, | ||
y: attrs.x, | ||
width: attrs.height, | ||
height: attrs.width, | ||
rowIndex: attrs.columnIndex, | ||
columnIndex: attrs.rowIndex, | ||
itemIndex: attrs.itemIndex | ||
}; | ||
}) | ||
}; | ||
} | ||
return { | ||
count: (_count = {}, _count[row] = countRow, _count[column] = countColumn, _count), | ||
size: (_size = {}, _size[width] = sizeWidth, _size[height] = sizeHeight, _size), | ||
layoutAttrs: layoutAttrs | ||
}; | ||
} |
@@ -34,3 +34,3 @@ "use strict"; | ||
itemHashList: [], | ||
itemHashDict: {} | ||
itemSizeDict: {} | ||
}; | ||
@@ -76,7 +76,7 @@ return _this; | ||
var itemHashList = state.itemHashList, | ||
itemHashDict = state.itemHashDict; | ||
itemSizeDict = state.itemSizeDict; | ||
var nextState = calculateLayout({ | ||
width: estimatedItemWidth, | ||
height: estimatedItemHeight | ||
}, itemHashList, itemHashDict, itemCount, spacing, { | ||
}, itemHashList, itemSizeDict, itemCount, spacing, { | ||
width: width, | ||
@@ -156,8 +156,15 @@ height: height | ||
function needsRender() {} | ||
function needsRender(rect, vRect, name) { | ||
if (name) { | ||
var _ref = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref[0], | ||
width = _ref[1]; | ||
function calculateLayout(itemSize, itemHashList, itemHashDict, itemCount, spacing, size, direction) { | ||
if (!direction) {} else if (direction === 'vertical') { | ||
return calculateLayout(itemSize, itemHashList, itemHashDict, itemCount, spacing, size); | ||
} else if (direction === 'horizontal') {} | ||
} | ||
var dx = rect[x] - vRect[x]; | ||
return -0.25 * vRect[width] < dx + rect[width] && dx < 1.25 * vRect[width]; | ||
} | ||
return needsRender(rect, vRect, 'x') && needsRender(rect, vRect, 'y'); | ||
} | ||
function calculateLayout(itemSize, itemHashList, itemSizeDict, itemCount, spacing, size, direction) {} |
@@ -13,8 +13,12 @@ "use strict"; | ||
if (name) { | ||
return Math.max(Math.min(size - cSize, 0), Math.min(offset, 0)); | ||
var _ref = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref[0], | ||
width = _ref[1]; | ||
return Math.max(Math.min(size[width] - cSize[width], 0), Math.min(offset[x], 0)); | ||
} | ||
return { | ||
x: getAdjustedContentOffset(offset.x, size.width, cSize.width, 'x'), | ||
y: getAdjustedContentOffset(offset.y, size.height, cSize.height, 'y') | ||
x: getAdjustedContentOffset(offset, size, cSize, 'x'), | ||
y: getAdjustedContentOffset(offset, size, cSize, 'y') | ||
}; | ||
@@ -25,14 +29,18 @@ } | ||
if (name) { | ||
return size ? size * Math.round(offset / size) : 0; | ||
var _ref2 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref2[0], | ||
width = _ref2[1]; | ||
return size[width] ? size[width] * Math.round(offset[x] / size[width]) : 0; | ||
} | ||
return { | ||
x: getAdjustedPagingOffset(offset.x, size.width, 'x'), | ||
y: getAdjustedPagingOffset(offset.y, size.height, 'y') | ||
x: getAdjustedPagingOffset(offset, size, 'x'), | ||
y: getAdjustedPagingOffset(offset, size, 'y') | ||
}; | ||
} | ||
function getAcc(rate, _ref) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
function getAcc(rate, _ref3) { | ||
var x = _ref3.x, | ||
y = _ref3.y; | ||
var r = Math.sqrt(x * x + y * y); | ||
@@ -47,14 +55,21 @@ return { | ||
if (name) { | ||
if (!acc) { | ||
var _ref4 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref4[0], | ||
width = _ref4[1]; | ||
if (!acc[x]) { | ||
return 0; | ||
} | ||
var direction = acc < 0 ? -1 : 1; | ||
return direction * Math.min(Math.abs(velocity), Math.sqrt(direction * acc * size)); | ||
var direction = acc[x] < 0 ? -1 : 1; | ||
return direction * Math.min(Math.abs(velocity[x]), Math.sqrt(direction * acc[x] * size[width])); | ||
} | ||
acc = getAcc(acc, velocity); | ||
if (typeof acc === 'number') { | ||
acc = getAcc(acc, velocity); | ||
} | ||
return { | ||
x: getAdjustedPagingVelocity(velocity.x, size.width, acc.x, 'x'), | ||
y: getAdjustedPagingVelocity(velocity.y, size.height, acc.y, 'y') | ||
x: getAdjustedPagingVelocity(velocity, size, acc, 'x'), | ||
y: getAdjustedPagingVelocity(velocity, size, acc, 'y') | ||
}; | ||
@@ -65,13 +80,18 @@ } | ||
if (name) { | ||
if (!acc) { | ||
return offset; | ||
var x = name; | ||
if (!acc[x]) { | ||
return offset[x]; | ||
} | ||
return offset + 0.5 * velocity * (velocity / acc); | ||
return offset[x] + 0.5 * velocity[x] * (velocity[x] / acc[x]); | ||
} | ||
acc = getAcc(acc, velocity); | ||
if (typeof acc === 'number') { | ||
acc = getAcc(acc, velocity); | ||
} | ||
return { | ||
x: getDecelerationEndOffset(offset.x, velocity.x, acc.x, 'x'), | ||
y: getDecelerationEndOffset(offset.y, velocity.y, acc.y, 'y') | ||
x: getDecelerationEndOffset(offset, velocity, acc, 'x'), | ||
y: getDecelerationEndOffset(offset, velocity, acc, 'y') | ||
}; | ||
@@ -82,5 +102,7 @@ } | ||
if (name) { | ||
if (!acc) { | ||
var x = name; | ||
if (!acc[x]) { | ||
return { | ||
offset: offsetEnd, | ||
offset: offsetEnd[x], | ||
velocity: 0 | ||
@@ -90,11 +112,11 @@ }; | ||
var dist = offsetEnd - offset; | ||
var direction = acc < 0 ? -1 : 1; | ||
var velocityH = direction * Math.sqrt(0.5 * velocity * velocity + acc * dist); | ||
var timeH = acc ? (velocityH - velocity) / acc : 0; | ||
var time = acc ? (2 * velocityH - velocity) / acc : 0; | ||
var dist = offsetEnd[x] - offset[x]; | ||
var direction = acc[x] < 0 ? -1 : 1; | ||
var velocityH = direction * Math.sqrt(0.5 * velocity[x] * velocity[x] + acc[x] * dist); | ||
var timeH = acc[x] ? (velocityH - velocity[x]) / acc[x] : 0; | ||
var time = acc[x] ? (2 * velocityH - velocity[x]) / acc[x] : 0; | ||
if (time < interval) { | ||
return { | ||
offset: offsetEnd, | ||
offset: offsetEnd[x], | ||
velocity: 0 | ||
@@ -105,13 +127,16 @@ }; | ||
return { | ||
offset: offset + 0.5 * (velocity + velocityH) * timeH - 0.5 * (2 * velocityH - acc * Math.abs(timeH - interval)) * (timeH - interval), | ||
velocity: velocityH - acc * Math.abs(timeH - interval) | ||
offset: offset[x] + 0.5 * (velocity[x] + velocityH) * timeH - 0.5 * (2 * velocityH - acc[x] * Math.abs(timeH - interval)) * (timeH - interval), | ||
velocity: velocityH - acc[x] * Math.abs(timeH - interval) | ||
}; | ||
} | ||
acc = getAcc(acc, { | ||
x: offsetEnd.x - offset.x, | ||
y: offsetEnd.y - offset.y | ||
}); | ||
var nextX = calculateDeceleration(interval, acc.x, offset.x, velocity.x, offsetEnd.x, 'x'); | ||
var nextY = calculateDeceleration(interval, acc.y, offset.y, velocity.y, offsetEnd.y, 'y'); | ||
if (typeof acc === 'number') { | ||
acc = getAcc(acc, { | ||
x: offsetEnd.x - offset.x, | ||
y: offsetEnd.y - offset.y | ||
}); | ||
} | ||
var nextX = calculateDeceleration(interval, acc, offset, velocity, offsetEnd, 'x'); | ||
var nextY = calculateDeceleration(interval, acc, offset, velocity, offsetEnd, 'y'); | ||
return { | ||
@@ -131,21 +156,25 @@ offset: { | ||
if (name) { | ||
var _ref5 = name === 'y' ? ['y', 'height'] : ['x', 'width'], | ||
x = _ref5[0], | ||
width = _ref5[1]; | ||
var nOffset; | ||
if (align === 'auto') { | ||
var direction = size < rSize ? -1 : 1; | ||
nOffset = -rOrigin + direction * Math.max(0, Math.min(direction * (rOrigin + offset), direction * (size - rSize))); | ||
if (align[x] === 'auto') { | ||
var direction = size[width] < rSize[width] ? -1 : 1; | ||
nOffset = -rOrigin[x] + direction * Math.max(0, Math.min(direction * (rOrigin[x] + offset[x]), direction * (size[width] - rSize[width]))); | ||
} else { | ||
if (align === 'start') { | ||
align = 0; | ||
} else if (align === 'center') { | ||
align = 0.5; | ||
} else if (align === 'end') { | ||
align = 1; | ||
if (align[x] === 'start') { | ||
align[x] = 0; | ||
} else if (align[x] === 'center') { | ||
align[x] = 0.5; | ||
} else if (align[x] === 'end') { | ||
align[x] = 1; | ||
} | ||
if (typeof align !== 'number' || isNaN(align)) { | ||
align = 0.5; | ||
if (typeof align[x] !== 'number' || isNaN(align[x])) { | ||
align[x] = 0.5; | ||
} | ||
nOffset = -rOrigin + align * (size - rSize); | ||
nOffset = -rOrigin[x] + align[x] * (size[width] - rSize[width]); | ||
} | ||
@@ -164,5 +193,5 @@ | ||
return { | ||
x: calculateRectOffset(rOrigin.x, rSize.width, align.x, offset.x, size.width, 'x'), | ||
y: calculateRectOffset(rOrigin.y, rSize.height, align.y, offset.y, size.height, 'y') | ||
x: calculateRectOffset(rOrigin, rSize, align, offset, size, 'x'), | ||
y: calculateRectOffset(rOrigin, rSize, align, offset, size, 'y') | ||
}; | ||
} |
{ | ||
"name": "react-pannable", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
250378
5746