Interactive interface for browsing global, full-resolution satellite imagery
WV-2143: Animation on mobile (#3805)
Jason Kent36390186045d
diff --git a/web/css/alert.css b/web/css/alert.cssindex 257726d1f..5c0fb636c 100644--- a/web/css/alert.css+++ b/web/css/alert.css@@ -1,22 +1,34 @@.wv-alert-container {position: absolute;- top: 60px !important;- right: 10px !important;- left: auto !important;+ top: 60px;+ right: 10px;+ left: auto;}+.wv-alert {+ position: relative;+ color: #fff;+ background: #282828;+ border: #282828;+ border-radius: 0;display: flex;align-items: center;justify-content: center;min-height: 40px;cursor: pointer;padding: 0;- border: none;z-index: 100;margin-bottom: 5px;}+.alert-content {+ padding-right: 3px;+ display: flex;+ align-items: center;+ height: 40px;+}.wv-alert .close-alert {padding: 11px 2px;+ text-align: center;}.wv-alert div:hover {background-color: #ddd;@@ -24,28 +36,20 @@}.wv-alert svg.svg-inline--fa {color: #d54e21;- margin-right: 10px;+ margin: 0 10px;font-size: 1.4em;}.wv-alert svg.svg-inline--fa.exit {color: #fff;margin-left: 10px;- font-size: 1.4em;}.wv-alert div:hover .exit {color: #333;}-.wv-alert-icon {+.wv-alert-icon svg.svg-inline--fa {padding-left: 3px;margin-left: 5px;}-.alert-content {- padding-right: 3px;- display: flex;- align-items: center;- height: 40px;- width: 100%;-}/* ErrorBoundary */.error-icon {@@ -58,3 +62,40 @@.error-body {margin-top: 10px;}++@media (max-width: 768px) {+ .wv-alert {+ min-height: 50px;+ font-size: 12px;+ svg.svg-inline--fa.wv-alert-icon {+ font-size: 2em;+ }+ }+ .alert-content {+ width: 85%;+ left: 0;+ position: absolute;+ }+ .wv-alert-container {+ position: absolute;+ top: 110px;+ right: 5px;+ left: 5px;+ }+ .wv-alert-icon {+ padding-left: 3px;+ margin-left: 5px;+ }+ .wv-alert-message {+ font-size: 14px;+ line-height: 16px;+ }+ .close-alert {+ position: absolute;+ right: 0;+ width: 15%;+ svg.svg-inline--fa.exit {+ font-size: 1.75em;+ }+ }+}diff --git a/web/css/anim.widget.css b/web/css/anim.widget.cssindex e0c3590b3..d90cde789 100644--- a/web/css/anim.widget.css+++ b/web/css/anim.widget.css@@ -1,12 +1,48 @@.wv-animation-widget-wrapper {position: absolute;- bottom: 88px;z-index: 100;+}+@media (min-width: 769px) {+ .wv-animation-widget-wrapper {+ bottom: 88px;+ &.minimized {+ bottom: 83px;+ left: 10px;+ }+ }+}++/* Mobile Style */+.wv-animation-widget-wrapper.mobile {+ bottom: 0;&.minimized {- bottom: 83px;- left: 10px;+ bottom: 10px;+ left: 188px;+ &.landscape {+ left: 323px;+ }+ }+ &.subdaily {+ bottom: 65px;+ left: 165px;+ &.landscape {+ bottom: 10px;+ left: 420px;+ }+ }+ .wv-animation-widget.minimized {+ background: transparent;+ height: 44px;+ width: 114px;+ .wv-icon-case {+ border: 2px solid #333;+ margin: 0;+ height: 42px;+ width: 112px;+ }}}+.wv-animation-widget .input-range.rc-slider-disabled {cursor: default;}@@ -114,9 +150,13 @@right: 8px;bottom: 9px;}- &:hover {- color: #999;- cursor: pointer;++ /* No hover styles on mobile */+ @media (min-width: 769px) {+ &:hover {+ color: #999;+ cursor: pointer;+ }}}.wv-date-range-selector {@@ -132,9 +172,11 @@ a .wv-animation-widget-icon {-webkit-transform: translate(-50%, -50%);left: 50%;top: 50%;- &:hover {- color: #fff;- opacity: 0.5;+ @media (min-width: 769px) {+ &:hover {+ color: #fff;+ opacity: 0.5;+ }}&.fa-file-video {font-size: 29px;diff --git a/web/css/events.css b/web/css/events.cssindex 579afac95..0ecd4e141 100644--- a/web/css/events.css+++ b/web/css/events.css@@ -373,20 +373,6 @@height: 100px;}-.wv-alert {- position: relative;- color: #fff;- background: #282828;- border: #282828;- border-radius: 0;-}--@media only screen and (max-width: 420px) {- .wv-alert {- left: 10px !important;- }-}-.event-alert-modal-body ul {padding-left: 20px;margin: 10px 0;diff --git a/web/js/components/animation-widget/gif-button.js b/web/js/components/animation-widget/gif-button.jsnew file mode 100644index 000000000..0470d6c81--- /dev/null+++ b/web/js/components/animation-widget/gif-button.js@@ -0,0 +1,222 @@+import React from 'react';+import { connect } from 'react-redux';+import PropTypes from 'prop-types';+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';+import { UncontrolledTooltip } from 'reactstrap';+import googleTagManager from 'googleTagManager';+import {+ cloneDeep as lodashCloneDeep,+ find as lodashFind,+ filter as lodashFilter,+ get as lodashGet,+} from 'lodash';+import GifContainer from '../../containers/gif';+import {+ toggleComponentGifActive,+ changeStartAndEndDate,+} from '../../modules/animation/actions';+import { clearCustoms, refreshPalettes } from '../../modules/palettes/actions';+import { clearRotate, refreshRotation } from '../../modules/map/actions';+import {+ clearGraticule, refreshGraticule, hideLayers, showLayers,+} from '../../modules/layers/actions';+import {+ getActiveLayers,+ getAllActiveLayers,+} from '../../modules/layers/selectors';+import {+ getNonDownloadableLayers,+ getNonDownloadableLayerWarning,+ hasNonDownloadableVisibleLayer,+} from '../../modules/image-download/util';+import Notify from '../image-download/notify';+import { notificationWarnings } from '../../modules/image-download/constants';+import { onToggle, openCustomContent } from '../../modules/modal/actions';+import { hasCustomPaletteInActiveProjection } from '../../modules/palettes/util';++const maxGifFrames = 40;+let onCloseGif;++const GifButton = (props) => {+ const {+ toggleGif,+ onUpdateStartAndEndDate,+ hasCustomPalettes,+ isRotated,+ hasGraticule,+ rotation,+ activePalettes,+ numberOfFrames,+ refreshStateAfterGif,+ hasNonDownloadableLayer,+ visibleLayersForProj,+ proj,+ notify,+ isGifActive,+ zeroDates,+ } = props;++ const gifDisabled = numberOfFrames >= maxGifFrames;+ const elemExists = document.querySelector('#create-gif-button');+ const showWarning = elemExists && gifDisabled;+ const warningMessage = (+ <span>+ Too many frames were selected.+ <br />+ Please request less than 40 frames if you would like to generate a GIF.+ </span>+ );+ const labelText = 'Create an animated GIF';+ const getPromise = (bool, type, action) => {+ if (bool) {+ return notify(type, action, visibleLayersForProj);+ }+ return Promise.resolve(type);+ };++ const openGif = async () => {+ const { startDate, endDate } = zeroDates();+ if (gifDisabled) {+ return;+ }+ const nonDownloadableLayers = hasNonDownloadableLayer ? getNonDownloadableLayers(visibleLayersForProj) : null;+ const paletteStore = lodashCloneDeep(activePalettes);+ await getPromise(hasCustomPalettes, 'palette', clearCustoms, 'Notice');+ await getPromise(isRotated, 'rotate', clearRotate, 'Reset rotation');+ await getPromise(hasGraticule && proj.id === 'geographic', 'graticule', clearGraticule, 'Remove Graticule?');+ await getPromise(hasNonDownloadableLayer, 'layers', hideLayers, 'Remove Layers?');+ await onUpdateStartAndEndDate(startDate, endDate);+ googleTagManager.pushEvent({+ event: 'GIF_create_animated_button',+ });++ onCloseGif = () => {+ refreshStateAfterGif(hasCustomPalettes ? paletteStore : undefined, rotation, hasGraticule, nonDownloadableLayers);+ toggleGif();+ };+ toggleGif();+ };++ return (+ <>+ <a+ id="create-gif-button"+ aria-label={labelText}+ className={gifDisabled ? 'wv-icon-case no-drag disabled' : 'wv-icon-case no-drag'}+ onClick={openGif}+ >+ <FontAwesomeIcon+ id="wv-animation-widget-file-video-icon"+ className="wv-animation-widget-icon"+ icon="file-video"+ />+ <UncontrolledTooltip+ placement="right"+ target="create-gif-button"+ >+ {showWarning ? warningMessage : labelText}+ </UncontrolledTooltip>+ </a>+ {isGifActive && <GifContainer onClose={onCloseGif} />}+ </>+ );+};++const mapStateToProps = (state) => {+ const {+ animation, palettes, compare, map, proj,+ } = state;+ const activeLayersForProj = getAllActiveLayers(state);+ const visibleLayersForProj = lodashFilter(activeLayersForProj, 'visible');+ const activePalettes = palettes[compare.activeString];+ const hasCustomPalettes = hasCustomPaletteInActiveProjection(+ activeLayersForProj,+ activePalettes,+ );+ const activeLayers = getActiveLayers(state);+ return {+ activePalettes,+ hasCustomPalettes,+ hasGraticule: Boolean(+ lodashGet(+ lodashFind(activeLayers, { id: 'Graticule' }) || {},+ 'visible',+ ),+ ),+ hasNonDownloadableLayer: hasNonDownloadableVisibleLayer(visibleLayersForProj),+ isGifActive: animation.gifActive,+ isRotated: Boolean(map.rotation !== 0),+ proj,+ rotation: map.rotation,+ visibleLayersForProj,+ };+};++const mapDispatchToProps = (dispatch) => ({+ toggleGif: () => {+ dispatch(toggleComponentGifActive());+ },+ onUpdateStartAndEndDate: (startDate, endDate) => {+ dispatch(changeStartAndEndDate(startDate, endDate));+ },+ refreshStateAfterGif: (activePalettes, rotation, isGraticule, nonDownloadableLayers) => {+ if (activePalettes) {+ dispatch(refreshPalettes(activePalettes));+ }+ if (rotation) {+ dispatch(refreshRotation(rotation));+ }+ if (isGraticule) {+ dispatch(refreshGraticule(isGraticule));+ }+ if (nonDownloadableLayers) {+ dispatch(showLayers(nonDownloadableLayers));+ }+ },+ notify: (type, action, visibleLayersForProj) => new Promise((resolve, reject, cancel) => {+ const nonDownloadableLayers = type !== 'layers' ? null : getNonDownloadableLayers(visibleLayersForProj);+ const bodyComponentProps = {+ bodyText: type !== 'layers' ? notificationWarnings[type] : getNonDownloadableLayerWarning(nonDownloadableLayers),+ cancel: () => {+ dispatch(onToggle());+ },+ accept: () => {+ dispatch(action(nonDownloadableLayers));+ dispatch(onToggle());+ resolve();+ },+ };+ dispatch(+ openCustomContent(`image_download_notify_${type}`, {+ headerText: 'Notify',+ bodyComponent: Notify,+ size: 'sm',+ modalClassName: 'notify',+ bodyComponentProps,+ }),+ );+ }),+});++export default connect(+ mapStateToProps,+ mapDispatchToProps,+)(GifButton);++GifButton.propTypes = {+ activePalettes: PropTypes.object,+ visibleLayersForProj: PropTypes.array,+ hasCustomPalettes: PropTypes.bool,+ hasGraticule: PropTypes.bool,+ hasNonDownloadableLayer: PropTypes.bool,+ isGifActive: PropTypes.bool,+ isRotated: PropTypes.bool,+ notify: PropTypes.func,+ numberOfFrames: PropTypes.number,+ onUpdateStartAndEndDate: PropTypes.func,+ proj: PropTypes.object,+ refreshStateAfterGif: PropTypes.func,+ rotation: PropTypes.number,+ toggleGif: PropTypes.func,+ zeroDates: PropTypes.func,+};diff --git a/web/js/components/animation-widget/play-button.js b/web/js/components/animation-widget/play-button.jsindex f825150c0..5fe8b783c 100644--- a/web/js/components/animation-widget/play-button.js+++ b/web/js/components/animation-widget/play-button.js@@ -8,7 +8,7 @@ import { UncontrolledTooltip } from 'reactstrap';* @extends React.Component*/const PlayButton = ({- playing, pause, play, isDisabled,+ playing, pause, play, isDisabled, isMobile,}) => {const buttonId = 'play-button';const labelText = isDisabled@@ -24,12 +24,14 @@ const PlayButton = ({className={`wv-anim-play-case wv-icon-case no-drag ${isDisabled ? 'disabled' : ''}`}onClick={onClick}>- <UncontrolledTooltip- target={buttonId}- placement="top"- >- {labelText}- </UncontrolledTooltip>+ {!isMobile && (+ <UncontrolledTooltip+ target={buttonId}+ placement="top"+ >+ {labelText}+ </UncontrolledTooltip>+ )}{playing? <FontAwesomeIcon icon="pause" className="wv-animation-widget-icon" />: <FontAwesomeIcon icon="play" className="wv-animation-widget-icon" />}@@ -42,6 +44,7 @@ PlayButton.propTypes = {play: PropTypes.func,playing: PropTypes.bool,isDisabled: PropTypes.bool,+ isMobile: PropTypes.bool,};export default PlayButton;diff --git a/web/js/components/animation-widget/play-queue.js b/web/js/components/animation-widget/play-queue.jsindex 0bd09f0f6..2cb1a8701 100644--- a/web/js/components/animation-widget/play-queue.js+++ b/web/js/components/animation-widget/play-queue.js@@ -2,6 +2,7 @@import React from 'react';import PropTypes from 'prop-types';import PQueue from 'p-queue/dist';+import { Progress } from 'reactstrap';import LoadingIndicator from './loading-indicator';import util from '../../util/util';@@ -36,6 +37,7 @@ class PlayQueue extends React.Component {this.playingDate = this.getStartDate();this.checkQueue();this.checkShouldPlay();+ this.determineFrameDates();}componentWillUnmount() {@@ -47,13 +49,27 @@ class PlayQueue extends React.Component {}}+ /**+ * Create an array of each date to be played+ */+ determineFrameDates() {+ const { startDate, endDate } = this.props;+ let frameDate = startDate;+ this.frameDates = [];+ this.frameDates.push(toString(frameDate));+ while (frameDate < endDate) {+ frameDate = this.nextDate(frameDate);+ this.frameDates.push(toString(frameDate));+ }+ }+/*** Determines whether to start at current date or the selected start date*/getStartDate() {- const { endDate, startDate, currentDate } = this.props;- const nextDate = this.nextDate(currentDate);- if (currentDate > startDate && nextDate < endDate) {+ const { endDate, startDate, snappedCurrentDate } = this.props;+ const nextDate = this.nextDate(snappedCurrentDate);+ if (snappedCurrentDate > startDate && nextDate < endDate) {return toString(nextDate);}return toString(startDate);@@ -184,7 +200,6 @@ class PlayQueue extends React.Component {this.checkQueue();};-checkShouldLoop() {const { isLoopActive, startDate, togglePlaying } = this.props;// Could base this off animation speed?@@ -356,14 +371,39 @@ class PlayQueue extends React.Component {this.playInterval = setTimeout(player, speed);}+ getPlaybackPosition() {+ const { isAnimating } = this.state;+ const { currentDate } = this.props;+ if (!isAnimating) {+ return 0;+ }+ const currentDateStr = toString(currentDate);+ const position = this.frameDates.indexOf(currentDateStr) + 1;+ const percentage = (position / this.frameDates.length) * 100;+ console.log(percentage);+ return percentage;+ }+render() {const { isAnimating } = this.state;- const { onClose } = this.props;+ const { onClose, isMobile } = this.props;const loadedItems = util.objectLength(this.bufferObject);const title = !this.minBufferLength ? 'Determining buffer size...' : 'Preloading buffer...';+ const mobileProgressStyle = {+ position: 'absolute',+ bottom: 0,+ width: '100%',+ height: '6px',+ };return isAnimating- ? ''+ ? isMobile && (+ <Progress+ style={mobileProgressStyle}+ value={this.getPlaybackPosition()}+ color="dark"+ />+ ): (<LoadingIndicatortitle={title}@@ -377,6 +417,7 @@ class PlayQueue extends React.Component {PlayQueue.propTypes = {endDate: PropTypes.object.isRequired,+ isMobile: PropTypes.bool,isPlaying: PropTypes.bool.isRequired,promiseImageryForTime: PropTypes.func.isRequired,selectDate: PropTypes.func.isRequired,@@ -390,6 +431,7 @@ PlayQueue.propTypes = {onClose: PropTypes.func,numberOfFrames: PropTypes.number,subDailyMode: PropTypes.bool,+ snappedCurrentDate: PropTypes.object,};export default PlayQueue;diff --git a/web/js/components/util/alert.js b/web/js/components/util/alert.jsindex 606f221c5..f3585a399 100644--- a/web/js/components/util/alert.js+++ b/web/js/components/util/alert.js@@ -19,6 +19,9 @@ export default class AlertUtil extends React.Component {props.onDismiss();}, props.timeout);}+ this.state = {+ isOpen: props.isOpen,+ };}componentDidMount() {@@ -31,16 +34,24 @@ export default class AlertUtil extends React.Component {}}+ closeAlert() {+ const { onDismiss } = this.props;+ this.setState({ isOpen: false });+ if (onDismiss) {+ onDismiss();+ }+ }+renderAlert() {const {id,title,message,icon,- isOpen,onDismiss,onClick,} = this.props;+ const { isOpen } = this.state;return (<Alert@@ -64,7 +75,11 @@ export default class AlertUtil extends React.Component {</div></div>{onDismiss && (- <div id={`${id}-close`} className="close-alert" onClick={onDismiss}>+ <div+ id={`${id}-close`}+ className="close-alert"+ onClick={() => this.closeAlert()}+ ><FontAwesomeIcon icon="times" className="exit" size="1x" /></div>)}diff --git a/web/js/containers/alerts.js b/web/js/containers/alerts.jsindex 484c2b281..b4f79d034 100644--- a/web/js/containers/alerts.js+++ b/web/js/containers/alerts.js@@ -7,7 +7,7 @@ import { openCustomContent } from '../modules/modal/actions';import { hasVectorLayers } from '../modules/layers/util';import { DISABLE_VECTOR_ZOOM_ALERT, DISABLE_VECTOR_EXCEEDED_ALERT, MODAL_PROPERTIES } from '../modules/alerts/constants';import safeLocalStorage from '../util/local-storage';-import { getActiveLayers } from '../modules/layers/selectors';+import { getActiveLayers, subdailyLayersActive } from '../modules/layers/selectors';const HAS_LOCAL_STORAGE = safeLocalStorage.enabled;const {@@ -15,6 +15,7 @@ const {DISMISSED_DISTRACTION_FREE_ALERT,DISMISSED_EVENT_VIS_ALERT,} = safeLocalStorage.keys;+class DismissableAlerts extends React.Component {constructor(props) {super(props);@@ -63,11 +64,14 @@ class DismissableAlerts extends React.Component {const {dismissVectorZoomAlert,dismissVectorExceededAlert,+ hasSubdailyLayers,isCompareActive,isDistractionFreeModeActive,isEmbedModeActive,isEventsActive,isSmall,+ isMobile,+ isAnimationActive,isVectorZoomAlertPresent,isVectorExceededAlertPresent,openAlertModal,@@ -86,6 +90,7 @@ class DismissableAlerts extends React.Component {const showEventsAlert = !isSmall && !hasDismissedEvents && isEventsActive;const showCompareAlert = !isSmall && !hasDismissedCompare && isCompareActive;+ const showAnimationAlert = isMobile && isAnimationActive && hasSubdailyLayers;return isDistractionFreeModeActive? !hasDismissedDistractionFree && (@@ -134,6 +139,16 @@ class DismissableAlerts extends React.Component {message="Too many results at selected point. Zoom in map to see more individual points."/>)}+ {showAnimationAlert && (+ <AlertUtil+ isOpen+ noPortal+ icon="info-circle"+ message="Some animations may use a large amount of data (>100MB)"+ onDismiss={() => {}}+ />+ )}+</>);}@@ -147,7 +162,7 @@ const mapDispatchToProps = (dispatch) => ({});const mapStateToProps = (state) => {const {- browser, embed, events, sidebar, compare, alerts, ui,+ browser, embed, events, sidebar, compare, alerts, ui, animation,} = state;const { isVectorZoomAlertPresent, isVectorExceededAlertPresent } = alerts;const activeLayers = getActiveLayers(state);@@ -159,8 +174,11 @@ const mapStateToProps = (state) => {isEmbedModeActive: embed.isEmbedModeActive,isEventsActive: !!(events.selected.id && sidebar.activeTab === 'events'),isSmall: browser.lessThan.small,+ isMobile: browser.lessThan.medium,+ isAnimationActive: animation.isActive,isVectorZoomAlertPresent: hasActiveVectorLayers && isVectorZoomAlertPresent,isVectorExceededAlertPresent: hasActiveVectorLayers && isVectorExceededAlertPresent,+ hasSubdailyLayers: subdailyLayersActive(state),};};export default connect(@@ -171,11 +189,14 @@ export default connect(DismissableAlerts.propTypes = {dismissVectorZoomAlert: PropTypes.func,dismissVectorExceededAlert: PropTypes.func,+ hasSubdailyLayers: PropTypes.bool,+ isAnimationActive: PropTypes.bool,isCompareActive: PropTypes.bool,isDistractionFreeModeActive: PropTypes.bool,isEmbedModeActive: PropTypes.bool,isEventsActive: PropTypes.bool,isSmall: PropTypes.bool,+ isMobile: PropTypes.bool,isVectorZoomAlertPresent: PropTypes.bool,isVectorExceededAlertPresent: PropTypes.bool,openAlertModal: PropTypes.func,diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.jsindex 4183fb317..49637ea46 100644--- a/web/js/containers/animation-widget.js+++ b/web/js/containers/animation-widget.js@@ -1,17 +1,13 @@import React from 'react';import { connect } from 'react-redux';import {- find as lodashFind,- filter as lodashFilter,get as lodashGet,- cloneDeep as lodashCloneDeep,} from 'lodash';-import googleTagManager from 'googleTagManager';import PropTypes from 'prop-types';import Slider, { Handle } from 'rc-slider';-import { UncontrolledTooltip } from 'reactstrap';import Draggable from 'react-draggable';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';+import util from '../util/util';import ErrorBoundary from './error-boundary';import DateRangeSelector from '../components/date-selector/date-range-selector';@@ -20,9 +16,7 @@ import PlayButton from '../components/animation-widget/play-button';import TimeScaleIntervalChange from '../components/timeline/timeline-controls/timescale-interval-change';import CustomIntervalSelector from '../components/timeline/custom-interval-selector/custom-interval-selector';import PlayQueue from '../components/animation-widget/play-queue';-import Notify from '../components/image-download/notify';import { promiseImageryForTime } from '../modules/map/util';-import GifContainer from './gif';import {selectDate,selectInterval,@@ -39,7 +33,6 @@ import {} from '../modules/animation/util';import {subdailyLayersActive,- getActiveLayers,getAllActiveLayers,dateRange as getDateRange,} from '../modules/layers/selectors';@@ -53,18 +46,8 @@ import {changeStartDate,changeEndDate,changeStartAndEndDate,- toggleComponentGifActive,} from '../modules/animation/actions';-import { notificationWarnings } from '../modules/image-download/constants';-import { onToggle, openCustomContent } from '../modules/modal/actions';-import { clearCustoms, refreshPalettes } from '../modules/palettes/actions';-import { clearRotate, refreshRotation } from '../modules/map/actions';-import {- clearGraticule, refreshGraticule, hideLayers, showLayers,-} from '../modules/layers/actions';-import { hasCustomPaletteInActiveProjection } from '../modules/palettes/util';-import { getNonDownloadableLayers, getNonDownloadableLayerWarning, hasNonDownloadableVisibleLayer } from '../modules/image-download/util';-+import GifButton from '../components/animation-widget/gif-button';const RangeHandle = (props) => {const {@@ -94,15 +77,7 @@ const RangeHandle = (props) => {const widgetWidth = 334;const subdailyWidgetWidth = 460;const maxFrames = 300;-const maxGifFrames = 40;--/*- * A react component, Builds a rather specific- * interactive widget- *- * @class AnimationWidget- * @extends React.Component- */+class AnimationWidget extends React.Component {constructor(props) {super(props);@@ -175,8 +150,6 @@ class AnimationWidget extends React.Component {/*** Prevent drag when interacting with child elements (e.g. buttons)* Only allow drag when targeting "background" elements- * @param {*} e- * @param {*} data*/handleDragStart = (e, data) => {const draggableTargets = [@@ -205,28 +178,6 @@ class AnimationWidget extends React.Component {});}- getPromise(bool, type, action) {- const { visibleLayersForProj } = this.props;- const { notify } = this.props;- if (bool) {- return notify(type, action, visibleLayersForProj);- }- return Promise.resolve(type);- }-- /**- * Sets a new state to say whether or not- * the animation should loop- *- * @method onLoop- *- * @param {Object} component - slider react- * component- * @param {number} value - Value of the slider- * selection- *- * @return {void}- */onLoop() {const { looping } = this.state;const { onPushLoop } = this.props;@@ -249,17 +200,6 @@ class AnimationWidget extends React.Component {}}- /**- * Changes selected default or custom interval in header and- * changes left/right date arrow increments- *- * @method onIntervalSelect- *- * @param {string} timeScale - clicked header string (ex: 'day', 'year', '12 day')- * component- *- * @return {void}- */onIntervalSelect(timeScale, openModal) {let delta;const { onIntervalSelect, customInterval, customDelta } = this.props;@@ -280,13 +220,6 @@ class AnimationWidget extends React.Component {onIntervalSelect(delta, timeScale, customSelected);}- /**- * update global store startDate, endDate, and isPlaying- *- * @method onPushPlay- *- * @return {void}- */onPushPlay = () => {const {onUpdateStartAndEndDate,@@ -337,11 +270,6 @@ class AnimationWidget extends React.Component {};}- /**- * @desc show/hide custom interval modal- * @param {Boolean} isOpen- * @returns {void}- */toggleCustomIntervalModal = (isOpen) => {const { toggleCustomModal } = this.props;toggleCustomModal(isOpen, customModalType.ANIMATION);@@ -349,24 +277,33 @@ class AnimationWidget extends React.Component {renderCollapsedWidget() {const {- onClose,+ hasSubdailyLayers,+ isLandscape,+ isMobile,isPlaying,+ onClose,onPushPause,- hasSubdailyLayers,- numberOfFrames,+ playDisabled,} = this.props;const { collapsedWidgetPosition } = this.state;const cancelSelector = '.no-drag, svg';- return (+ const dontShow = isMobile && playDisabled;+ const widgetClasses = 'wv-animation-widget-wrapper minimized '+ + `${hasSubdailyLayers ? 'subdaily ' : ''}`+ + `${isMobile ? 'mobile ' : ''}`+ + `${isLandscape ? 'landscape ' : ''}`;++ return !dontShow && (<Draggablebounds="body"cancel={cancelSelector}onStart={this.handleDragStart}position={collapsedWidgetPosition}onDrag={this.onCollapsedDrag}+ disabled={isMobile}><div- className={`wv-animation-widget-wrapper minimized${hasSubdailyLayers ? ' subdaily' : ''}`}+ className={widgetClasses}><divid="wv-animation-widget"@@ -376,89 +313,17 @@ class AnimationWidget extends React.Component {playing={isPlaying}play={this.onPushPlay}pause={onPushPause}- isDisabled={numberOfFrames >= maxFrames}+ isDisabled={playDisabled}+ isMobile={isMobile}/>- <FontAwesomeIcon icon="chevron-up" className="wv-expand" onClick={this.toggleCollapse} />- <FontAwesomeIcon icon="times" className="wv-close" onClick={onClose} />+ {!isMobile && <FontAwesomeIcon icon="chevron-up" className="wv-expand" onClick={this.toggleCollapse} /> }+ {!isMobile && <FontAwesomeIcon icon="times" className="wv-close" onClick={onClose} /> }</div></div></Draggable>);}- renderCreateGifButton() {- const {- toggleGif,- onUpdateStartAndEndDate,- hasCustomPalettes,- isRotated,- hasGraticule,- rotation,- activePalettes,- numberOfFrames,- refreshStateAfterGif,- hasNonDownloadableLayer,- visibleLayersForProj,- proj,- } = this.props;- const gifDisabled = numberOfFrames >= maxGifFrames;- const elemExists = document.querySelector('#create-gif-button');- const showWarning = elemExists && numberOfFrames >= maxGifFrames;- const warningMessage = (- <span>- Too many frames were selected.- <br />- Please request less than 40 frames if you would like to generate a GIF.- </span>- );- const labelText = 'Create an animated GIF';-- const openGif = async () => {- const { startDate, endDate } = this.zeroDates();- if (numberOfFrames >= maxGifFrames) {- return;- }- const nonDownloadableLayers = hasNonDownloadableLayer ? getNonDownloadableLayers(visibleLayersForProj) : null;- const paletteStore = lodashCloneDeep(activePalettes);-- await this.getPromise(hasCustomPalettes, 'palette', clearCustoms, 'Notice');- await this.getPromise(isRotated, 'rotate', clearRotate, 'Reset rotation');- await this.getPromise(hasGraticule && proj.id === 'geographic', 'graticule', clearGraticule, 'Remove Graticule?');- await this.getPromise(hasNonDownloadableLayer, 'layers', hideLayers, 'Remove Layers?');- await onUpdateStartAndEndDate(startDate, endDate);- googleTagManager.pushEvent({- event: 'GIF_create_animated_button',- });- this.onCloseGif = () => {- refreshStateAfterGif(hasCustomPalettes ? paletteStore : undefined, rotation, hasGraticule, nonDownloadableLayers);- toggleGif();- };- toggleGif();- };-- return (- <a- id="create-gif-button"- aria-label={labelText}- className={gifDisabled ? 'wv-icon-case no-drag disabled' : 'wv-icon-case no-drag'}- onClick={openGif}- >- <FontAwesomeIcon- id="wv-animation-widget-file-video-icon"- className="wv-animation-widget-icon"- icon="file-video"- />- <UncontrolledTooltip- placement="right"- target="create-gif-button"- >- {showWarning ? warningMessage : labelText}- </UncontrolledTooltip>- </a>-- );- }-renderExpandedWidget() {const {onClose,@@ -475,6 +340,7 @@ class AnimationWidget extends React.Component {interval,animationCustomModalOpen,hasSubdailyLayers,+ playDisabled,numberOfFrames,} = this.props;const { speed, widgetPosition } = this.state;@@ -515,7 +381,7 @@ class AnimationWidget extends React.Component {playing={isPlaying}play={this.onPushPlay}pause={onPushPause}- isDisabled={numberOfFrames >= maxFrames}+ isDisabled={playDisabled}/><LoopButton looping={looping} onLoop={this.onLoop} />@@ -536,7 +402,10 @@ class AnimationWidget extends React.Component {</div>{/* Create Gif */}- {this.renderCreateGifButton()}+ <GifButton+ zeroDates={this.zeroDates}+ numberOfFrames={numberOfFrames}+ />{/* From/To Date/Time Selection */}<DateRangeSelector@@ -564,14 +433,15 @@ class AnimationWidget extends React.Component {looping,isPlaying,startDate,+ isMobile,endDate,onPushPause,isActive,isDistractionFreeModeActive,promiseImageryForTime,selectDate,+ currentDate,snappedCurrentDate,- isGifActive,delta,interval,numberOfFrames,@@ -582,17 +452,16 @@ class AnimationWidget extends React.Component {if (!isActive) {return null;}- if (isGifActive) {- return <GifContainer onClose={this.onCloseGif} />;- }return (<ErrorBoundary>{isPlaying && (<PlayQueue+ isMobile={isMobile}isLoopActive={looping}isPlaying={isPlaying}numberOfFrames={numberOfFrames}- currentDate={snappedCurrentDate}+ snappedCurrentDate={snappedCurrentDate}+ currentDate={currentDate}startDate={startDate}endDate={endDate}interval={interval}@@ -607,7 +476,7 @@ class AnimationWidget extends React.Component {)}{!isDistractionFreeModeActive && (<>- {collapsed ? this.renderCollapsedWidget() : this.renderExpandedWidget()}+ {collapsed || isMobile ? this.renderCollapsedWidget() : this.renderExpandedWidget()}</>)}</ErrorBoundary>@@ -623,7 +492,6 @@ function mapStateToProps(state) {embed,sidebar,modal,- palettes,config,map,browser,@@ -631,7 +499,7 @@ function mapStateToProps(state) {proj,} = state;const {- startDate, endDate, speed, loop, isPlaying, isActive, gifActive,+ startDate, endDate, speed, loop, isPlaying, isActive,} = animation;const {customSelected,@@ -644,16 +512,12 @@ function mapStateToProps(state) {interval,customInterval,} = date;- const activeLayers = getActiveLayers(state);+const hasSubdailyLayers = subdailyLayersActive(state);const activeLayersForProj = getAllActiveLayers(state);const hasFutureLayers = activeLayersForProj.filter((layer) => layer.futureTime).length > 0;const layerDateRange = getDateRange({}, activeLayersForProj);- const activePalettes = palettes[compare.activeString];- const hasCustomPalettes = hasCustomPaletteInActiveProjection(- activeLayersForProj,- activePalettes,- );+const minDate = new Date(config.startDate);let maxDate;if (layerDateRange && layerDateRange.end > appNow) {@@ -665,7 +529,6 @@ function mapStateToProps(state) {const { isDistractionFreeModeActive } = ui;const { isEmbedModeActive } = embed;const animationIsActive = isActive- && (browser.greaterThan.small || isEmbedModeActive)&& lodashGet(map, 'ui.selected.frameState_')&& sidebar.activeTab !== 'download' // No Animation when data download is active&& !compare.active@@ -686,8 +549,6 @@ function mapStateToProps(state) {useDelta,maxFrames,);- const { rotation } = map;- const visibleLayersForProj = lodashFilter(activeLayersForProj, 'visible');const currentDate = getSelectedDate(state);let snappedCurrentDate;if (numberOfFrames < maxFrames) {@@ -709,12 +570,14 @@ function mapStateToProps(state) {customSelected,startDate,endDate,- activePalettes,snappedCurrentDate,+ currentDate,minDate,maxDate,isActive: animationIsActive,isDistractionFreeModeActive,+ isMobile: browser.lessThan.medium,+ isLandscape: browser.orientation === 'landscape',hasFutureLayers,hasSubdailyLayers,subDailyMode,@@ -727,23 +590,11 @@ function mapStateToProps(state) {speed,isPlaying,looping: loop,- hasCustomPalettes,map,proj,- hasNonDownloadableLayer: hasNonDownloadableVisibleLayer(visibleLayersForProj),- visibleLayersForProj,promiseImageryForTime: (date) => promiseImageryForTime(state, date),- isGifActive: gifActive,- isCompareActive: compare.active,isEmbedModeActive,- isRotated: Boolean(rotation !== 0),- rotation,- hasGraticule: Boolean(- lodashGet(- lodashFind(activeLayers, { id: 'Graticule' }) || {},- 'visible',- ),- ),+ playDisabled: numberOfFrames >= maxFrames || numberOfFrames === 1,};}@@ -751,29 +602,6 @@ const mapDispatchToProps = (dispatch) => ({selectDate: (val) => {dispatch(selectDate(val));},- notify: (type, action, visibleLayersForProj) => new Promise((resolve, reject, cancel) => {- const nonDownloadableLayers = type !== 'layers' ? null : getNonDownloadableLayers(visibleLayersForProj);- const bodyComponentProps = {- bodyText: type !== 'layers' ? notificationWarnings[type] : getNonDownloadableLayerWarning(nonDownloadableLayers),- cancel: () => {- dispatch(onToggle());- },- accept: () => {- dispatch(action(nonDownloadableLayers));- dispatch(onToggle());- resolve();- },- };- dispatch(- openCustomContent(`image_download_notify_${type}`, {- headerText: 'Notify',- bodyComponent: Notify,- size: 'sm',- modalClassName: 'notify',- bodyComponentProps,- }),- );- }),onClose: () => {dispatch(onClose());},@@ -786,23 +614,6 @@ const mapDispatchToProps = (dispatch) => ({onPushLoop: () => {dispatch(toggleLooping());},- toggleGif: () => {- dispatch(toggleComponentGifActive());- },- refreshStateAfterGif: (activePalettes, rotation, isGraticule, nonDownloadableLayers) => {- if (activePalettes) {- dispatch(refreshPalettes(activePalettes));- }- if (rotation) {- dispatch(refreshRotation(rotation));- }- if (isGraticule) {- dispatch(refreshGraticule(isGraticule));- }- if (nonDownloadableLayers) {- dispatch(showLayers(nonDownloadableLayers));- }- },toggleCustomModal: (open, toggleBy) => {dispatch(toggleCustomModal(open, toggleBy));},@@ -835,30 +646,25 @@ RangeHandle.propTypes = {};AnimationWidget.propTypes = {appNow: PropTypes.object,- activePalettes: PropTypes.object,animationCustomModalOpen: PropTypes.bool,- visibleLayersForProj: PropTypes.array,snappedCurrentDate: PropTypes.object,+ currentDate: PropTypes.object,customDelta: PropTypes.number,customInterval: PropTypes.number,delta: PropTypes.number,endDate: PropTypes.object,- hasCustomPalettes: PropTypes.bool,hasFutureLayers: PropTypes.bool,- hasGraticule: PropTypes.bool,- hasNonDownloadableLayer: PropTypes.bool,hasSubdailyLayers: PropTypes.bool,interval: PropTypes.string,isActive: PropTypes.bool,isDistractionFreeModeActive: PropTypes.bool,isEmbedModeActive: PropTypes.bool,- isGifActive: PropTypes.bool,+ isMobile: PropTypes.bool,isPlaying: PropTypes.bool,- isRotated: PropTypes.bool,+ isLandscape: PropTypes.bool,looping: PropTypes.bool,maxDate: PropTypes.object,minDate: PropTypes.object,- notify: PropTypes.func,numberOfFrames: PropTypes.number,onClose: PropTypes.func,onIntervalSelect: PropTypes.func,@@ -869,10 +675,8 @@ AnimationWidget.propTypes = {onUpdateEndDate: PropTypes.func,onUpdateStartAndEndDate: PropTypes.func,onUpdateStartDate: PropTypes.func,+ playDisabled: PropTypes.bool,promiseImageryForTime: PropTypes.func,- proj: PropTypes.object,- refreshStateAfterGif: PropTypes.func,- rotation: PropTypes.number,screenWidth: PropTypes.number,selectDate: PropTypes.func,sliderLabel: PropTypes.string,@@ -880,5 +684,4 @@ AnimationWidget.propTypes = {startDate: PropTypes.object,subDailyMode: PropTypes.bool,toggleCustomModal: PropTypes.func,- toggleGif: PropTypes.func,};