diff --git a/src/components/Slider/index.tsx b/src/components/Slider/index.tsx index 89cac55b..76da05a2 100644 --- a/src/components/Slider/index.tsx +++ b/src/components/Slider/index.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames' -import { ChangeEvent, useRef, useState } from 'react' +import { ChangeEvent, useEffect, useMemo, useRef, useState } from 'react' import Draggable from 'react-draggable' import { OverlayMark } from 'components/Icons' @@ -98,6 +98,17 @@ export default function Slider(props: Props) { const DraggableElement: any = Draggable + const [positionOffset, position] = useMemo(() => { + return [ + { x: (props.value / 100) * -12, y: 0 }, + { x: (sliderRect.width / 100) * props.value, y: -2 }, + ] + }, [props.value, sliderRect.width]) + + useEffect(() => { + handleSliderRect() + }, []) + return (
setIsDragging(false)} - position={{ x: (sliderRect.width / 100) * props.value, y: -2 }} + position={position} >
{props.leverage && ( -
+