Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refractor(memories):update-lane-ui

Aswin Asok16fbbd45dd54
diff --git a/web/apps/memories/src/components/LaneMemoryViewer.tsx b/web/apps/memories/src/components/LaneMemoryViewer.tsx
index b918638aaf..4391f6f4eb 100644
--- a/web/apps/memories/src/components/LaneMemoryViewer.tsx
+++ b/web/apps/memories/src/components/LaneMemoryViewer.tsx
@@ -22,7 +22,6 @@ import {
calculateLaneOverlayOpacity,
calculateLaneRotation,
calculateLaneScale,
- calculateLaneYOffset,
easeInOutCubic,
getFileAspectRatio,
getLaneStackSlices,
@@ -51,7 +50,7 @@ import {
} from "./PublicMemoryViewerShared";
const LANE_FRAME_INTERVAL_MS = 800;
-const LANE_CARD_TRANSITION_DURATION_MS = 520;
+const LANE_CARD_TRANSITION_DURATION_MS = 440;
const LANE_COMPACT_LAYOUT_BREAKPOINT_PX = 900;
const LANE_MOBILE_MEDIA_RESERVED_VERTICAL_SPACE_PX = 340;
const DESKTOP_LANE_MEDIA_VERTICAL_RESERVED_PX = 320;
@@ -65,6 +64,23 @@ const LANE_GRID_LINE_COLOR = "#08c225";
const LANE_GRID_LINE_OPACITY = 0.06;
const LANE_GRID_DISPLACEMENT_SCALE = 9;
const LANE_VERTICAL_STACK_GAP_PX = 32;
+const LANE_CARD_TO_CONTROLS_GAP_PX = 40;
+const LANE_CARD_SIZE_SCALE = 0.94;
+
+function calculateLaneXOffset(
+ distance: number,
+ cardWidth: number,
+ viewportWidth: number,
+): number {
+ if (distance >= 0) {
+ const compression = Math.pow(0.78, distance);
+ return -cardWidth * 0.12 * distance * compression;
+ }
+ const sideways = Math.abs(distance);
+ const exitDistance = Math.max(cardWidth * 1.8, viewportWidth * 0.82);
+ const overshoot = Math.max(0, sideways - 1) * cardWidth * 0.4;
+ return sideways * exitDistance + overshoot;
+}
/**
* Primary viewer for lane-style public memory shares.
@@ -470,6 +486,9 @@ export function LaneMemoryViewer({
width = height * LANE_CARD_ASPECT_RATIO;
}
+ width *= LANE_CARD_SIZE_SCALE;
+ height *= LANE_CARD_SIZE_SCALE;
+
return { width: Math.round(width), height: Math.round(height) };
}, [isCompactLaneLayout, viewport.height, viewport.width]);
@@ -593,9 +612,10 @@ export function LaneMemoryViewer({
const scale = calculateLaneScale(
slice.distance,
);
- const yOffset = calculateLaneYOffset(
+ const xOffset: number = calculateLaneXOffset(
slice.distance,
- laneFrameSize.height,
+ laneFrameSize.width,
+ viewport.width,
);
const opacity = calculateLaneOpacity(
slice.distance,
@@ -629,7 +649,7 @@ export function LaneMemoryViewer({
key={`lane-slice-${slice.index}`}
style={{
opacity,
- transform: `translateY(${yOffset}px) rotate(${rotation}deg) scale(${scale})`,
+ transform: `translateX(${xOffset}px) rotate(${rotation}deg) scale(${scale})`,
}}
>
<LaneCardSurface
@@ -1073,7 +1093,7 @@ const LaneCenterSection = styled("div")({
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
- gap: `${LANE_VERTICAL_STACK_GAP_PX}px`,
+ gap: `${LANE_CARD_TO_CONTROLS_GAP_PX}px`,
transform: "translateY(-28px)",
"@media (max-width: 900px)": {
transform: "translateY(0)",
diff --git a/web/apps/memories/src/components/PublicMemoryControls.tsx b/web/apps/memories/src/components/PublicMemoryControls.tsx
index a02c556fe1..e9a722a493 100644
--- a/web/apps/memories/src/components/PublicMemoryControls.tsx
+++ b/web/apps/memories/src/components/PublicMemoryControls.tsx
@@ -51,7 +51,7 @@ const LaneProgressTrack = styled("div")({
cursor: "pointer",
"@media (max-width: 900px)": { maxWidth: "320px" },
[`@media (max-width: ${MOBILE_LAYOUT_BREAKPOINT_PX}px)`]: {
- maxWidth: "248px",
+ maxWidth: "min(calc(100vw - 48px), 304px)",
},
});
diff --git a/web/apps/memories/src/utils/lane.ts b/web/apps/memories/src/utils/lane.ts
index 58dab2d022..9e829bb7d7 100644
--- a/web/apps/memories/src/utils/lane.ts
+++ b/web/apps/memories/src/utils/lane.ts
@@ -329,17 +329,6 @@ export const calculateLaneScale = (distance: number) => {
return Math.min(Math.max(1.0 - Math.abs(distance) * 0.02, 0.82), 1.02);
};
-export const calculateLaneYOffset = (distance: number, cardHeight: number) => {
- if (distance >= 0) {
- const compression = Math.pow(0.72, distance);
- return -cardHeight * 0.14 * distance * compression;
- }
- const downward = Math.abs(distance);
- const easedComponent = Math.pow(downward, 1.45);
- const travel = downward * (2.8 + 1.8 * downward);
- return cardHeight * (travel + easedComponent * 0.65);
-};
-
export const calculateLaneBlur = (distance: number) => {
if (distance <= 0) {
return 0;
@@ -362,11 +351,7 @@ export const calculateLaneOpacity = (distance: number) => {
return Math.max(0.35, 1 - distance * 0.22);
}
const drop = Math.abs(distance);
- if (drop <= 0.9) {
- return 1;
- }
- const t = Math.min(Math.max((drop - 0.9) / 0.55, 0), 1);
- return Math.max(0, 1 - t);
+ return Math.max(0, 1 - drop * 0.85);
};
export const calculateLaneOverlayOpacity = (distance: number) => {