ISSUE-021 - Another progress commit. Have issues with combining spring animated components and Styled-Components.

This commit is contained in:
Kyle Geib committed 2022-01-18 15:18:39 -05:00
1 parent 97c5752102
commit 9925eae4cc
2 files changed
+16 -17

No files matched your search

@@ -5,7 +5,7 @@ import { clamp } from "lodash";
import { ProgressSliderBar, ProgressSliderBarHandle, ProgressSliderBarHandleContainer, ProgressSliderBody } from "./styles";
const MARGIN_WIDTH = 30;
const MARGIN_WIDTH = 15;
type ProgressSliderProps = {
value: number, // Fraction of 1 (0.0 to 1.0)
@@ -20,7 +20,7 @@ export function ProgressSlider({
const [bodyRef, {
width: bodyWidth,
}] = useMeasure();
const barPos = useSpring({ x: (bodyWidth - 2 * MARGIN_WIDTH) * value });
const barPos = useSpring({ x: (bodyWidth - MARGIN_WIDTH) * value });
const bindBarPos = useDrag((params) => {
const newPos = clamp(barPos.x.get() + params.delta[0], MARGIN_WIDTH, bodyWidth - MARGIN_WIDTH);
const newValue = newPos / (bodyWidth - MARGIN_WIDTH);
@@ -33,20 +33,17 @@ export function ProgressSlider({
// const
// console.log("main", bodyWidth, barPos.x.get());
console.log("main",barPos.x.get());
// console.log("main",barPos.x.get());
// console.log(bodyWidth);
return (
<ProgressSliderBody ref={bodyRef}>
{/* <animated.div style={{ x: barPos.x }}> */}
<ProgressSliderBar>
{/* <animated.div {...bindBarPos()} style={{ x: barPos.x }}> */}
<ProgressSliderBarHandleContainer {...bindBarPos()} style={{ x: barPos.x }}>
<ProgressSliderBarHandle />
</ProgressSliderBarHandleContainer>
{/* </animated.div> */}
</ProgressSliderBar>
{/* </animated.div> */}
<ProgressSliderBar style={{ x: barPos.x }} bodyWidth={bodyWidth - MARGIN_WIDTH} />
<ProgressSliderBarHandleContainer {...bindBarPos()} style={{ x: barPos.x }}>
<ProgressSliderBarHandle />
</ProgressSliderBarHandleContainer>
</ProgressSliderBody>
);