Interactive interface for browsing global, full-resolution satellite imagery
Align labels and running-bars
Benjamin King50045c5635ad
diff --git a/web/css/palettes.css b/web/css/palettes.cssindex af30c56ba..c728edf0e 100644--- a/web/css/palettes.css+++ b/web/css/palettes.css@@ -52,10 +52,15 @@.wv-running-category-label,.wv-running-label {font-size: 0.7em;- position: absolute;bottom: 0;width: auto;}+.wv-palettes-max,+.wv-palettes-min,+.wv-running-category-label,+.wv-running-label {+ position: absolute;+}.wv-palettes-max,.wv-palettes-min,@@ -117,7 +122,7 @@}.bank div .wv-palettes-panel .wv-running-bar {- bottom: 11px;+ bottom: 15px;width: 1px;height: 12px;background: #000;@@ -171,7 +176,7 @@width: 100%;height: 10px;border: 1px solid #404040;- margin-bottom: 15px;+ margin-bottom: 13px;}.bank .wv-palettes-colorbar:hover {diff --git a/web/js/map/runningdata.js b/web/js/map/runningdata.jsindex 358bc343a..72d17ec11 100644--- a/web/js/map/runningdata.js+++ b/web/js/map/runningdata.js@@ -95,14 +95,14 @@ export function MapRunningData(models) {* @return {number} margin-left value of label**/- self.getLabelMarginLeft = function (labelWidth, caseWidth, location) {- if (location + (labelWidth / 2) > caseWidth) {- return (caseWidth - labelWidth) - 5;- } else if (location - (labelWidth / 2) < 0) {- return 0;- } else {- return (location - ((labelWidth / 2) + 5));+ self.getLabelMarginLeft = function (labelWidth, caseWidth, location, marginLeft) {+ var offsetLeft = location + marginLeft - (labelWidth / 2);+ if (offsetLeft + labelWidth > caseWidth) {+ offsetLeft = caseWidth - labelWidth;+ } else if (offsetLeft < 5) {+ offsetLeft = 5;}+ return offsetLeft;};/*@@ -350,19 +350,13 @@ export function MapRunningData(models) {caseWidth = $categoryPaletteCase.width();$colorSquare = $categoryPaletteCase.find('[data-class-index=\'' + data.index + '\']');offset = $colorSquare.position();- console.log(offset);$paletteLabel = $categoryPaletteCase.find('.wv-running-category-label');$paletteLabel.text(data.label);labelWidth = util.getTextWidth(data.label, 'Lucida Sans');- offsetLeft = offset.left + (squareWidth / 2) + marginLeft - (labelWidth / 2);+ offsetLeft = offset.left + (squareWidth / 2);offsetTop = offset.top + squareWidth;- // Keep label inside parent element- if (offsetLeft < 5) {- offsetLeft = 5;- } else if ((offsetLeft + labelWidth) > caseWidth) {- offsetLeft = caseWidth - labelWidth;- }+ offsetLeft = self.getLabelMarginLeft(labelWidth, caseWidth, offsetLeft, marginLeft);$paletteLabel.attr('style', 'left:' + Math.round(offsetLeft) + 'px; top: ' + offsetTop + 'px');$categoryPaletteCase.addClass('wv-running');$categoryPaletteCase.find('.wv-active')@@ -395,8 +389,11 @@ export function MapRunningData(models) {var labelWidth;var percent;var labelMargin;- var location;+ var offsetLeft;var margin;+ var marginLeft;++ marginLeft = 3;$palette = self.getPalette(id);$paletteCase = $palette.parent();@@ -407,14 +404,14 @@ export function MapRunningData(models) {percent = self.getPercent(data.len, data.index, $paletteWidth);margin = (($paletteCaseWidth - $paletteWidth) / 2);- location = ($paletteWidth * percent + margin);+ offsetLeft = ($paletteWidth * percent + margin);$paletteLabel.text(data.label);labelWidth = util.getTextWidth(data.label, 'Lucida Sans');- labelMargin = self.getLabelMarginLeft(labelWidth, $paletteWidth, location);+ labelMargin = self.getLabelMarginLeft(labelWidth, $paletteCaseWidth, offsetLeft, marginLeft);$paletteLabel.attr('style', 'left:' + Math.round(labelMargin) + 'px;');- $paletteBar.attr('style', 'left:' + Math.round(location) + 'px;');+ $paletteBar.attr('style', 'left:' + Math.round(offsetLeft) + 'px;');$paletteCase.addClass('wv-running');};