Skip to content

Commit

Permalink
fix: use useRef
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed May 21, 2021
1 parent fe93a01 commit b360911
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/component/elements/InputRange.jsx
Expand Up @@ -24,8 +24,6 @@ const styles = {
},
};

const previousPosition = { x: 0, nano: performance.now() };

export default function InputRange({
name,
value,
Expand All @@ -34,9 +32,10 @@ export default function InputRange({
style,
className,
}) {
const previousPosition = useRef(0);
const mouseMoveCallback = (event) => {
let diff = event.clientX - previousPosition.x;
previousPosition.x = event.clientX;
let diff = event.clientX - previousPosition.current;
previousPosition.current = event.clientX;
if (event.buttons === 1) {
onChange({
value: value + diff / (event.shiftKey ? 10 : 1),
Expand Down

0 comments on commit b360911

Please sign in to comment.