Interactive interface for browsing global, full-resolution satellite imagery
Add animation redux rendering #1623 #1622
Benjamin King33d2d232c904
diff --git a/web/js/components/animation-widget/play-queue.js b/web/js/components/animation-widget/play-queue.jsindex e3f6aa51e..83947a35e 100644--- a/web/js/components/animation-widget/play-queue.js+++ b/web/js/components/animation-widget/play-queue.js@@ -205,6 +205,7 @@ class PlayAnimation extends React.Component {**/checkQueue(bufferLength, index) {+<<<<<<< HEADconst {startDate,endDate,@@ -213,13 +214,20 @@ class PlayAnimation extends React.Component {queueLength,maxQueueLength} = this.props;+=======+ const { startDate, endDate, hasCustomPalettes, canPreloadAll } = this.props;+>>>>>>> Add animation redux rendering #1623 #1622var currentDate = util.parseDateUTC(index);var lastToQueue = this.getLastBufferDateStr(currentDate,startDate,endDate);+<<<<<<< HEADvar nextDate = this.nextDate(currentDate);+=======++>>>>>>> Add animation redux rendering #1623 #1622if (!this.preloadedArray[0] && !this.inQueueObject[index]) {this.initialPreload(currentDate, startDate, endDate, lastToQueue);} else if (@@ -230,12 +238,16 @@ class PlayAnimation extends React.Component {) {// if last preload date doesn't existthis.addItemToQueue(currentDate, startDate, endDate);+<<<<<<< HEAD} else if (hasCustomPalettes &&this.preloadedArray[0] &&!this.inQueueObject[nextDate] &&queueLength > maxQueueLength) {+=======+ } else if (hasCustomPalettes && this.preloadedArray[0]) {+>>>>>>> Add animation redux rendering #1623 #1622this.customQueuer(currentDate, startDate, endDate);}}@@ -252,7 +264,10 @@ class PlayAnimation extends React.Component {clearCache() {this.preloadObject = {};this.preloadedArray = [];+<<<<<<< HEADthis.inQueueObject = {};+=======+>>>>>>> Add animation redux rendering #1623 #1622}/*@@ -293,11 +308,21 @@ class PlayAnimation extends React.Component {if (nextDate > endDate) {nextDate = startDate;}+<<<<<<< HEADnextDateStr = util.toISOStringSeconds(nextDate);if (!this.preloadObject[nextDateStr] &&!this.inQueueObject[nextDateStr] &&!this.state.isPlaying+=======++ nextDateStr = util.toISOStringSeconds(nextDate);++ if (+ !this.preloadedArray[nextDateStr] &&+ !this.inQueueObject[nextDateStr] &&+ !this.state.isplaying+>>>>>>> Add animation redux rendering #1623 #1622) {this.clearCache();this.checkQueue(this.props.queueLength, this.currentPlayingDate);@@ -359,8 +384,14 @@ class PlayAnimation extends React.Component {**/getNextBufferDate(currentDate, startDate, endDate) {+<<<<<<< HEADconst strDate = this.preloadedArray[this.preloadedArray.length - 1];var lastInBuffer = util.parseDateUTC(strDate);+=======+ var lastInBuffer = util.parseDateUTC(+ this.preloadedArray[this.preloadedArray.length - 1]+ );+>>>>>>> Add animation redux rendering #1623 #1622var nextDate = this.nextDate(lastInBuffer);if (lastInBuffer >= endDate || nextDate > endDate) {return startDate;@@ -427,6 +458,8 @@ class PlayAnimation extends React.Component {return true;}i++;+<<<<<<< HEAD+=======}return false;}@@ -442,6 +475,60 @@ class PlayAnimation extends React.Component {* @returns {object} JS Date**/+ addDate(date) {+ const { layers, promiseImageryForTime } = this.props;+ const activeLayers = getLayersActiveAtDate(layers, date);+ const strDate = util.toISOStringSeconds(date);+ if (this.inQueueObject[strDate] || this.preloadObject[strDate]) return;+ this.addToInQueue(date);+ this.queue+ .add(function() {+ return promiseImageryForTime(date, activeLayers);+ })+ .then(date => {+ this.preloadObject[strDate] = date;+ delete this.inQueueObject[strDate];+ this.shiftCache();+ this.checkQueue(this.queueLength, this.currentPlayingDate);+ this.checkShouldPlay();+ });+ }+ /*+ * removes loader and starts the+ * animation+ *+ * @method play+ * @static+ *+ * @param index {string} date string+ *+ * @returns {void}+ *+ */+ play(dateStr) {+ const { togglePlaying } = this.props;+ if (!this.state.isPlaying) this.setState({ isPlaying: true });++ this.animate(dateStr);+ if (document.hidden) {+ togglePlaying();+>>>>>>> Add animation redux rendering #1623 #1622+ }+ return false;+ }+ /*+<<<<<<< HEAD+ * Gets next date based on current+ * increments+ *+ * @method nextDate+ * @static+ *+ * @param date {object} JS date obj+ *+ * @returns {object} JS Date+ *+ */addDate(date) {const { layers, promiseImageryForTime } = this.props;const activeLayers = getLayersActiveAtDate(layers, date);@@ -526,6 +613,45 @@ class PlayAnimation extends React.Component {clearInterval(this.interval);this.setState({ isPlaying: false });}+=======+ * function that loops through frames+ * at a specified time interval+ *+ * @method animate+ * @static+ *+ * @param index {string} Date string+ * @returns {void}+ *+ */+ animate(index) {+ const { selectDate, endDate, queueLength, speed } = this.props;+ var currentPlayingDate = index;+ var currentPlayingDateJSDate;+ var player = () => {+ this.shiftCache();+ this.checkQueue(queueLength, currentPlayingDate);+ selectDate(util.parseDateUTC(currentPlayingDate));+ this.pastDates[currentPlayingDate] = util.parseDateUTC(+ currentPlayingDate+ ); // played record+ this.currentPlayingDate = currentPlayingDate;+ currentPlayingDate = util.toISOStringSeconds(+ this.nextDate(util.parseDateUTC(currentPlayingDate))+ );+ currentPlayingDateJSDate = util.parseDateUTC(currentPlayingDate);+ if (currentPlayingDateJSDate > endDate) {+ clearInterval(this.interval);+ return this.checkShouldLoop(currentPlayingDateJSDate);+ }+ if (!this.preloadObject[currentPlayingDate]) {+ clearInterval(this.interval);+ this.setState({ isPlaying: false });+ this.shiftCache();+ return this.checkQueue(queueLength, this.currentPlayingDate);+ }++>>>>>>> Add animation redux rendering #1623 #1622this.checkQueue(queueLength, this.currentPlayingDate);this.interval = setTimeout(player, 1000 / this.props.speed);};diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 6ec8e890a..a16dc675d 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -29,14 +29,26 @@ import {import { toggleActiveCompareState } from '../../modules/compare/actions';import {onActivate as openAnimation,+<<<<<<< HEADonClose as closeAnimation,changeStartDate,changeEndDate} from '../../modules/animation/actions';+<<<<<<< HEAD+=======+import { timeScaleFromNumberKey, timeScaleToNumberKey } from '../../modules/date/constants';+=======+ onClose as closeAnimation+} from '../../modules/animation/actions';+>>>>>>> Add animation redux rendering #1623 #1622import {timeScaleFromNumberKey,timeScaleToNumberKey} from '../../modules/date/constants';+<<<<<<< HEAD+=======+>>>>>>> Add animation redux rendering #1623 #1622+>>>>>>> Add animation redux rendering #1623 #1622const ANIMATION_DELAY = 500;@@ -241,8 +253,12 @@ class Timeline extends React.Component {animStartLocationDate,animEndLocationDate,isAnimationWidgetOpen,+<<<<<<< HEADanimationDisabled,hideTimeline+=======+ animationDisabled+>>>>>>> Add animation redux rendering #1623 #1622} = this.props;return dateFormatted ? (<ErrorBoundary>@@ -265,12 +281,23 @@ class Timeline extends React.Component {</div><div id="zoom-buttons-group"><TimeScaleIntervalChange+<<<<<<< HEAD+=======+<<<<<<< HEAD+ setTimeScaleIntervalChangeUnit={this.setTimeScaleIntervalChangeUnit}+ customIntervalZoomLevel={timeScaleFromNumberKey[customIntervalZoomLevel]}+=======+>>>>>>> Add animation redux rendering #1623 #1622setTimeScaleIntervalChangeUnit={this.setTimeScaleIntervalChangeUnit}customIntervalZoomLevel={timeScaleFromNumberKey[customIntervalZoomLevel]}+<<<<<<< HEAD+=======+>>>>>>> Add animation redux rendering #1623 #1622+>>>>>>> Add animation redux rendering #1623 #1622customSelected={customSelected}customDelta={customIntervalValue}timeScaleChangeUnit={timeScaleChangeUnit}@@ -293,10 +320,14 @@ class Timeline extends React.Component {</div><divid="timeline-footer"+<<<<<<< HEADstyle={{display:this.state.timelineHidden || hideTimeline ? 'none' : 'block'}}+=======+ style={{ display: this.state.timelineHidden ? 'none' : 'block' }}+>>>>>>> Add animation redux rendering #1623 #1622><div id="wv-animation-widet-case">{isAnimationWidgetOpen ? <AnimationWidget /> : null}@@ -363,8 +394,12 @@ function mapStateToProps(state) {browser,date,animation,+<<<<<<< HEADsidebar,modal+=======+ sidebar+>>>>>>> Add animation redux rendering #1623 #1622} = state;let {customSelected,@@ -452,11 +487,16 @@ function mapStateToProps(state) {timelineEndDateLimit,leftArrowDisabled,rightArrowDisabled,+<<<<<<< HEADhideTimeline:(modal.isOpen && modal.id === 'TOOLBAR_SNAPSHOT') || animation.gifActive,animationDisabled:!lodashGet(map, 'ui.selected.frameState_') ||sidebar.activeTab === 'download'+=======+ animationDisabled:+ !legacy.map.selectedMap || !legacy.map.selectedMap.frameState_ || sidebar.activeTab === 'download'+>>>>>>> Add animation redux rendering #1623 #1622};}diff --git a/web/js/modules/animation/util.js b/web/js/modules/animation/util.jsindex fcfc95b64..d5f33b6ea 100644--- a/web/js/modules/animation/util.js+++ b/web/js/modules/animation/util.js@@ -1,7 +1,10 @@import { round as lodashRound } from 'lodash';import canvg from 'canvg-browser';import util from '../../util/util';+<<<<<<< HEADimport update from 'immutability-helper';+=======+>>>>>>> Add animation redux rendering #1623 #1622export function getStampProps(stampWidthRatio,diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.jsindex 8103d664e..d158b57f3 100644--- a/web/js/modules/layers/util.js+++ b/web/js/modules/layers/util.js@@ -399,4 +399,4 @@ export function mapLocationToLayerState(});}return stateFromLocation;-}+}\ No newline at end of file