Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sticky of claim button #428

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions features/withdrawals/claim/form/claim-form-footer-sticky.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const STICK_CHECKPOINT_OFFSET =

type ScrollState = {
isSticked: boolean;
footerShift: number;
};

type ScrollStateSetter = <
Expand All @@ -49,7 +48,6 @@ export const ClaimFormFooterSticky: FC<
// frequent operations performant during scroll
const { current: scrollState } = useRef<ScrollState>({
isSticked: false,
footerShift: -1,
});

const setStateAndUpdate = useCallback<ScrollStateSetter>(
Expand All @@ -70,7 +68,6 @@ export const ClaimFormFooterSticky: FC<
const { y: screenH, x: screenW } = getScreenSize();
const rectRequests = elRequests.getBoundingClientRect();
const rectFooter = elFooter.getBoundingClientRect();
const footerHeight = elFooter.clientHeight;
const menuOffset = screenW < NAV_MOBILE_MAX_WIDTH ? NAV_MOBILE_HEIGHT : 0;

// Calcs
Expand All @@ -87,17 +84,8 @@ export const ClaimFormFooterSticky: FC<
if (!scrollState.isSticked) {
setStateAndUpdate('isSticked', true);
}

const currFooterShift =
footerHeight - Math.min(distanceFromElStart, footerHeight) - menuOffset;
if (currFooterShift !== scrollState.footerShift) {
elFooter.style.setProperty('bottom', `${-currFooterShift}px`);
scrollState.footerShift = currFooterShift;
}
} else {
if (scrollState.isSticked) {
scrollState.footerShift = -1;
elFooter.style.removeProperty('bottom');
setStateAndUpdate('isSticked', false);
}
}
Expand All @@ -107,7 +95,6 @@ export const ClaimFormFooterSticky: FC<

const positionInitializatorEffect = useCallback(() => {
if (!isEnabled) return;
const elFooter = refFooter.current;

// Event subscriptions
window.addEventListener('resize', updatePosition, { passive: true });
Expand All @@ -116,8 +103,6 @@ export const ClaimFormFooterSticky: FC<
return () => {
window.removeEventListener('resize', updatePosition);
window.removeEventListener('scroll', updatePosition);
scrollState.footerShift = -1;
if (elFooter) elFooter.style.removeProperty('bottom');
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isEnabled]);
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/claim/form/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const ClaimFooterBodyEnder = styled.div`

export const ClaimFormFooterWrapper = styled.div<{ isSticked: boolean }>`
position: ${({ isSticked }) => (isSticked ? 'sticky' : 'relative')};
bottom: 0;
bottom: ${({ isSticked }) => (isSticked ? `60px` : '0px')};
${({ isSticked }) =>
isSticked &&
css`
Expand Down
Loading