mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
Clamp indicated value within value range
This commit is contained in:
parent
ba362b727c
commit
c99e1de803
1 changed files with 11 additions and 0 deletions
|
@ -34,6 +34,17 @@ type IProps = {
|
|||
|
||||
export default class Slider extends React.Component<IProps> {
|
||||
_offset(values: number[], value: number): number {
|
||||
const lowest = values[0];
|
||||
const highest = values[values.length - 1];
|
||||
|
||||
if (value < lowest) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (value > highest) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
return (value - values[0]) / (values[values.length - 1] - values[0]) * 100;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue