Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

keep anim widget centered when togglging between subdaily/regular mode if user hasn't manually positioned it yet. center header text. always right align custom interval selector above timeline date/interval selection area. keep interval tooltip centered

Jason Kentf6776b56e2ae
diff --git a/web/css/anim.widget.css b/web/css/anim.widget.css
index b35b1671a..46d2621be 100644
--- a/web/css/anim.widget.css
+++ b/web/css/anim.widget.css
@@ -5,9 +5,6 @@
&.minimized {
bottom: 80px;
left: 10px;
- &.subdaily {
- left: 347px;
- }
}
}
.wv-animation-widget {
@@ -25,7 +22,8 @@
}
& .wv-animation-widget-header {
display: block;
- margin: 7px 0 10px 20px;
+ margin: 7px 45px 10px 5px;
+ text-align: center;
text-transform: capitalize;
& .interval-btn-container,
& .interval-btn.interval-btn-active {
@@ -34,7 +32,7 @@
}
& .wv-tooltip {
bottom: 128px;
- left: 27%;
+ left: 35%;
position: absolute;
border-bottom: 8px solid transparent;
width: 100px;
@@ -78,7 +76,7 @@
left: 113px;
}
& .wv-tooltip {
- left: 44%;
+ left: 39%;
}
}
& .wv-slider-case {
diff --git a/web/css/timeline.css b/web/css/timeline.css
index a8447e432..95f6553ca 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -348,6 +348,9 @@ button:focus {
left: 85px;
color: #fff;
border-bottom: thin solid #444;
+ &.subdaily {
+ left: 189px;
+ }
}
.custom-interval-widget i.wv-close {
diff --git a/web/js/components/timeline/custom-interval-selector/interval-selector-widget.js b/web/js/components/timeline/custom-interval-selector/interval-selector-widget.js
index 628825b23..046d9b48b 100644
--- a/web/js/components/timeline/custom-interval-selector/interval-selector-widget.js
+++ b/web/js/components/timeline/custom-interval-selector/interval-selector-widget.js
@@ -50,7 +50,7 @@ class CustomIntervalSelectorWidget extends PureComponent {
return customIntervalModalOpen && (
<div
onKeyDown={this.handleKeyPress}
- className="custom-interval-widget"
+ className={'custom-interval-widget ' + (hasSubdailyLayers ? 'subdaily' : '')}
tabIndex={0}
ref={(customIntervalWidget) => { this.customIntervalWidget = customIntervalWidget; }}
>
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.js
index 7b1d6be08..376596f8e 100644
--- a/web/js/containers/animation-widget.js
+++ b/web/js/containers/animation-widget.js
@@ -77,6 +77,9 @@ const RangeHandle = props => {
);
};
+const widgetWidth = 334;
+const subdailyWidgetWidth = 460;
+
/*
* A react component, Builds a rather specific
* interactive widget
@@ -87,7 +90,7 @@ const RangeHandle = props => {
class AnimationWidget extends React.Component {
constructor(props) {
super(props);
- const halfWidgetWidth = 115;
+ const halfWidgetWidth = (props.subDailyMode ? subdailyWidgetWidth : widgetWidth) / 2;
this.state = {
speed: props.speed,
isSliding: false,
@@ -95,11 +98,11 @@ class AnimationWidget extends React.Component {
hoverGif: false,
customIntervalModalOpen: false,
widgetPosition: {
- x: props.screenWidth / 2 - halfWidgetWidth,
+ x: (props.screenWidth / 2) - halfWidgetWidth,
y: 0
},
collapsed: false,
- collapsedWidgePosition: { x: 0, y: 0 }
+ collapsedWidgetPosition: { x: 0, y: 0 }
};
this.onDateChange = this.onDateChange.bind(this);
this.onIntervalSelect = this.onIntervalSelect.bind(this);
@@ -112,6 +115,25 @@ class AnimationWidget extends React.Component {
this.onExpandedDrag = this.onExpandedDrag.bind(this);
}
+ componentDidUpdate(prevProps, prevState) {
+ const { widgetPosition } = this.state;
+ const { subDailyMode, screenWidth } = this.props;
+ const subdailyChange = subDailyMode !== prevProps.subDailyMode;
+ const origYPosition = widgetPosition.y === 0;
+
+ // If toggling between subdaily/regular mode and widget hasn't been manually moved
+ // yet, try to keep it centered
+ if (subdailyChange && origYPosition) {
+ const useWidth = subDailyMode ? subdailyWidgetWidth : widgetWidth;
+ this.setState({
+ widgetPosition: {
+ x: (screenWidth / 2) - (useWidth / 2),
+ y: 0
+ }
+ });
+ }
+ }
+
static getDerivedStateFromProps(props, state) {
if (props.speed !== state.speed && !state.isSliding) {
return { speed: props.speed };
@@ -146,7 +168,7 @@ class AnimationWidget extends React.Component {
onCollapsedDrag(e, position) {
const { x, y } = position;
- this.setState({ collapsedWidgePosition: { x, y } });
+ this.setState({ collapsedWidgetPosition: { x, y } });
};
getPromise(bool, type, action, title) {
@@ -368,7 +390,7 @@ class AnimationWidget extends React.Component {
<Draggable
bounds="body"
onStart={this.handleDragStart}
- position={this.state.collapsedWidgePosition}
+ position={this.state.collapsedWidgetPosition}
onDrag={this.onCollapsedDrag}>
<div
className={'wv-animation-widget-wrapper minimized' + (hasSubdailyLayers ? ' subdaily' : '')}>