Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

limit number of frames calculation with max to save cpu on large ranges

Edward Platocff7b5fe29e1
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.js
index ccb1d26e1..59400ceed 100644
--- a/web/js/containers/animation-widget.js
+++ b/web/js/containers/animation-widget.js
@@ -79,6 +79,7 @@ const RangeHandle = props => {
const widgetWidth = 334;
const subdailyWidgetWidth = 460;
+const maxFrames = 40;
/*
* A react component, Builds a rather specific
@@ -200,7 +201,7 @@ class AnimationWidget extends React.Component {
endDate
} = this.zeroDates();
- if (numberOfFrames >= 40) {
+ if (numberOfFrames >= maxFrames) {
return;
}
@@ -374,7 +375,7 @@ class AnimationWidget extends React.Component {
const { numberOfFrames } = this.props;
const { hoverGif } = this.state;
const elemExists = document.querySelector('#create-gif-button');
- const showTooltip = elemExists && hoverGif && numberOfFrames >= 40;
+ const showTooltip = elemExists && hoverGif && numberOfFrames >= maxFrames;
return (
<Tooltip
placement="right"
@@ -436,7 +437,7 @@ class AnimationWidget extends React.Component {
hasSubdailyLayers
} = this.props;
const { speed } = this.state;
- const gifDisabled = numberOfFrames >= 40;
+ const gifDisabled = numberOfFrames >= maxFrames;
return (
<Draggable
bounds="body"
@@ -669,7 +670,8 @@ function mapStateToProps(state) {
startDate,
endDate,
timeScaleFromNumberKey[useInterval],
- customSelected && customDelta ? customDelta : delta
+ customSelected && customDelta ? customDelta : delta,
+ maxFrames
);
return {
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 6f13084ff..d97527e60 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -444,13 +444,17 @@ export default (function(self) {
return newDate;
};
- self.getNumberOfDays = function(start, end, interval, increment) {
+ self.getNumberOfDays = function(start, end, interval, increment, maxToCheck) {
increment = increment || 1;
var i = 1;
var currentDate = start;
while (currentDate < end) {
i++;
currentDate = self.dateAdd(currentDate, interval, increment);
+ // if checking for a max number limit, break out after reaching it
+ if (maxToCheck && i >= maxToCheck) {
+ return i;
+ }
}
return i;
};