Interactive interface for browsing global, full-resolution satellite imagery
add today button, shift t shortcut keypress and about doc, styling changes to fit timeline header change
Ed Plato62fd4f4056d4
diff --git a/web/css/timeline.css b/web/css/timeline.cssindex 3fabac31e..d29746fc2 100644--- a/web/css/timeline.css+++ b/web/css/timeline.css@@ -179,19 +179,31 @@ button:focus {-ms-filter: 'FlipH';}+ & #now-button-group {+ width: 34px;+ height: 34px;+ top: 2px;+ & svg {+ top: 0;+ left: 3px;+ margin: 0;+ }+ }+& > .button-action-group:hover .arrow,- & #zoom-buttons-group .button-action-group:hover .arrow {+ & #zoom-buttons-group .button-action-group:hover .arrow,+ & #zoom-buttons-group .button-action-group:hover .circle {fill: #1a1a1a;fill-opacity: 1;stroke: none;}& > .button-action-group.button-disabled .arrow,& #zoom-buttons-group .button-disabled .arrow {- fill: #333;+ fill: #4d4d4d;}& > .button-action-group.button-disabled:hover .arrow,& #zoom-buttons-group .button-disabled:hover .arrow {- fill: #333;+ fill: #4d4d4d;}& #animate-button {@@ -201,11 +213,12 @@ button:focus {& .animate-button {position: absolute;- height: 40px;- width: 50px;- top: 11px;- right: 24px;- padding-left: 3px;+ height: 34px;+ width: 37px;+ top: 20px;+ right: 4px;+ padding-left: 4px;+ padding-top: 5px;}& .animate-button:hover svg.wv-animate path {fill: #1a1a1a;@@ -217,18 +230,17 @@ button:focus {& .animate-button.wv-disabled-button:hover {background-color: transparent;}- & .animate-button.wv-disabled-button:hover .wv-animate {- opacity: 0.5;- color: #fff;- }- & .animate-button.wv-disabled-button .wv-animate {- opacity: 0.5;+ & .animate-button.wv-disabled-button svg.wv-animate path {+ fill: #4d4d4d;pointer-events: none;}& .button-action-group svg path {fill: #fff;}+ & .button-action-group:hover svg path {+ fill: #000;+ }}.timeline-header-desktop {@@ -458,7 +470,7 @@ button:focus {position: absolute;bottom: 100%;border-bottom: 8px solid transparent;- width: 100px;+ width: 80px;z-index: 10;}@@ -484,7 +496,7 @@ button:focus {.zoom-btn-active,.interval-btn-active {- width: 100%;+ width: 80px;color: #ccc;font-size: 12px;line-height: 14px;@@ -733,3 +745,7 @@ button:focus {.datepicker-navbar-btn:hover {background: #fff;}++#timeline-header .button-action-group .now-btn-1:hover svg path {+ fill: #1a1a1a;+}diff --git a/web/js/components/about/about-page.js b/web/js/components/about/about-page.jsindex e7e9bffbe..f70df429e 100644--- a/web/js/components/about/about-page.js+++ b/web/js/components/about/about-page.js@@ -85,6 +85,16 @@ export default function AboutPage() {<td><code>→</code></td><td>Move forward one time interval</td></tr>+ <tr>+ <td>+ <code>Shift</code>+ {' '}+ ++ {' '}+ <code>T</code>+ </td>+ <td>Jump to today/now on the timeline</td>+ </tr><tr><td><code>Shift</code>diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex 6fdb97224..74c7e4406 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -141,7 +141,6 @@ class TimelineAxis extends Component {timelineEndDateLimit,} = this.props;const { wheelZoom } = this.state;-let draggerDate = draggerSelected === 'selected' ? draggerTimeState : draggerTimeStateB;// update timescale axis focus@@ -220,12 +219,12 @@ class TimelineAxis extends Component {* @desc main function to update axis scale, time range, grids tiles/text, dragger A/B positions, animation start/end draggers* @param {String} inputDate* @param {String} updatedTimeScale- * @param {Number} leftOffsetFixedCoeff+ * @param {Number} leftOffsetFixedCoefficient* @param {Boolean} hoverChange* @param {String} previousTimeScale - limited use for hover timeScale change* @returns {void}*/- updateScale = (inputDate, timeScale, leftOffsetFixedCoeff, hoverChange, previousTimeScale) => {+ updateScale = (inputDate, timeScale, leftOffsetFixedCoefficient, hoverChange, previousTimeScale) => {const {dateA,dateB,@@ -246,8 +245,8 @@ class TimelineAxis extends Component {const options = timeScaleOptions[timeScale].timeAxis;const { gridWidth } = options;const timelineAxisWidth = axisWidth;- const hoverLeftOffset = leftOffsetFixedCoeff- ? timelineAxisWidth * leftOffsetFixedCoeff+ const hoverLeftOffset = leftOffsetFixedCoefficient+ ? timelineAxisWidth * leftOffsetFixedCoefficient: leftOffset === 0? timelineAxisWidth * 0.8: leftOffset;@@ -255,8 +254,8 @@ class TimelineAxis extends Component {// visible tiles based on timeline axis width (screen/browser size dependent)const numberOfVisibleTiles = Number((timelineAxisWidth / gridWidth).toFixed(8));// grid overflow/cushion coefficient- const gridOverflowCoeff = 2.5;- let gridNumber = Math.floor(numberOfVisibleTiles * gridOverflowCoeff);+ const gridOverflowCoefficient = 2.5;+ let gridNumber = Math.floor(numberOfVisibleTiles * gridOverflowCoefficient);const dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);if (timeScale === 'year') {const endLimitYear = new Date(timelineEndDateLimit).getUTCFullYear() + 1;@@ -268,7 +267,7 @@ class TimelineAxis extends Component {gridNumber = monthTotal;}- // this is the middle on the axis based on number of tiles determined from width of axis and gridwidth+ // this is the middle on the axis based on number of tiles determined from width of axis and grid width// this is used to determine position and also to "reset" position after an axis drag has stopped// eslint-disable-next-line no-mixed-operatorsconst midPoint = numberOfVisibleTiles / 2 * gridWidth - gridWidth * gridNumber / 2;@@ -329,9 +328,9 @@ class TimelineAxis extends Component {const pixelsToAdd = diffStartAndZeroed / diffFactor;// offset grids needed since each zoom in won't be centered- const gridOffsetCoeff = 2.5;+ const gridOffsetCoefficient = 2.5;const offSetGrids = Math.floor(hoverLeftOffset / gridWidth);- const offSetHalved = Math.floor(Math.floor(numberOfVisibleTiles * gridOffsetCoeff) / 2);+ const offSetHalved = Math.floor(Math.floor(numberOfVisibleTiles * gridOffsetCoefficient) / 2);const offSetGridsDiff = offSetGrids - Math.floor(numberOfVisibleTiles / 2);let gridsToSubtract = offSetHalved + offSetGridsDiff;let gridsToAdd = offSetHalved - offSetGridsDiff;@@ -521,7 +520,7 @@ class TimelineAxis extends Component {* @param {Number} draggerPosition* @param {Number} draggerPositionB* @param {Number} overDrag- * @returns {Object} output - return new time range and dragger visibilty/updated position+ * @returns {Object} output - return new time range and dragger visibility/updated position* @returns {Array} output.currentTimeRange* @returns {Number} output.transformX* @returns {Boolean} output.draggerVisible@@ -545,25 +544,25 @@ class TimelineAxis extends Component {isCompareModeActive,draggerSelected,} = this.props;- // get updated visible tiles with overdrag+ // get updated visible tiles with over dragconst updatedNumberOfVisibleTiles = Math.floor(numberOfVisibleTiles * 0.25);const overDragGrids = Math.ceil(overDrag / gridWidth);- const numVisibleTilesWithOverdrag = updatedNumberOfVisibleTiles + 1 + overDragGrids;+ const numVisibleTilesWithOverDrag = updatedNumberOfVisibleTiles + 1 + overDragGrids;const newCurrentTimeRange = currentTimeRange;let timeRangeAdd;let transform;if (deltaX > 0) { // dragging right - exposing past datesconst firstDateInRange = newCurrentTimeRange[0].rawDate;- timeRangeAdd = this.getTimeRangeArray(numVisibleTilesWithOverdrag, -1, firstDateInRange);- removeBackMultipleInPlace(newCurrentTimeRange, numVisibleTilesWithOverdrag);+ timeRangeAdd = this.getTimeRangeArray(numVisibleTilesWithOverDrag, -1, firstDateInRange);+ removeBackMultipleInPlace(newCurrentTimeRange, numVisibleTilesWithOverDrag);newCurrentTimeRange.unshift(...timeRangeAdd);- transform = transformX - numVisibleTilesWithOverdrag * gridWidth;+ transform = transformX - numVisibleTilesWithOverDrag * gridWidth;} else { // dragging left - exposing future datesconst lastDateInRange = newCurrentTimeRange[newCurrentTimeRange.length - 1].rawDate;- timeRangeAdd = this.getTimeRangeArray(-1, numVisibleTilesWithOverdrag, lastDateInRange);- removeFrontMultipleInPlace(newCurrentTimeRange, numVisibleTilesWithOverdrag);+ timeRangeAdd = this.getTimeRangeArray(-1, numVisibleTilesWithOverDrag, lastDateInRange);+ removeFrontMultipleInPlace(newCurrentTimeRange, numVisibleTilesWithOverDrag);newCurrentTimeRange.push(...timeRangeAdd);- transform = transformX + numVisibleTilesWithOverdrag * gridWidth;+ transform = transformX + numVisibleTilesWithOverDrag * gridWidth;}// check if dragger is in between range and visible@@ -701,6 +700,7 @@ class TimelineAxis extends Component {*/checkDraggerMoveOrUpdateScale = (previousDate, isDraggerB) => {const {+ appNow,dateA,dateB,draggerPosition,@@ -734,7 +734,10 @@ class TimelineAxis extends Component {const rightEdgeOfVisibleAxis = axisWidth - 80;const isDraggerPositionWithinAxis = selectedDraggerPosition <= rightEdgeOfVisibleAxis&& selectedDraggerPosition >= leftEdgeOfVisibleAxis;- const newDraggerWithinRangeCheck = isDraggerPositionWithinAxis && isDateWithinRange;+ let newDraggerWithinRangeCheck = isDraggerPositionWithinAxis && isDateWithinRange;+ if (new Date(backDate) > appNow && selectedDraggerTimeState === getISODateFormatted(appNow)) {+ newDraggerWithinRangeCheck = false;+ }return {withinRange: newDraggerWithinRangeCheck,@@ -751,10 +754,10 @@ class TimelineAxis extends Component {* @returns {void}*/updateScaleWithOffset = (date, timeScale, newDateInThePast) => {- const leftOffsetFixedCoeff = newDateInThePast+ const leftOffsetFixedCoefficient = newDateInThePast? 0.25: 0.75;- this.updateScale(date, timeScale, leftOffsetFixedCoeff);+ this.updateScale(date, timeScale, leftOffsetFixedCoefficient);}// #### Drag/mouse handlers ####@@ -826,7 +829,7 @@ class TimelineAxis extends Component {// handle horizontal scroll on x axis wheel eventthis.handleStartDrag();- // mutli-touch drag left+ // multi-touch drag leftif (e.deltaX > 0) {const scrollX = position - deltaChangeCoefficient;// cancel drag if exceeds axis leftBound and hitLeftBound flag hit@@ -985,10 +988,10 @@ class TimelineAxis extends Component {// calculate position of touch click relative to front dateconst positionRelativeToFront = clientX - parentOffset - position - transformX - 2;- // determine approximate new dragger date and coefficient based on gridwidth- const gridWidthCoef = positionRelativeToFront / gridWidth;- const gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);- const draggerDateAdded = moment.utc(frontDate).add(Math.floor(gridWidthCoef), timeScale);+ // determine approximate new dragger date and coefficient based on grid width+ const gridWidthCoefficient = positionRelativeToFront / gridWidth;+ const gridWidthCoefficientRemainder = gridWidthCoefficient - Math.floor(gridWidthCoefficient);+ const draggerDateAdded = moment.utc(frontDate).add(Math.floor(gridWidthCoefficient), timeScale);// get ms time valueconst draggerDateAddedValue = new Date(draggerDateAdded).getTime();@@ -1001,10 +1004,10 @@ class TimelineAxis extends Component {daysCount = draggerDateAdded.daysInMonth();}// days times milliseconds in day times remainder- const remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;+ const remainderMilliseconds = daysCount * 86400000 * gridWidthCoefficientRemainder;newDraggerTime = Math.floor(draggerDateAddedValue + remainderMilliseconds);} else { // known scaleMs (e.g. 86400000 for day)- newDraggerTime = draggerDateAddedValue + (diffZeroValues * gridWidthCoefRemainder);+ newDraggerTime = draggerDateAddedValue + (diffZeroValues * gridWidthCoefficientRemainder);}// check other dragger visibility on update@@ -1274,16 +1277,16 @@ class TimelineAxis extends Component {if (!diffZeroValues) {// calculate based on frontDate due to varying number of days per month and per year (leap years)const hoverLinePositionRelativeToFrontDate = leftOffset - midPoint - newTransformX;- const gridWidthCoef = hoverLinePositionRelativeToFrontDate / gridWidth;- const hoverTimeAdded = moment.utc(frontDate).add(gridWidthCoef, timeScale);+ const gridWidthCoefficient = hoverLinePositionRelativeToFrontDate / gridWidth;+ const hoverTimeAdded = moment.utc(frontDate).add(gridWidthCoefficient, timeScale);let daysCount;if (timeScale === 'year') {daysCount = hoverTimeAdded.isLeapYear() ? 366 : 365;} else if (timeScale === 'month') {daysCount = hoverTimeAdded.daysInMonth();}- const gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);- const remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;+ const gridWidthCoefficientRemainder = gridWidthCoefficient - Math.floor(gridWidthCoefficient);+ const remainderMilliseconds = daysCount * 86400000 * gridWidthCoefficientRemainder;hoverTimeDate = getISODateFormatted(hoverTimeAdded.add(remainderMilliseconds));} else {// calculate based on known diffZeroValues (days, hours, minutes)@@ -1306,7 +1309,7 @@ class TimelineAxis extends Component {? timelineStartDateLimit: hoverTimeDate;- // parent update positioning and hovertime+ // parent update positioning and hover timeupdatePositioningOnAxisStopDrag(updatePositioningArguments, hoverTimeDate);}@@ -1531,6 +1534,7 @@ TimelineAxis.propTypes = {animationStartLocation: PropTypes.number,animEndLocationDate: PropTypes.object,animStartLocationDate: PropTypes.object,+ appNow: PropTypes.object,axisWidth: PropTypes.number,backDate: PropTypes.string,dateA: PropTypes.string,diff --git a/web/js/components/timeline/timeline-controls/animation-button.js b/web/js/components/timeline/timeline-controls/animation-button.jsindex 96098b602..82dc4fae9 100644--- a/web/js/components/timeline/timeline-controls/animation-button.js+++ b/web/js/components/timeline/timeline-controls/animation-button.js@@ -21,7 +21,7 @@ class AnimationButton extends PureComponent {>{labelText}</UncontrolledTooltip>- <FontAwesomeIcon icon="video" className="wv-animate" size="3x" />+ <FontAwesomeIcon icon="video" className="wv-animate" size="2x" /></div></div>);diff --git a/web/js/components/timeline/timeline-controls/date-change-arrows.js b/web/js/components/timeline/timeline-controls/date-change-arrows.jsindex 6bc4e3f28..aabe3e501 100644--- a/web/js/components/timeline/timeline-controls/date-change-arrows.js+++ b/web/js/components/timeline/timeline-controls/date-change-arrows.js@@ -84,6 +84,7 @@ class DateChangeArrows extends PureComponent {isMobile,leftArrowDisabled,rightArrowDisabled,+ handleSelectNowButton,} = this.props;return (<div>@@ -94,6 +95,7 @@ class DateChangeArrows extends PureComponent {onMouseDown={this.leftArrowDown}onMouseUp={this.leftArrowUp}onMouseLeave={this.leftArrowUp}+ aria-disabled={leftArrowDisabled}><HoverTooltipisMobile={isMobile}@@ -116,6 +118,7 @@ class DateChangeArrows extends PureComponent {onMouseDown={this.rightArrowDown}onMouseUp={this.rightArrowUp}onMouseLeave={this.rightArrowUp}+ aria-disabled={rightArrowDisabled}><HoverTooltipisMobile={isMobile}@@ -130,12 +133,34 @@ class DateChangeArrows extends PureComponent {/></svg></div>++ {/* NOW BUTTON */}+ <div+ className={`button-action-group ${rightArrowDisabled ? 'button-disabled' : ''}`}+ id="now-button-group"+ onClick={handleSelectNowButton}+ aria-disabled={rightArrowDisabled}+ >+ <HoverTooltip+ isMobile={isMobile}+ labelText="Now"+ placement="top"+ target="now-button-group"+ />+ <svg height="30" width="30" viewBox="0 0 40 28">+ <path+ d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z M 26,30 26,0 34,0 34,30 z"+ className="arrow arrow-now"+ />+ </svg>+ </div></div>);}}DateChangeArrows.propTypes = {+ handleSelectNowButton: PropTypes.func,leftArrowDisabled: PropTypes.bool,leftArrowDown: PropTypes.func,leftArrowUp: PropTypes.func,diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex d21015800..98fdce6d0 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -44,6 +44,7 @@ import {changeCustomInterval,updateAppNow,toggleCustomModal,+ triggerTodayButton,} from '../../modules/date/actions';import {filterProjLayersWithStartDate,@@ -958,6 +959,11 @@ class Timeline extends React.Component {this.debounceDateUpdate(dateObj, draggerSelected);}+ handleSelectNowButton = () => {+ const { triggerTodayButton } = this.props;+ triggerTodayButton();+ }+/*** @desc getMobileDateButtonStyle date change button style for smaller displays* @returns {Object} style { left, bottom }@@ -1115,6 +1121,7 @@ class Timeline extends React.Component {><div id="zoom-buttons-group"><DateChangeArrows+ handleSelectNowButton={this.handleSelectNowButton}leftArrowDown={this.throttleDecrementDate}leftArrowUp={this.stopLeftArrow}leftArrowDisabled={leftArrowDisabled}@@ -1133,6 +1140,7 @@ class Timeline extends React.Component {<divid="timeline-header"className={`timeline-header-desktop ${hasSubdailyLayers ? 'subdaily' : ''}`}+ style={{ marginRight: isTimelineHidden ? '20px' : '0' }}>{/* Date Selector, Interval, Arrow Controls */}<div id="date-selector-main">@@ -1157,6 +1165,7 @@ class Timeline extends React.Component {hasSubdailyLayers={hasSubdailyLayers}/><DateChangeArrows+ handleSelectNowButton={this.handleSelectNowButton}leftArrowDown={this.throttleDecrementDate}leftArrowUp={this.stopLeftArrow}leftArrowDisabled={leftArrowDisabled}@@ -1184,6 +1193,7 @@ class Timeline extends React.Component {<div id="timeline-footer" className="notranslate">{/* Axis */}<TimelineAxis+ appNow={appNow}axisWidth={axisWidth}parentOffset={parentOffset}leftOffset={leftOffset}@@ -1510,6 +1520,10 @@ const mapDispatchToProps = (dispatch) => ({updateAppNow: (date) => {dispatch(updateAppNow(date));},+ // sets date to NOW based on state.date.appNow+ triggerTodayButton: (date) => {+ dispatch(triggerTodayButton(date));+ },// changes date of active dragger 'selected' or 'selectedB'changeDate: (val) => {dispatch(selectDate(val));@@ -1604,6 +1618,7 @@ Timeline.propTypes = {timeScaleChangeUnit: PropTypes.string,toggleActiveCompareState: PropTypes.func,toggleCustomModal: PropTypes.func,+ triggerTodayButton: PropTypes.func,updateAppNow: PropTypes.func,};diff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.jsindex 293cbabf2..259e76fb5 100644--- a/web/js/modules/date/actions.js+++ b/web/js/modules/date/actions.js@@ -7,8 +7,30 @@ import {TOGGLE_CUSTOM_MODAL,INIT_SECOND_DATE,} from './constants';+import { getSelectedDate } from './selectors';import { getMaxActiveLayersDate } from './util';+export function triggerTodayButton() {+ return (dispatch, getState) => {+ const state = getState();+ const {+ date,+ compare,+ } = state;+ const activeString = compare.isCompareA ? 'selected' : 'selectedB';+ const selectedDate = getSelectedDate(state, activeString);+ const { appNow } = date;++ if (selectedDate < appNow) {+ dispatch({+ type: SELECT_DATE,+ activeString,+ value: appNow,+ });+ }+ };+}+export function changeTimeScale(num) {return {type: CHANGE_TIME_SCALE,diff --git a/web/js/modules/key-press/actions.js b/web/js/modules/key-press/actions.jsindex a62975950..d36498b4c 100644--- a/web/js/modules/key-press/actions.js+++ b/web/js/modules/key-press/actions.js@@ -1,6 +1,7 @@import { KEY_PRESS_ACTION as ANIMATION_KEY_PRESS_ACTION } from '../animation/constants';import { TOUR_KEY_PRESS_CLOSE } from '../tour/constants';import { TOGGLE_DISTRACTION_FREE_MODE } from '../ui/constants';+import { triggerTodayButton } from '../date/actions';import { CLOSE as CLOSE_MODAL } from '../modal/constants';/**@@ -24,7 +25,7 @@ export default function keyPress(keyCode, shiftKey, ctrlOrCmdKey, isInput) {} = modal;const { isDistractionFreeModeActive } = ui;const isProductPickerOpen = isOpen && id === 'LAYER_PICKER_COMPONENT';- if (tour.active && keyCode === 27) {+ if (tour.active && keyCode === 27) { // ESCdispatch({type: TOUR_KEY_PRESS_CLOSE,});@@ -36,12 +37,16 @@ export default function keyPress(keyCode, shiftKey, ctrlOrCmdKey, isInput) {keyCode,});}- if (!isInput && !ctrlOrCmdKey && shiftKey && keyCode === 68) {- dispatch({ type: TOGGLE_DISTRACTION_FREE_MODE });- if (!isDistractionFreeModeActive && isOpen) {- dispatch({ type: CLOSE_MODAL });+ if (!isInput && !ctrlOrCmdKey && shiftKey) {+ if (keyCode === 68) { // SHIFT D+ dispatch({ type: TOGGLE_DISTRACTION_FREE_MODE });+ if (!isDistractionFreeModeActive && isOpen) {+ dispatch({ type: CLOSE_MODAL });+ }+ } else if (keyCode === 84) { // SHIFT T+ dispatch(triggerTodayButton());}- } else if (keyCode === 27) {+ } else if (keyCode === 27) { // ESCif (!isInput && isDistractionFreeModeActive) {dispatch({ type: TOGGLE_DISTRACTION_FREE_MODE });} else {