scrub returning trim move perfectly in sandbox
This commit is contained in:
1 parent
b17f868db2
commit
827f5453ec
1 file changed
+9
-10
+9
-10
@@ -1,5 +1,5 @@
|
||||
import React,{
|
||||
// useEffect,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
useLayoutEffect,
|
||||
@@ -14,8 +14,6 @@ export interface withScrubbingPropsI {
|
||||
styleOverride?: {[key: string]: string|number };
|
||||
onScrubEnds?: (posPercent: number)=>void;
|
||||
//return scrubber location as %, where 0 < % < 1
|
||||
onScrubChanges?: (posPercent:number)=>void;
|
||||
//return scrubber location as %, where 0 < % < 1
|
||||
}
|
||||
|
||||
type withSrcubbingStates = {
|
||||
@@ -32,10 +30,9 @@ export const withScrubbing = <P extends withScrubbingPropsI>(Component: React.Co
|
||||
initialLeftOffsetPercent = 0,
|
||||
styleOverride = {},
|
||||
onScrubEnds,
|
||||
onScrubChanges,
|
||||
...rest
|
||||
}: withScrubbingPropsI) => {
|
||||
// console.log(`withScrubbing reRender!! ${Date.now()}`);
|
||||
console.log(`withSCRUBBING reRender!! `);
|
||||
const refEl = useRef<HTMLDivElement| null>(null);
|
||||
const refListener = useRef<number>(Date.now());
|
||||
|
||||
@@ -46,7 +43,7 @@ export const withScrubbing = <P extends withScrubbingPropsI>(Component: React.Co
|
||||
const [{
|
||||
// key,
|
||||
currLeftOffset, pointerStartPos,
|
||||
// prevLeftOffset,
|
||||
prevLeftOffset,
|
||||
}, setStates] = useState<withSrcubbingStates>({
|
||||
key: Date.now(),
|
||||
currLeftOffset: initialLeftOffset, // in pixels
|
||||
@@ -108,10 +105,12 @@ export const withScrubbing = <P extends withScrubbingPropsI>(Component: React.Co
|
||||
window.removeEventListener("mousemove", handleScrubMove);
|
||||
};
|
||||
}
|
||||
}, []);
|
||||
// useEffect(()=>{
|
||||
// if(onScrubEnds)onScrubEnds(prevLeftOffset/boundingWidth);
|
||||
// },[prevLeftOffset, boundingWidth, onScrubEnds]);
|
||||
}, [scrubberWidth, boundingWidth]);
|
||||
|
||||
useEffect(()=>{
|
||||
if(onScrubEnds)onScrubEnds(prevLeftOffset/boundingWidth);
|
||||
},[prevLeftOffset, boundingWidth, onScrubEnds]);
|
||||
|
||||
return(
|
||||
<div
|
||||
className="scrubber-wrapper"
|
||||
|
||||
Reference in new issue
Block a user