Skip to content

Commit

Permalink
fix: mobile offset other direction
Browse files Browse the repository at this point in the history
  • Loading branch information
shalanah committed Apr 3, 2024
1 parent 7af9251 commit 5f1792c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/verticalCenterWithMargin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ type Props = {
children?: React.ReactNode;
};

const getYPosition = () =>
// verticalView: boolean
{
const centerY = cartonHeight / 2;
// visual centering top part of milk carton less important + recedes
// const verticalOffset = verticalView && window.innerHeight < 600 ? 0 : 0;
return -centerY + 0;
};
const getYPosition = (verticalView: boolean) => {
const centerY = cartonHeight / 2;
// visual centering top part of milk carton less important + recedes
const verticalOffset = verticalView && window.innerHeight < 800 ? -2 : 0;
return -centerY + verticalOffset;
};

const config = {
mass: 0.25,
Expand Down Expand Up @@ -47,7 +45,7 @@ export const VerticalCenterWithMargin = ({ children = null }: Props) => {
useCanIUseContext();
const { camera, size } = useThree();

const y = getYPosition();
const y = getYPosition(verticalView);
const position = [0, y, -cartonSide * (scale - 1)];

const [spring] = useSpring(
Expand Down

0 comments on commit 5f1792c

Please sign in to comment.