fix(home-slider): restore desktop mouse hover tracking, isolate slider from link navigation, and fix touch drag math
This commit is contained in:
@@ -145,11 +145,21 @@ export function CardBeforeAfterSlider({
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleContainerPointerDown = useCallback(
|
||||
(e: React.PointerEvent<HTMLDivElement>) => {
|
||||
// On desktop with mouse, clicking anywhere on the card moves the split
|
||||
if (e.pointerType !== 'mouse' || e.button !== 0) return;
|
||||
handlePointerDown(e);
|
||||
},
|
||||
[handlePointerDown]
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
onPointerDown={handleContainerPointerDown}
|
||||
style={{
|
||||
'--split': '50%',
|
||||
touchAction: 'pan-y', // Allows mobile vertical scrolling across the card and line
|
||||
|
||||
@@ -82,7 +82,7 @@ export function Cinematic3DComparison({
|
||||
};
|
||||
}, [autoSlide, isDragging, updatePosition]);
|
||||
|
||||
// Unified Pointer Handlers on the Slider Arrows Handle
|
||||
// Unified Pointer Handlers
|
||||
const handlePointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (e.button !== 0 && e.pointerType === 'mouse') return;
|
||||
e.stopPropagation();
|
||||
@@ -105,6 +105,12 @@ export function Cinematic3DComparison({
|
||||
}
|
||||
};
|
||||
|
||||
const handleContainerPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
// On desktop with mouse, clicking anywhere on the stage moves the slider
|
||||
if (e.pointerType !== 'mouse' || e.button !== 0) return;
|
||||
handlePointerDown(e);
|
||||
};
|
||||
|
||||
const handlePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!isPointerDownRef.current) return;
|
||||
e.stopPropagation();
|
||||
@@ -167,6 +173,7 @@ export function Cinematic3DComparison({
|
||||
{/* 3D Kinetic Tilt Stage - Allows smooth page scrolling when touching anywhere except the arrows handle */}
|
||||
<div
|
||||
ref={containerRef}
|
||||
onPointerDown={handleContainerPointerDown}
|
||||
className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden preserve-3d transition-transform duration-150 ease-out shadow-cinematic-3d hover:shadow-cinematic-hover border border-slate-900/[0.08] bg-slate-950`}
|
||||
style={{
|
||||
'--split': '50%',
|
||||
|
||||
Reference in New Issue
Block a user