Skip to content
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 update #1791

Merged
merged 1 commit into from Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/src/slider/Slider.tsx
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;