From 7df1533d669b9c4828534c0732caa547668389f1 Mon Sep 17 00:00:00 2001 From: Dan Grebb Date: Wed, 17 Jan 2024 20:08:01 -0500 Subject: [PATCH] feat(compare): add `layoutSettings` state persistence (#1519) --- compare/output/index_bundle.js | 2 +- compare/src/store.js | 64 +++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/compare/output/index_bundle.js b/compare/output/index_bundle.js index 958a50403..61e4eb124 100644 --- a/compare/output/index_bundle.js +++ b/compare/output/index_bundle.js @@ -1,2 +1,2 @@ /*! For license information please see index_bundle.js.LICENSE.txt */ -(()=>{var e,t,n={184:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}t.Z=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=r(e)&&"function"!=typeof e)return{default:e};var n=i(t);if(n&&n.has(e))return n.get(e);var o={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if("default"!==l&&Object.prototype.hasOwnProperty.call(e,l)){var u=a?Object.getOwnPropertyDescriptor(e,l):null;u&&(u.get||u.set)?Object.defineProperty(o,l,u):o[l]=e[l]}return o.default=e,n&&n.set(e,o),o}(n(294));function i(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(i=function(e){return e?n:t})(e)}function a(e,t){for(var n=0;n=u)&&Math.abs(d)>l)return void this.endDrag();if(!t)return}var y=this.twentyTwentyComponent.current.getBoundingClientRect(),h=100*(o-y.left)/y.width;h=Math.max(Math.min(h,100),0),this.setState({position:h,isDragging:t})}}},{key:"beginDrag",value:function(e){if(e&&e.preventDefault(),this.props.isDraggingEnabled){var t="touches"in e?e.touches[0]:e,n=t.pageX,r=t.pageY;this.setState({startX:n,startY:r}),document.addEventListener("mousemove",this.onDragMove),document.addEventListener("mouseup",this.endDrag),document.addEventListener("touchmove",this.onDragMove),document.addEventListener("touchend",this.endDrag)}}},{key:"endDrag",value:function(){document.removeEventListener("mousemove",this.onDragMove),document.removeEventListener("mouseup",this.endDrag),document.removeEventListener("touchmove",this.onDragMove),document.removeEventListener("touchend",this.endDrag),this.setState({isDragging:!1,startY:NaN,endY:NaN})}},{key:"render",value:function(){var e=this.state.position,t=this.props,n=t.children,r=t.verticalAlign,i=t.leftHorizontalAlign,a=t.rightHorizontalAlign;return 2!==n.length&&3!==n.length?(console.warn("Expected exactly two or three children"),null):o.default.createElement("div",{ref:this.twentyTwentyComponent,style:{position:"relative",overflow:"hidden",whiteSpace:"nowrap"},onMouseDown:this.beginDrag,onTouchStart:this.beginDrag},o.default.createElement("div",{style:{position:"absolute",left:"".concat(e,"%"),height:"100%",width:0,zIndex:1}},n[2]),o.default.createElement("div",{style:{display:"inline-block",width:"100%",position:"relative",verticalAlign:r,left:"".concat(e-100,"%"),overflow:"hidden"}},o.default.createElement("div",{style:{position:"relative",right:"".concat(e-100,"%"),textAlign:i}},n[0])),o.default.createElement("div",{style:{display:"inline-block",width:"100%",position:"relative",verticalAlign:r,left:"".concat(e-100,"%"),overflow:"hidden"}},o.default.createElement("div",{style:{position:"relative",right:"".concat(e,"%"),textAlign:a}},n[1])))}}])&&a(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),d}(o.Component)).defaultProps={verticalAlign:"middle",leftHorizontalAlign:"center",rightHorizontalAlign:"center",minDistanceToBeginInteraction:15,maxAngleToBeginInteraction:30,initialPosition:50,isDraggingEnabled:!0}},875:(e,t,n)=>{var r;!function(){"use strict";var o=!("undefined"==typeof window||!window.document||!window.document.createElement),i={canUseDOM:o,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:o&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:o&&!!window.screen};void 0===(r=function(){return i}.call(t,n,t,e))||(e.exports=r)}()},75:function(e){(function(){var t,n,r,o,i,a;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-i)/1e6},n=process.hrtime,o=(t=function(){var e;return 1e9*(e=n())[0]+e[1]})(),a=1e9*process.uptime(),i=o-a):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)},703:(e,t,n)=>{"use strict";var r=n(414);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},697:(e,t,n)=>{e.exports=n(703)()},414:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},87:(e,t,n)=>{for(var r=n(75),o="undefined"==typeof window?n.g:window,i=["moz","webkit"],a="AnimationFrame",l=o["request"+a],u=o["cancel"+a]||o["cancelRequest"+a],c=0;!l&&c{"use strict";var r=n(294),o=n(840);function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n