Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/src/slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import useTheme from "../useTheme";
import SliderPropsType, { RefType } from "./types";
import { v4 as uuidv4 } from "uuid";

const isFirefox = navigator.userAgent.indexOf("Firefox") !== -1;

const DxcSlider = React.forwardRef<RefType, SliderPropsType>(
(
{
Expand Down Expand Up @@ -36,6 +34,7 @@ const DxcSlider = React.forwardRef<RefType, SliderPropsType>(
const [innerValue, setInnerValue] = useState(defaultValue ?? 0);
const [dragging, setDragging] = useState(false);
const colorsTheme = useTheme();
const isFirefox = navigator?.userAgent.indexOf("Firefox") !== -1;

const minLabel = useMemo(
() => (labelFormatCallback ? labelFormatCallback(minValue) : minValue),
Expand All @@ -48,10 +47,11 @@ const DxcSlider = React.forwardRef<RefType, SliderPropsType>(
);

const tickMarks = useMemo(() => {
const ticks = [];
const numberOfMarks = Math.floor(maxValue / step - minValue / step);
let index = 0;
const range = maxValue - minValue;
const ticks = [];
let index = 0;

if (marks) {
while (index <= numberOfMarks) {
ticks.push(
Expand All @@ -65,9 +65,7 @@ const DxcSlider = React.forwardRef<RefType, SliderPropsType>(
index++;
}
return ticks;
} else {
return null;
}
} else return null;
}, [minValue, maxValue, step, value, innerValue]);

const handleSliderChange = (event) => {
Expand Down Expand Up @@ -371,4 +369,4 @@ const StyledTextInput = styled.div`
max-width: 70px;
`;

export default DxcSlider;
export default DxcSlider;