mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(erase-object): auto-center compare slider at erased region
Track the painted mask centroid and initialise the before/after slider at that position so the result is immediately visible without manual dragging.
This commit is contained in:
@@ -9,6 +9,8 @@ interface BeforeAfterSliderProps {
|
||||
beforeSize?: number;
|
||||
/** Processed file size in bytes. */
|
||||
afterSize?: number;
|
||||
/** Initial divider position as a percentage (0–100). Defaults to 50. */
|
||||
initialPosition?: number;
|
||||
}
|
||||
|
||||
function formatSize(bytes: number): string {
|
||||
@@ -29,9 +31,10 @@ export function BeforeAfterSlider({
|
||||
afterSrc,
|
||||
beforeSize,
|
||||
afterSize,
|
||||
initialPosition = 50,
|
||||
}: BeforeAfterSliderProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [position, setPosition] = useState(50); // percentage 0-100
|
||||
const [position, setPosition] = useState(initialPosition); // percentage 0-100
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
|
||||
const updatePosition = useCallback((clientX: number) => {
|
||||
|
||||
Reference in New Issue
Block a user