Interactive interface for browsing global, full-resolution satellite imagery
Fix discrete palattes with multiple rows #1282
Benjamin Kingab07c2038ed5
diff --git a/web/css/palettes.css b/web/css/palettes.cssindex 581ac1085..0808dfa15 100644--- a/web/css/palettes.css+++ b/web/css/palettes.css@@ -60,7 +60,6 @@}.wv-palettes-max,.wv-palettes-min,-.wv-running-category-label,.wv-running-label {position: absolute;}@@ -121,10 +120,14 @@.sidebar-panel div .wv-palettes-panel .wv-running-category-label {bottom: 1px;- position: absolute;visibility: hidden;+ display: block;+}+.wv-running-category-label-case {+ min-height: 15px;+ margin: 3px 0 0;+ width: 100%;}-.wv-palettes-panel .wv-running-bar {top: 0;width: 1px;@@ -190,7 +193,7 @@width: 13px;display: inline-block;border: 1px solid #000;- margin: 0 2px 15px;+ margin: 0 2px;}.wv-running .wv-palettes-class {opacity: 0.25;diff --git a/web/js/components/sidebar/products/legend.js b/web/js/components/sidebar/products/legend.jsindex 97f407992..4276dede5 100644--- a/web/js/components/sidebar/products/legend.js+++ b/web/js/components/sidebar/products/legend.js@@ -166,16 +166,20 @@ class Legend extends React.Component {* @param {Number} textWidth | Label width* @param {Number} width | Case width*/- getClassLabelStyle(index, boxWidth, textWidth, width) {+ getClassLabelStyle(index, boxWidth, textWidth, width, rowEndIndex) {var halfTextWidth = textWidth / 2 || 0;- var xOffset = boxWidth * index + boxWidth / 2 || 0;+ var xOffset = boxWidth * (index - rowEndIndex) + boxWidth / 2 || 0;if (halfTextWidth > xOffset) {- return { left: '0', visibility: 'visible' };+ return { textAlign: 'left', visibility: 'visible' };} else if (xOffset + halfTextWidth > width) {- return { right: '0', visibility: 'visible' };+ return { textAlign: 'right', visibility: 'visible' };}- return { left: xOffset - halfTextWidth + 'px', visibility: 'visible' };+ return {+ marginLeft: xOffset - halfTextWidth + 'px',+ visibility: 'visible',+ textAlign: 'left'+ };}/*** @param {Number} xOffset | X px Location of running-data@@ -288,9 +292,13 @@ class Legend extends React.Component {const { isRunningData, colorHex } = this.state;const { width } = this.props;const boxWidth = 17; // width (13) + margin (4)+ const len = legend.colors.length;+ const maxInRow = Math.round((this.state.width - 8) / boxWidth);+ var rowEndIndex = 0;+ var isEndOfRow = false;var legendObj, textWidth;if (isRunningData && colorHex) {- legendObj = this.getLegendObject(legend, colorHex, 40); // {label,len,index}+ legendObj = this.getLegendObject(legend, colorHex, 5); // {label,len,index}if (legendObj) {textWidth = util.getTextWidth(legendObj.label, 'Lucida Sans');}@@ -305,6 +313,8 @@ class Legend extends React.Component {key={legend.id + '_' + index}>{legend.colors.map((color, index) => {+ rowEndIndex = isEndOfRow ? index : rowEndIndex;+ isEndOfRow = index === maxInRow - 1 || index === len - 1;return (<React.Fragment key={legend.id + '-color-' + index}><span@@ -319,39 +329,34 @@ class Legend extends React.Component {onMouseLeave={this.hideValue.bind(this)}dangerouslySetInnerHTML={{ __html: ' ' }}/>- {isRunningData && legendObj && index === legendObj.index ? (- <span- className="wv-running-category-label"- style={this.getClassLabelStyle(- index,- boxWidth,- textWidth,- width- )}- >- {legendObj.label}- </span>+ {isEndOfRow ? (+ <div className="wv-running-category-label-case">+ {isRunningData &&+ legendObj &&+ (legendObj.index >= rowEndIndex && // legend is in this row+ legendObj.index <= index) ? (+ <span+ className="wv-running-category-label"+ style={this.getClassLabelStyle(+ legendObj.index,+ boxWidth,+ textWidth,+ width,+ rowEndIndex+ )}+ >+ {legendObj ? legendObj.label : ''}+ </span>+ ) : (+ ''+ )}+ </div>) : ('')}</React.Fragment>);})}- <span- className="wv-running-category-label"- style={- legendObj && isRunningData- ? this.getClassLabelStyle(- legendObj.index,- boxWidth,- textWidth,- width- )- : {}- }- >- {legendObj ? legendObj.label : ''}- </span></div>);}