-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Fixes to the play slider #5675
Fixes to the play slider #5675
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5675 +/- ##
==========================================
- Coverage 63.49% 63.48% -0.02%
==========================================
Files 360 360
Lines 22889 22930 +41
Branches 2549 2559 +10
==========================================
+ Hits 14534 14556 +22
- Misses 8340 8359 +19
Partials 15 15
Continue to review full report at Codecov.
|
} else { | ||
values = newValues; | ||
} | ||
this.setState({ values }); |
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.
- Avoid negation if not necessary
this.setState({
values: Array.isArray(newValues)
? newValues
: [newValues, newValues + this.props.step]
});
@@ -21,3 +20,7 @@ | |||
color: #b3b3b3; | |||
margin-right: 5px; | |||
} | |||
|
|||
div.tooltip.tooltip-main.top.in { | |||
margin-left: 0 !important; |
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.
Is there a way to override without using !important
?
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.
I think we can use a more specific selector, let me take a look.
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.
@kristw, the 3rd-party library bootstrap-slider
is setting the left margin directly in the DOM using style=
, so it overrules any CSS rules. I only got it to work using !important
.
@@ -87,7 +89,11 @@ export default class PlaySlider extends React.PureComponent { | |||
if (this.props.disabled) { | |||
return; | |||
} | |||
let values = this.props.values.map(value => value + this.increment); | |||
let values = this.props.values; | |||
if (!Array.isArray(values)) { |
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.
The code in if
block is not used? Because values
is set again right after the block.
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.
Ah, good point, will fix.
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.
It can be confusing if values
is the new one or the old one.
I prefer to avoid using let
and try not to mutate variable if not necessary.
const { start, end, step, values, disabled } = this.props;
if (disabled) {
return;
}
const newValues = (Array.isArray(values) ? values : [values, values + step])
.map(v => v + this.increment);
// What does cr stand for?
const cr = (newValues[1] > end) ? (newValues[0] - start) : 0;
this.props.onChange(cr === 0 ? newValues : newValues.map(v => v - cr));
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.
CR is carriage return — how much the controls move back once they hit the end of the slider. I'll make the code more clear, thanks!
@@ -46,7 +58,8 @@ export default class AnimatableDeckGLContainer extends React.Component { | |||
end={this.props.end} | |||
step={this.props.step} | |||
values={this.state.values} | |||
onChange={newValues => this.setState({ values: newValues })} | |||
range={!this.props.aggregation} |
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.
Use deconstruction from this.props
to avoid having this.props.xxx
multiple time.
const { end, step, aggregation } = this.props;
const { values } = this.state;
@@ -116,7 +122,8 @@ export default class PlaySlider extends React.PureComponent { | |||
</Col> | |||
<Col md={11} className="padded"> | |||
<ReactBootstrapSlider | |||
value={this.props.values} | |||
value={this.props.range ? this.props.values : this.props.values[0]} |
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.
Use deconstruction for this.props
const { range, values } = this.props;
height: 20px; | ||
width: 100%; | ||
width: 90%; |
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.
Try wrapping PlaySlider in <div style="position: relative">
It will be better to have the slider at full width rather than 90%
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.
+1
@kristw this is how it looks now: |
LGTM |
1 similar comment
LGTM |
* Fixes to the play slider * Address comments * Make CSS rules more strict * Fix CSS and improve code (cherry picked from commit bcc0954)
* Fixes to the play slider * Address comments * Make CSS rules more strict * Fix CSS and improve code (cherry picked from commit bcc0954)
* Fixes to the play slider * Address comments * Make CSS rules more strict * Fix CSS and improve code
Some fixes to the CSS:
More importantly, added a props called
aggregation
toAnimatableDeckGLContainer
. When true, the play slider will not allow selecting a wider period than the time granularity. This means that for the scatter plot or GeoJSON visualizations (which show just features) the user can select a wider period and see all the features combined. But for screengrid this doesn't make sense, so it users will be able to only step through the granularity.