Interactive interface for browsing global, full-resolution satellite imagery
fix drag to now on timeline, revise right dragger disable and ceiling functionality, styling, e2e update
Ed Platod03cceb7d2b4
diff --git a/e2e/features/timeline/date-selector-test.js b/e2e/features/timeline/date-selector-test.jsindex 727a51a22..c6e934658 100644--- a/e2e/features/timeline/date-selector-test.js+++ b/e2e/features/timeline/date-selector-test.js@@ -55,14 +55,15 @@ module.exports = {},// verify default right arrow disabled since loaded on current day- 'Right timeline arrow will be disabled by default - unless past 00:00 UTC but before 04:00': (c) => {+ 'Right timeline arrow will be disabled by defaul': (c) => {reuseables.loadAndSkipTour(c, TIME_LIMIT);- // accomodate for config.initialDate past 00:00 UTC but before 04:00- if (new Date().getUTCHours() < 3) {- c.assert.not.cssClassPresent('#right-arrow-group', 'button-disabled');- } else {- c.assert.cssClassPresent('#right-arrow-group', 'button-disabled');- }+ c.assert.cssClassPresent('#right-arrow-group', 'button-disabled');+ },++ // verify default not button disabled+ 'Now button will be disabled by default': (c) => {+ reuseables.loadAndSkipTour(c, TIME_LIMIT);+ c.assert.cssClassPresent('#now-button-group', 'button-disabled');},// verify valid right arrow enabled since NOT loaded on current day@@ -71,6 +72,12 @@ module.exports = {c.assert.not.cssClassPresent('#right-arrow-group', 'button-disabled');},+ // verify now button enabled since NOT loaded on current day+ 'Now button will not be disabled': (c) => {+ c.url(c.globals.url + knownDate);+ c.assert.not.cssClassPresent('#now-button-group', 'button-disabled');+ },+// verify date selector is populated with date YYYY-MON-DD'Verify date selector is populated with date YYYY-MON-DD': (c) => {c.url(`${c.globals.url}?t=2019-02-22`);@@ -146,7 +153,6 @@ module.exports = {c.click('#right-arrow-group');c.assert.not.cssClassPresent('#right-arrow-group', 'button-disabled');c.click('#right-arrow-group');- c.assert.not.cssClassPresent('#right-arrow-group', 'button-disabled');},after: (c) => {diff --git a/e2e/features/timeline/timeline-mobile-test.js b/e2e/features/timeline/timeline-mobile-test.jsindex 8f0f51214..58d673cbf 100644--- a/e2e/features/timeline/timeline-mobile-test.js+++ b/e2e/features/timeline/timeline-mobile-test.js@@ -28,7 +28,7 @@ module.exports = {c.assert.containsText(mobileDatePickerSelectBtn, '2013 MAR 15');});},- 'date.mob.init.3b:After 3:00 UTC: right button is disabled': (c) => {+ 'date.mob.init.3b:After 3:00 UTC: right button is disabled': (c) => {c.expect.element(nextDayArrowContainer).to.be.present;c.expect.element(`${nextDayArrowContainer}.button-disabled`).to.be.present;},diff --git a/web/css/timeline.css b/web/css/timeline.cssindex d29746fc2..172eae3b0 100644--- a/web/css/timeline.css+++ b/web/css/timeline.css@@ -178,11 +178,10 @@ button:focus {filter: FlipH;-ms-filter: 'FlipH';}-- & #now-button-group {+ & .now-button-group {width: 34px;height: 34px;- top: 2px;+ top: -1px;& svg {top: 0;left: 3px;@@ -215,7 +214,7 @@ button:focus {position: absolute;height: 34px;width: 37px;- top: 20px;+ top: 16px;right: 4px;padding-left: 4px;padding-top: 5px;@@ -551,22 +550,20 @@ button:focus {border-color: #000;}-#timeline-hide:hover .wv-timeline-hide,-#timeline-layer-coverage-panel-handle:hover .timeline-layer-coverage-panel-handle-chevron {- background-position: -206px -63px;+#timeline-hide:hover .wv-timeline-hide {+ background-position: -206px -68px;}.wv-timeline-hide {display: block;- top: 18px;right: -5px;color: #fff;cursor: pointer;user-select: none;- height: 30px;+ height: 21px;width: 30px;position: absolute;- background: url('../images/icon-sprite.svg') -206px -3px no-repeat;+ background: url('../images/icon-sprite.svg') -206px -8px no-repeat;border-radius: 0;-webkit-box-sizing: border-box;box-sizing: border-box;@@ -574,10 +571,12 @@ button:focus {}.wv-timeline-hide-double-chevron-left {+ top: 26px;transform: rotate(90deg);}.wv-timeline-hide-double-chevron-right {+ top: 22px;transform: rotate(270deg);}@@ -616,6 +615,10 @@ button:focus {margin-left: -14px;}+#timeline-layer-coverage-panel-handle:hover .timeline-layer-coverage-panel-handle-chevron {+ background-position: -206px -63px;+}+.dragger-container {pointer-events: none;position: absolute;@@ -708,7 +711,7 @@ button:focus {}/* Mobile date change arrows */-.mobile-date-change-arrows-btn {+#timeline-header .mobile-date-change-arrows-btn {position: absolute;left: 120px;bottom: 10px;@@ -719,9 +722,19 @@ button:focus {height: 44px;& .button-action-group {height: 44px;+ }+ & #left-arrow-group, #now-button-group {border-top-right-radius: 5px;border-bottom-right-radius: 5px;}+ & #now-button-group {+ height: 44px;+ width: 40px;+ top: 0;+ svg {+ left: 18px;+ }+ }}.datepicker.android-dark .datepicker-header {diff --git a/web/js/components/timeline/timeline-controls/date-change-arrows.js b/web/js/components/timeline/timeline-controls/date-change-arrows.jsindex aabe3e501..601fed087 100644--- a/web/js/components/timeline/timeline-controls/date-change-arrows.js+++ b/web/js/components/timeline/timeline-controls/date-change-arrows.js@@ -81,16 +81,17 @@ class DateChangeArrows extends PureComponent {render() {const {+ handleSelectNowButton,isMobile,leftArrowDisabled,+ nowButtonDisabled,rightArrowDisabled,- handleSelectNowButton,} = this.props;return (<div>{/* LEFT ARROW */}<div- className={`button-action-group ${leftArrowDisabled ? 'button-disabled' : ''}`}+ className={`button-action-group${leftArrowDisabled ? ' button-disabled' : ''}`}id="left-arrow-group"onMouseDown={this.leftArrowDown}onMouseUp={this.leftArrowUp}@@ -113,7 +114,7 @@ class DateChangeArrows extends PureComponent {{/* RIGHT ARROW */}<div- className={`button-action-group ${rightArrowDisabled ? 'button-disabled' : ''}`}+ className={`button-action-group${rightArrowDisabled ? ' button-disabled' : ''}`}id="right-arrow-group"onMouseDown={this.rightArrowDown}onMouseUp={this.rightArrowUp}@@ -136,10 +137,10 @@ class DateChangeArrows extends PureComponent {{/* NOW BUTTON */}<div- className={`button-action-group ${rightArrowDisabled ? 'button-disabled' : ''}`}+ className={`button-action-group now-button-group${nowButtonDisabled ? ' button-disabled' : ''}`}id="now-button-group"onClick={handleSelectNowButton}- aria-disabled={rightArrowDisabled}+ aria-disabled={nowButtonDisabled}><HoverTooltipisMobile={isMobile}@@ -165,6 +166,7 @@ DateChangeArrows.propTypes = {leftArrowDown: PropTypes.func,leftArrowUp: PropTypes.func,isMobile: PropTypes.bool,+ nowButtonDisabled: PropTypes.bool,rightArrowDisabled: PropTypes.bool,rightArrowDown: PropTypes.func,rightArrowUp: PropTypes.func,diff --git a/web/js/components/timeline/timeline-draggers/dragger-container.js b/web/js/components/timeline/timeline-draggers/dragger-container.jsindex 815b479be..c894b7ade 100644--- a/web/js/components/timeline/timeline-draggers/dragger-container.js+++ b/web/js/components/timeline/timeline-draggers/dragger-container.js@@ -190,10 +190,10 @@ class DraggerContainer extends PureComponent {// only need to calculate difference in time unit for varying timescales - month and yearconst diffZeroValues = options.scaleMs;if (!diffZeroValues) {- // calculate based on frontDate due to varying number of days per month and per year (leapyears)+ // calculate based on frontDate due to varying number of days per month and per year (leap years)const draggerPositionRelativeToFrontDate = draggerWidth - 2 + newDraggerPosition - position - transformX;- const gridWidthCoef = draggerPositionRelativeToFrontDate / gridWidth;- const draggerDateAdded = moment.utc(frontDate).add(Math.floor(gridWidthCoef), timeScale);+ const gridWidthCoefficient = draggerPositionRelativeToFrontDate / gridWidth;+ const draggerDateAdded = moment.utc(frontDate).add(Math.floor(gridWidthCoefficient), timeScale);let daysCount;if (timeScale === 'year') {@@ -201,8 +201,8 @@ class DraggerContainer extends PureComponent {} else if (timeScale === 'month') {daysCount = draggerDateAdded.daysInMonth();}- const gridWidthCoefRemainder = gridWidthCoef - Math.floor(gridWidthCoef);- const remainderMilliseconds = daysCount * 86400000 * gridWidthCoefRemainder;+ const gridWidthCoefficientRemainder = gridWidthCoefficient - Math.floor(gridWidthCoefficient);+ const remainderMilliseconds = daysCount * 86400000 * gridWidthCoefficientRemainder;newDraggerTime = draggerDateAdded.add(remainderMilliseconds);} else {const diffFactor = diffZeroValues / gridWidth;@@ -214,6 +214,16 @@ class DraggerContainer extends PureComponent {if (isBetweenValidTimeline) {newDraggerTime = getISODateFormatted(newDraggerTime);} else {+ const timelineEndDateLimitTime = new Date(timelineEndDateLimit).getTime();+ // prevent over drag and set endDatePosition and time to timelineEndDateLimit+ if (newDraggerTime > timelineEndDateLimitTime) {+ const frontDateObj = moment.utc(frontDate);+ const endDateLimitPositionFromFront = Math.abs(frontDateObj.diff(timelineEndDateLimit, timeScale, true) * gridWidth);+ const endDatePosition = endDateLimitPositionFromFront + position - draggerWidth + transformX + 2;++ updateDraggerDatePosition(timelineEndDateLimit, draggerSelected, endDatePosition, null, null, true);+ return;+ }return false;}diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 98fdce6d0..be03f128a 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -976,7 +976,7 @@ class Timeline extends React.Component {screenWidth,} = this.props;- const isScreenWidthLessThan450 = screenWidth < 450;+ const isScreenWidthLessThan484 = screenWidth < 484;// default positioninglet mobileLeft = 190;@@ -989,12 +989,12 @@ class Timeline extends React.Component {// 1) subdaily (mobile date picker width);// 2) screen width; and// 3) compare mode- if (hasSubdailyLayers && screenWidth >= 450) {+ if (hasSubdailyLayers && screenWidth >= 484) {mobileLeft = 287;if (isEmbedModeActive) {mobileLeft = 210;}- } else if (isScreenWidthLessThan450) {+ } else if (isScreenWidthLessThan484) {mobileLeft = isCompareModeActive ? 112 : 10;mobileBottom = 65;if (isEmbedModeActive) {@@ -1035,6 +1035,7 @@ class Timeline extends React.Component {isMobile,isTourActive,leftArrowDisabled,+ nowButtonDisabled,parentOffset,rightArrowDisabled,timelineCustomModalOpen,@@ -1122,13 +1123,14 @@ class Timeline extends React.Component {<div id="zoom-buttons-group"><DateChangeArrowshandleSelectNowButton={this.handleSelectNowButton}+ isMobile={isMobile}+ leftArrowDisabled={leftArrowDisabled}leftArrowDown={this.throttleDecrementDate}leftArrowUp={this.stopLeftArrow}- leftArrowDisabled={leftArrowDisabled}- isMobile={isMobile}+ nowButtonDisabled={nowButtonDisabled}+ rightArrowDisabled={rightArrowDisabled}rightArrowDown={this.throttleIncrementDate}rightArrowUp={this.stopRightArrow}- rightArrowDisabled={rightArrowDisabled}/></div></div>@@ -1166,13 +1168,14 @@ class Timeline extends React.Component {/><DateChangeArrowshandleSelectNowButton={this.handleSelectNowButton}+ isMobile={isMobile}+ leftArrowDisabled={leftArrowDisabled}leftArrowDown={this.throttleDecrementDate}leftArrowUp={this.stopLeftArrow}- leftArrowDisabled={leftArrowDisabled}- isMobile={isMobile}+ nowButtonDisabled={nowButtonDisabled}+ rightArrowDisabled={rightArrowDisabled}rightArrowDown={this.throttleIncrementDate}rightArrowUp={this.stopRightArrow}- rightArrowDisabled={rightArrowDisabled}/></div><AnimationButton@@ -1472,6 +1475,10 @@ function mapStateToProps(state) {timeScaleChangeUnit,timelineEndDateLimit,);+ const nowButtonDisabled = checkNowButtonDisabled(+ selectedDate,+ timelineEndDateLimit,+ );return {appNow,activeLayers: activeLayersFiltered,@@ -1500,6 +1507,7 @@ function mapStateToProps(state) {timelineEndDateLimit,leftArrowDisabled,rightArrowDisabled,+ nowButtonDisabled,hideTimeline:(modal.isOpen && modal.id === 'TOOLBAR_SNAPSHOT') || animation.gifActive,animationDisabled:@@ -1521,8 +1529,8 @@ const mapDispatchToProps = (dispatch) => ({dispatch(updateAppNow(date));},// sets date to NOW based on state.date.appNow- triggerTodayButton: (date) => {- dispatch(triggerTodayButton(date));+ triggerTodayButton: () => {+ dispatch(triggerTodayButton());},// changes date of active dragger 'selected' or 'selectedB'changeDate: (val) => {@@ -1602,6 +1610,7 @@ Timeline.propTypes = {isMobile: PropTypes.bool,isTourActive: PropTypes.bool,leftArrowDisabled: PropTypes.bool,+ nowButtonDisabled: PropTypes.bool,onUpdateEndDate: PropTypes.func,onUpdateStartAndEndDate: PropTypes.func,onUpdateStartDate: PropTypes.func,@@ -1702,12 +1711,19 @@ const checkRightArrowDisabled = () => {const nextIncMoment = moment.utc(date).add(delta, timeScaleChangeUnit);const nextIncrementDate = new Date(nextIncMoment.seconds(0).format());- const maxPlusDeltaMoment = moment.utc(timelineEndDateLimit).add(delta, timeScaleChangeUnit);- const maxPlusDeltaDate = new Date(maxPlusDeltaMoment.seconds(0).format());const nextIncrementDateTime = nextIncrementDate.getTime();- const maxPlusDeltaDateTime = maxPlusDeltaDate.getTime();- return nextIncrementDateTime >= maxPlusDeltaDateTime;+ const maxPlusDeltaDateTime = new Date(timelineEndDateLimit).getTime();+ return nextIncrementDateTime > maxPlusDeltaDateTime;+};++const checkNowButtonDisabled = (+ date,+ timelineEndDateLimit,+) => {+ const dateTimeMoment = new Date(moment.utc(date).seconds(0).format());+ const maxDateMoment = new Date(moment.utc(timelineEndDateLimit).seconds(0).format());+ return dateTimeMoment.getTime() === maxDateMoment.getTime();};// get timelineEndDateLimit based on potential future layersdiff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.jsindex 259e76fb5..44d0d42fc 100644--- a/web/js/modules/date/actions.js+++ b/web/js/modules/date/actions.js@@ -21,7 +21,9 @@ export function triggerTodayButton() {const selectedDate = getSelectedDate(state, activeString);const { appNow } = date;- if (selectedDate < appNow) {+ const selectedDateTime = selectedDate.getTime();+ const appNowTime = appNow.getTime();+ if (selectedDateTime < appNowTime) {dispatch({type: SELECT_DATE,activeString,