Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Load animation from URL and add animation play transistion to story

ZachTRicedde4173ee0bf
diff --git a/config/default/common/config/wv.json/stories.json b/config/default/common/config/wv.json/stories.json
index 96f3b4132..2fa66bfe8 100644
--- a/config/default/common/config/wv.json/stories.json
+++ b/config/default/common/config/wv.json/stories.json
@@ -48,8 +48,8 @@
"description": "step004.html",
"transition": [
{
- "element": "",
- "action": ""
+ "element": "animation",
+ "action": "play"
}
],
"stepLink": "p=geographic&l=VIIRS_SNPP_CorrectedReflectance_TrueColor,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden),Reference_Labels,Reference_Features(hidden),Coastlines(hidden)&t=2018-09-14-T00%3A00%3A00Z&z=3&t1=2018-09-19-T00%3A00%3A00Z&v=-105.3766105876101,15.639834408938874,-54.1539543376101,48.616396908938874&ab=on&as=2018-08-31T00%3A00%3A00Z&ae=2018-09-14T00%3A00%3A00Z&av=10&al=false"
diff --git a/web/js/animation/model.js b/web/js/animation/model.js
index e9b5e0a81..75a8c82a2 100644
--- a/web/js/animation/model.js
+++ b/web/js/animation/model.js
@@ -71,6 +71,32 @@ export function animationModel(models, config) {
}
};
+ /*
+ * Activates state object
+ *
+ * @method activate
+ * @static
+ *
+ * @returns {void}
+ *
+ */
+ self.activate = function() {
+ self.rangeState.state = 'on';
+ };
+
+ /*
+ * Deactivate state object
+ *
+ * @method deactivate
+ * @static
+ *
+ * @returns {void}
+ *
+ */
+ self.deactivate = function() {
+ self.rangeState.state = 'off';
+ };
+
/*
* saves animation state to permalink
*
diff --git a/web/js/components/tour/modal-tour-in-progress.js b/web/js/components/tour/modal-tour-in-progress.js
index 4686beaf8..60954f785 100644
--- a/web/js/components/tour/modal-tour-in-progress.js
+++ b/web/js/components/tour/modal-tour-in-progress.js
@@ -67,63 +67,79 @@ class ModalInProgress extends React.Component {
}
stepLink(currentStory, currentStepIndex) {
- var state, stepLink;
+ var prevState, currentState, prevStepLink, currentStepLink, stepTransition;
var config = this.props.config;
var models = this.props.models;
var errors = [];
// Get steplink from the currentstory's current step
currentStepIndex = (currentStepIndex - 1).toString().padStart(0, '0');
- stepLink = currentStory.steps[currentStepIndex]['stepLink'];
+ if (currentStory.steps[currentStepIndex - 1]) prevStepLink = currentStory.steps[currentStepIndex - 1]['stepLink'];
+ currentStepLink = currentStory.steps[currentStepIndex]['stepLink'];
+ stepTransition = currentStory.steps[currentStepIndex]['transition'];
// TESTING HERE:
- // stepLink = 'p=arctic&l=VIIRS_SNPP_CorrectedReflectance_TrueColor(hidden),MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,AMSR2_Snow_Water_Equivalent,Reference_Labels(hidden),Reference_Features(hidden),Coastlines&t=2018-11-06-T00%3A00%3A00Z&z=3&v=-8382951.387251401,-7726888.724782713,8382951.387251401,7726888.724782713&r=-38.5164';
- state = util.fromQueryString(stepLink);
-
- // Parse the step link
- projectionParser(state, errors, config);
- layerParser(state, errors, config);
- dateParser(state, errors, config);
- mapParser(state, errors, config);
- palettes.parse(state, errors, config);
- tourParser(state, errors, config);
+ // stepLink = 'p=geographic&l=VIIRS_SNPP_CorrectedReflectance_TrueColor,MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor(hidden),Reference_Labels,Reference_Features(hidden),Coastlines(hidden)&t=2018-08-31-T00%3A00%3A00Z&z=3&t1=2018-09-19-T00%3A00%3A00Z&v=-113.05825121261012,-7.7039155910611115,-10.61293871261011,58.24920940893889&ab=on&as=2018-08-31T00%3A00%3A00Z&ae=2018-09-14T00%3A00%3A00Z&av=10&al=false';
+ prevState = util.fromQueryString(prevStepLink);
+ currentState = util.fromQueryString(currentStepLink);
+
+ // Parse the previous step link
+ projectionParser(prevState, errors, config);
+ layerParser(prevState, errors, config);
+ dateParser(prevState, errors, config);
+ mapParser(prevState, errors, config);
+ palettes.parse(prevState, errors, config);
+ tourParser(prevState, errors, config);
if (config.features.dataDownload) {
- dataParser(state, errors, config);
+ dataParser(prevState, errors, config);
}
if (config.features.animation) {
- animationParser(state, errors, config);
+ animationParser(prevState, errors, config);
+ }
+
+ // Parse the current step link
+ projectionParser(currentState, errors, config);
+ layerParser(currentState, errors, config);
+ dateParser(currentState, errors, config);
+ mapParser(currentState, errors, config);
+ palettes.parse(currentState, errors, config);
+ tourParser(currentState, errors, config);
+ if (config.features.dataDownload) {
+ dataParser(currentState, errors, config);
+ }
+ if (config.features.animation) {
+ animationParser(currentState, errors, config);
}
// Create a query string again to be passed to the URL
- stepLink = models.link.toQueryString(state);
+ currentStepLink = models.link.toQueryString(currentState);
// Push query string to browser url
if (util.browser.history) {
window.history.pushState(
'',
'@OFFICIAL_NAME@',
- '?' + stepLink
+ '?' + currentStepLink
);
}
// Process the state of the application
- this.selectLink(state);
+ this.selectLink(currentState, prevState, stepTransition);
}
- selectLink(state) {
+ selectLink(currentState, prevState, stepTransition) {
// var errors = [];
// var config = this.props.config;
var models = this.props.models;
var ui = this.props.ui;
// var map = ui.map.selected;
-
// Map Projection, Map Date
- models.link.load(state);
+ models.link.load(currentState);
// Map Rotation (Animated)
- if (state.p === 'arctic' || state.p === 'antarctic') {
- if (!isNaN(state.r)) {
- let rotation = state.r * (Math.PI / 180.0);
+ if (currentState.p === 'arctic' || currentState.p === 'antarctic') {
+ if (!isNaN(currentState.r)) {
+ let rotation = currentState.r * (Math.PI / 180.0);
ui.map.selected.getView().animate({
duration: 800,
rotation: rotation
@@ -132,12 +148,12 @@ class ModalInProgress extends React.Component {
}
// Map Zoom & View (Animated)
- if (state.v) {
+ if (currentState.v) {
// No animation option
- // ui.map.selected.getView().fit(state.v, ui.map.selected.getSize());
+ // ui.map.selected.getView().fit(currentState.v, ui.map.selected.getSize());
// Animate to extent & zoom
- let extent = state.v;
+ let extent = currentState.v;
var coordinateX = extent[0] + (extent[2] - extent[0]) / 2;
var coordinateY = extent[1] + (extent[3] - extent[1]) / 2;
let coordinates = [coordinateX, coordinateY];
@@ -149,14 +165,42 @@ class ModalInProgress extends React.Component {
});
}
- // var comparisonOn = state.ca;
- // var timeA = state.t;
- // var timeB = state.t1;
- // var layersA = state.l;
- // // var layersB = state.l1;
- // var projection = state.p;
- // var view = state.v;
- // var zoom = state.z;
+ // Animation
+ if (currentState.ab) {
+ if (currentState.ab === 'on') {
+ models.anim.activate();
+ } else {
+ models.anim.deactivate();
+ }
+ }
+ if (prevState.ab !== currentState.ab) {
+ ui.anim.widget.toggleAnimationWidget();
+ }
+ if (stepTransition.element === 'animation' && stepTransition.action === 'play') {
+ ui.anim.widget.onPressPlay();
+ }
+ // }
+ // if (currentState.as && currentState.ae) {
+ // if (currentState.ae.length >= 10 && currentState.as.length >= 10) {
+ // self.rangeState.startDate = currentState.as;
+ // self.rangeState.endDate = currentState.ae;
+ // }
+ // }
+ // if (currentState.av) {
+ // self.rangeState.speed = Number(currentState.av);
+ // }
+ // if (currentState.al) {
+ // self.rangeState.loop = Boolean(currentState.al);
+ // }
+
+ // var comparisonOn = currentState.ca;
+ // var timeA = currentState.t;
+ // var timeB = currentState.t1;
+ // var layersA = currentState.l;
+ // // var layersB = currentState.l1;
+ // var projection = currentState.p;
+ // var view = currentState.v;
+ // var zoom = currentState.z;
// // Set Projection
// if (projection) models.proj.select(projection);
@@ -195,11 +239,9 @@ class ModalInProgress extends React.Component {
// if (layer) models.layers.remove(layer.id);
// });
- // console.log(JSON.stringify(state, null, 4));
-
- // console.log(JSON.stringify(state, null, 4));
-
+ // console.log(JSON.stringify(currentState, null, 4));
+ // console.log(JSON.stringify(currentState, null, 4));
}
render() {