Skip to content

Commit

Permalink
fix: Check element in viewport (#75) and upgrade node-fetch(#76)
Browse files Browse the repository at this point in the history
* fix: Check element in viewport.
* chore(deps): bump node-fetch from 2.6.6 to 2.6.7
  • Loading branch information
lemon5920 authored Jan 23, 2022
1 parent f572def commit f9fc72b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
9 changes: 4 additions & 5 deletions src/pages/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
import { breakpoints } from '@assets/themes/globalTheme';
import Box from '@components/Box';
import booksOrderBy from '@recoil/booksOrderBy';
import { scrollToTop, shakeView } from '@utils/window/scroll';
import { scrollToTop } from '@utils/window/scroll';
import { Tabs } from 'antd';
import { isEmpty } from 'lodash-es';
import { FunctionComponent, useEffect, useState } from 'react';
import { forceCheck } from 'react-lazyload';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';
import ResultEmpty from './ResultEmpty';
Expand Down Expand Up @@ -42,12 +43,10 @@ const Search: FunctionComponent = () => {

useEffect(() => setCurrentTab('all'), [bookstores]);
useEffect(() => {
shakeView();
scrollToTop();
forceCheck();
}, [currentTab]);
useEffect(() => {
shakeView(); // To show books which lazyload.
}, [orderBy]);
useEffect(() => forceCheck(), [orderBy]);

return (
<>
Expand Down
7 changes: 0 additions & 7 deletions src/utils/window/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ smoothscroll.polyfill();
export const scrollToTop = (): void => {
window.scroll({ top: 0, behavior: 'smooth' });
};

export const shakeView = (): void => {
const scrollY = window.scrollY;
window.scrollTo({ top: scrollY + 1 });
window.scrollTo({ top: scrollY - 1 });
window.scrollTo({ top: scrollY });
};
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5464,9 +5464,9 @@ node-emoji@^1.10.0:
lodash "^4.17.21"

node-fetch@^2.6.1:
version "2.6.6"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
whatwg-url "^5.0.0"

Expand Down

0 comments on commit f9fc72b

Please sign in to comment.