-
Notifications
You must be signed in to change notification settings - Fork 3
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
Slider #2 #329
base: master
Are you sure you want to change the base?
Conversation
008d77f
to
ab7f3d4
Compare
src/ts/utils/slider.ts
Outdated
step: number | ||
) => { | ||
const totalRange = max - min; | ||
return (step - min) / totalRange; |
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.
You should guard this in case the value is zero.
src/ts/components/forms/slider.tsx
Outdated
); | ||
|
||
const initialValue = { | ||
from: props.initialValue ? props.initialValue.from : min, |
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 initial value stuff should probably do some smart checking if the min is larger than the max stuff. Same for the min and max values themselves. Otherwise we may end up with a weird inverted slider.
Thinking about it... we may also have issues with negative numbers. What happens if the min is -100
and the max is 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.
Agree we should check if from < to and probably also if initial values are within range 👍
I checked and slider with negative values works absolutely fine.
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.
Don't think we can check if min
is smaller than max
using TS
so have just made sure the initialValues
are correct
Co-Authored-By: Jake 'Sid' Smith <jake@dabapps.com>
Co-Authored-By: Jake 'Sid' Smith <jake@dabapps.com>
Math.ceil won't work when the value is an integer
Which can be used in onHandleFrom and onHandleTo
Instead of onChange at end of slider movement
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.
We should be able to check and handle from/to and min/max being smaller than one another, or dividing by zero.
Also, what I meant when we discussed this in Slack was that the onChange
should be what is now called onSlide
, as this is standard for inputs. Just that it shouldn't only be called when released, but called every time the value changes.
Finally: I didn't initially check the markup of the component, but I now realize I don't know why there is a background element, let alone 2. The background color should just be applied to the wrapper? And we could remove the getControlStyle
logic completely if the controls are just rendered inside the range (position absoluted to either side).
transform: translate(-30%, -50%); | ||
text-align: center; | ||
background-color: @slider-control-popover-background; | ||
font-size: 11px; |
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.
font-size: 11px; | |
font-size: @font-size-small; |
top: -1.4em; | ||
width: 2.5em; | ||
height: 2em; | ||
transform: translate(-30%, -50%); |
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.
top: -1.4em; | |
width: 2.5em; | |
height: 2em; | |
transform: translate(-30%, -50%); | |
top: 0; | |
left: 50%; | |
transform: translate(-50%, -100%); |
top: 50%; | ||
left: 0; | ||
float: left; | ||
transform: translate(-100%, -50%); |
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.
transform: translate(-100%, -50%); | |
transform: translate(-50%, -50%); |
height: 100%; | ||
background-color: @slider-bar-background; | ||
|
||
&:last-of-type { |
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 more than one background?
Trello: https://trello.com/c/MVf2vg4g/74-back-port-slider-functionality-from-fare-comparer-into-roe-sliders