Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelfangjw committed Jun 19, 2021
1 parent 8b56dce commit 7e0dd15
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pages/sicp/Sicp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ const Sicp: React.FC<SicpProps> = props => {
const bottomRef = React.useRef<HTMLDivElement>(null);
const refs = React.useRef({});

const scrollRefIntoView = (ref :HTMLDivElement | null) => {
const scrollRefIntoView = (ref: HTMLDivElement | null) => {
if (!ref) {
return;
}

// Hack to get scrolling to work properly.
// When 'block: start' option is used with scrollIntoView, the whole page scrolls with it.
// This issue does not occur when the option 'block: nearest' is used.
// To get `block: nearest` to mimic `block: start` behaviour, we first scroll to the bottom of
// To get `block: nearest` to mimic `block: start` behaviour, we first scroll to the bottom of
// the page before scrolling to the desired ref using the `block: nearest` option.
bottomRef.current!.scrollIntoView({ block: 'end' });
ref.scrollIntoView({ block: 'nearest' });
}
bottomRef.current!.scrollIntoView({ block: 'end' });
ref.scrollIntoView({ block: 'nearest' });
};

// Fetch json data
React.useEffect(() => {
Expand Down

0 comments on commit 7e0dd15

Please sign in to comment.