Interactive interface for browsing global, full-resolution satellite imagery
simplify data line position with boolean, improve weird background stripe rendering issue on edges, cleanup
Ed Plato4925ed1522f2
diff --git a/web/js/components/timeline/timeline-data/layer-data-items.js b/web/js/components/timeline/timeline-data/layer-data-items.jsindex 9e7df3b8d..5051e9703 100644--- a/web/js/components/timeline/timeline-data/layer-data-items.js+++ b/web/js/components/timeline/timeline-data/layer-data-items.js@@ -148,7 +148,14 @@ class LayerDataItems extends Component {position,transformX,} = this.props;- const width = Math.max(options.width, 0);+ const {+ borderRadius,+ leftOffset,+ isWidthGreaterThanRendered,+ width,+ } = options;+ const lineWidth = Math.max(width, 0);+// get formatted dates based on line typeconst {dateRangeStart,@@ -156,8 +163,9 @@ class LayerDataItems extends Component {toolTipText,} = this.getFormattedDisplayDates(lineType, startDate, endDate, layerPeriod);const dateRangeStartEnd = `${id}-${dateRangeStart}-${dateRangeEnd}`;+// handle tooltip positioning- const toolTipOffset = -options.leftOffset - (width < axisWidth ? options.leftOffset : axisWidth / 2);+ const toolTipOffset = -leftOffset - (lineWidth < axisWidth ? leftOffset : axisWidth / 2);const toolTipPlacement = 'auto';// candy stripe color@@ -169,7 +177,11 @@ class LayerDataItems extends Component {${color} 20px,${altLineColor} 20px,${altLineColor} 40px)`;- const bgPosition = `${options.leftOffset + width + position + transformX}px 0`;+ const backgroundPositionCalculated = `${leftOffset + lineWidth + position + transformX}px 0`;+ const backgroundPosition = !isWidthGreaterThanRendered+ || (leftOffset !== 0 && isWidthGreaterThanRendered)+ ? 0+ : backgroundPositionCalculated;return (<div@@ -182,11 +194,11 @@ class LayerDataItems extends Component {onMouseEnter={() => hoverOnToolTip(`${dateRangeStartEnd}`)}onMouseLeave={() => hoverOffToolTip()}style={{- transform: `translate(${options.leftOffset}px, 0)`,- width: `${width}px`,- borderRadius: options.borderRadius,+ transform: `translate(${leftOffset}px, 0)`,+ width: `${lineWidth}px`,+ borderRadius,background: stripeBackground,- backgroundPosition: width < axisWidth ? 0 : bgPosition,+ backgroundPosition,}}><Tooltipdiff --git a/web/js/components/timeline/timeline-data/timeline-data.js b/web/js/components/timeline/timeline-data/timeline-data.jsindex 296a6d421..30af1d44f 100644--- a/web/js/components/timeline/timeline-data/timeline-data.js+++ b/web/js/components/timeline/timeline-data/timeline-data.js@@ -88,7 +88,7 @@ class TimelineData extends Component {* @param {Object} layer* @param {String} rangeStart* @param {String} rangeEnd- * @returns {Object} visible, leftOffset, width, borderRadius+ * @returns {Object} visible, leftOffset, width, borderRadius, isWidthGreaterThanRendered*/getMatchingCoverageLineDimensions = (layer, rangeStart, rangeEnd) => {const {@@ -150,6 +150,7 @@ class TimelineData extends Component {}}+ const isWidthGreaterThanRendered = layerStart < axisFrontDate || layerEnd > axisBackDate;const borderRadius = `${borderRadiusLeft} ${borderRadiusRight} ${borderRadiusRight} ${borderRadiusLeft}`;return {@@ -157,6 +158,7 @@ class TimelineData extends Component {leftOffset,width,borderRadius,+ isWidthGreaterThanRendered,};}