-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation refactor #377
Merged
Merged
Animation refactor #377
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a3fcfb6
Don't pass around controls, instead directly pass numDates
trvrb ef476f8
Remove unused colorBy
trvrb 729fca6
Avoid unnecessary triplication in getLatLongs
trvrb 6986d7b
Duplicate map rather than triplicate
trvrb 3bf0efd
Cleanup names and shelve off interchange into a function
trvrb e3ac4ed
Cleanup code to shelve out a maybeGetTransmissionPair function
trvrb c3b8bba
dispatch play/pause button before map animation starts
jameshadfield 014ae03
remove unused transmissionPathLengths calcs. Should improve speed.
jameshadfield 7e6b426
fix import statements
jameshadfield 2bc6af7
only import lodash functions which are actually used
jameshadfield 6ac79a6
try / catch to fix bezier errors. Closes #375
jameshadfield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
/*eslint max-len: 0*/ | ||
import React from "react"; | ||
import d3 from "d3"; | ||
import _ from "lodash"; | ||
import { connect } from "react-redux"; | ||
import Card from "../framework/card"; | ||
import {changeDateFilter} from "../../actions/treeProperties"; | ||
|
@@ -25,18 +24,16 @@ import { | |
// datasetGuid: state.tree.datasetGuid, | ||
treeVersion: state.tree.version, | ||
treeLoaded: state.tree.loaded, | ||
controls: state.controls, | ||
splitTreeAndMap: state.controls.splitTreeAndMap, | ||
nodes: state.tree.nodes, | ||
nodeColors: state.tree.nodeColors, | ||
visibility: state.tree.visibility, | ||
visibilityVersion: state.tree.visibilityVersion, | ||
metadata: state.metadata.metadata, | ||
browserDimensions: state.browserDimensions.browserDimensions, | ||
colorScaleVersion: state.controls.colorScale.version, | ||
colorBy: state.controls.colorBy, | ||
map: state.map, | ||
geoResolution: state.controls.geoResolution, | ||
// mapAnimationStartDate: state.controls.mapAnimationStartDate, | ||
mapAnimationDurationInMilliseconds: state.controls.mapAnimationDurationInMilliseconds, | ||
mapAnimationCumulative: state.controls.mapAnimationCumulative, | ||
mapAnimationPlayPauseButton: state.controls.mapAnimationPlayPauseButton, | ||
|
@@ -138,7 +135,7 @@ class Map extends React.Component { | |
} | ||
doComputeResponsive(nextProps) { | ||
return computeResponsive({ | ||
horizontal: nextProps.browserDimensions.width > twoColumnBreakpoint && (this.props.controls && this.props.controls.splitTreeAndMap) ? .5 : 1, | ||
horizontal: nextProps.browserDimensions.width > twoColumnBreakpoint && (this.props.splitTreeAndMap) ? .5 : 1, | ||
vertical: 1.0, /* if we are in single column, full height */ | ||
browserDimensions: nextProps.browserDimensions, | ||
sidebar: nextProps.sidebar, | ||
|
@@ -189,7 +186,8 @@ class Map extends React.Component { | |
this.state.d3DOMNode, | ||
this.state.map, | ||
this.props.nodes, | ||
this.props.controls | ||
calendarToNumeric(this.props.dateFormat, this.props.dateScale, this.props.dateMin), | ||
calendarToNumeric(this.props.dateFormat, this.props.dateScale, this.props.dateMax) | ||
); | ||
|
||
/* Set up leaflet events */ | ||
|
@@ -243,7 +241,13 @@ class Map extends React.Component { | |
} | ||
respondToLeafletEvent(leafletEvent) { | ||
if (leafletEvent.type === "moveend") { /* zooming and panning */ | ||
updateOnMoveEnd(this.state.d3elems, this.latLongs(), this.props.controls, this.props.nodes); | ||
updateOnMoveEnd( | ||
this.state.d3elems, | ||
this.latLongs(), | ||
calendarToNumeric(this.props.dateFormat, this.props.dateScale, this.props.dateMin), | ||
calendarToNumeric(this.props.dateFormat, this.props.dateScale, this.props.dateMax), | ||
this.props.nodes | ||
); | ||
} | ||
} | ||
getGeoRange() { | ||
|
@@ -279,7 +283,13 @@ class Map extends React.Component { | |
) { | ||
const latLongs = this.latLongs(); /* can't run if noMap || noDemes */ | ||
if (latLongs === null) { return; } | ||
updateVisibility(this.state.d3elems, latLongs, this.props.controls, this.props.nodes); | ||
updateVisibility( | ||
this.state.d3elems, | ||
latLongs, | ||
calendarToNumeric(this.props.dateFormat, this.props.dateScale, this.props.dateMin), | ||
calendarToNumeric(this.props.dateFormat, this.props.dateScale, this.props.dateMax), | ||
this.props.nodes | ||
); | ||
} | ||
} | ||
// maybeAnimateDemesAndTransmissions() { | ||
|
@@ -292,7 +302,6 @@ class Map extends React.Component { | |
this.props.visibility, | ||
this.props.metadata, | ||
this.state.map, | ||
this.props.colorBy, | ||
this.props.geoResolution, | ||
this.props.mapTriplicate, | ||
this.props.nodeColors, | ||
|
@@ -306,8 +315,8 @@ class Map extends React.Component { | |
|
||
/* initial map bounds */ | ||
if (this.props.mapTriplicate === true) { | ||
southWest = L.latLng(-70, -540); | ||
northEast = L.latLng(80, 540); | ||
southWest = L.latLng(-70, -360); | ||
northEast = L.latLng(80, 360); | ||
} else { | ||
southWest = L.latLng(-70, -180); | ||
northEast = L.latLng(80, 180); | ||
|
@@ -414,11 +423,11 @@ class Map extends React.Component { | |
* ANIMATE MAP (AND THAT LINE ON TREE) | ||
*****************************************/ | ||
if (this.props.mapAnimationPlayPauseButton === "Play") { | ||
this.animateMap(); | ||
this.props.dispatch({ | ||
type: MAP_ANIMATION_PLAY_PAUSE_BUTTON, | ||
data: "Pause" | ||
}); | ||
this.animateMap(); | ||
} else { | ||
clearInterval(window.NEXTSTRAIN.mapAnimationLoop) | ||
window.NEXTSTRAIN.mapAnimationLoop = null; | ||
|
@@ -432,7 +441,7 @@ class Map extends React.Component { | |
resetAnimation() { | ||
clearInterval(window.NEXTSTRAIN.mapAnimationLoop); | ||
window.NEXTSTRAIN.mapAnimationLoop = null; | ||
this.props.dispatch(changeDateFilter({newMin: this.props.controls.absoluteDateMin, newMax: this.props.controls.absoluteDateMax})); | ||
this.props.dispatch(changeDateFilter({newMin: this.props.absoluteDateMin, newMax: this.props.absoluteDateMax})); | ||
this.props.dispatch({ | ||
type: MAP_ANIMATION_PLAY_PAUSE_BUTTON, | ||
data: "Play" | ||
|
@@ -488,38 +497,6 @@ class Map extends React.Component { | |
} | ||
}, animationTick); | ||
|
||
// controls: state.controls, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment can stay, I will clean up on the requestAnimationFrame pass |
||
// this.props.dateMin //"2013-06-28" | ||
// this.props.dateMax //"2016-11-21" | ||
// this.props.absoluteDateMin //"2013-06-29" | ||
// this.props.absoluteDateMax //"2016-11-21" | ||
// export const CHANGE_DATE_MIN = "CHANGE_DATE_MIN"; | ||
// export const CHANGE_DATE_MAX = "CHANGE_DATE_MAX"; | ||
// export const CHANGE_ABSOLUTE_DATE_MIN = "CHANGE_ABSOLUTE_DATE_MIN"; | ||
// export const CHANGE_ABSOLUTE_DATE_MAX = "CHANGE_ABSOLUTE_DATE_MAX"; | ||
|
||
// =======OLD RAF CODE======= | ||
// let start = null; | ||
// | ||
// const step = (timestamp) => { | ||
// if (!start) start = timestamp; | ||
// | ||
// let progress = timestamp - start; | ||
// | ||
// this.props.dispatch({ | ||
// type: MAP_ANIMATION_TICK, | ||
// data: { | ||
// progress | ||
// } | ||
// }) | ||
// | ||
// if (progress < globals.mapAnimationDurationInMilliseconds) { | ||
// window.requestAnimationFrame(step); | ||
// } else { | ||
// this.props.dispatch({ type: MAP_ANIMATION_END }) | ||
// } | ||
// } | ||
// window.requestAnimationFrame(step); | ||
} | ||
render() { | ||
// clear layers - store all markers in map state https://github.com/Leaflet/Leaflet/issues/3238#issuecomment-77061011 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way cleaner