Skip to content

Commit 7d1c753

Browse files
committed
feat: lockfile
1 parent 1da8508 commit 7d1c753

File tree

2 files changed

+37
-12483
lines changed

2 files changed

+37
-12483
lines changed

src/client/page/comic/imgList.jsx

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
/* eslint-disable */
21
import React, {
32
useRef,
43
useState,
54
useEffect,
65
useLayoutEffect,
76
useCallback,
87
useMemo,
9-
Fragment,
10-
} from 'react';
11-
import classNames from 'classnames';
12-
import StartUpPage from '../../startPage';
13-
import Button from '@material-ui/core/Button';
14-
import styles from './index.css';
15-
import useComicContext from './useComicContext';
8+
} from "react";
9+
import classNames from "classnames";
10+
import StartUpPage from "../../startPage";
11+
import Button from "@material-ui/core/Button";
12+
import styles from "./index.css";
13+
import useComicContext from "./useComicContext";
1614

1715
// onVisitPosition: 当对应图片露出时调用,用来记录看到的位置
18-
function ImgList({ onNextPage, hasNextPage, imgList, onVisitPosition}) {
19-
const { filter, autoScroll, setAutoScroll, comic } = useComicContext();
16+
function ImgList({ onNextPage, hasNextPage, imgList, onVisitPosition }) {
17+
const { filter, autoScroll, comic } = useComicContext();
2018
/* 只有首次初始化ImgList时才自动定位到comic.position位置*/
2119
const firstElePosition = useMemo(() => {
2220
if (Number.isInteger(comic.position) && comic.position) {
@@ -42,31 +40,35 @@ function ImgList({ onNextPage, hasNextPage, imgList, onVisitPosition}) {
4240
}
4341
});
4442

45-
document.querySelectorAll('.comic-img').forEach(ele => {
43+
document.querySelectorAll(".comic-img").forEach((ele) => {
4644
observer.observe(ele);
4745
});
4846

4947
return () => {
5048
observer.disconnect();
51-
}
52-
}
53-
54-
return () => {
49+
};
5550
}
5651

52+
return () => {};
5753
}, [isFirst]);
5854

59-
const onImgLoad = useCallback((e) => {
60-
if (isFirst && Number(e.currentTarget.dataset.index) === firstElePosition) {
61-
const target = e.currentTarget;
62-
setTimeout(() => {
63-
target.scrollIntoView();
64-
}, 50);
65-
setTimeout(() => {
66-
setIsFirst(false);
67-
}, 100);
68-
}
69-
}, [isFirst]);
55+
const onImgLoad = useCallback(
56+
(e) => {
57+
if (
58+
isFirst &&
59+
Number(e.currentTarget.dataset.index) === firstElePosition
60+
) {
61+
const target = e.currentTarget;
62+
setTimeout(() => {
63+
target.scrollIntoView();
64+
}, 50);
65+
setTimeout(() => {
66+
setIsFirst(false);
67+
}, 100);
68+
}
69+
},
70+
[isFirst]
71+
);
7072

7173
function renderList(list) {
7274
return list.map((item, index) => {
@@ -76,7 +78,10 @@ function ImgList({ onNextPage, hasNextPage, imgList, onVisitPosition}) {
7678
src={item}
7779
onLoad={onImgLoad}
7880
data-index={index}
79-
className={classNames('comic-img', styles[`filter-${filter}`])}
81+
className={classNames(
82+
"comic-img border-box border border-black",
83+
styles[`filter-${filter}`]
84+
)}
8085
/>
8186
);
8287
});
@@ -164,17 +169,18 @@ function ImgList({ onNextPage, hasNextPage, imgList, onVisitPosition}) {
164169
}, []);
165170

166171
return (
167-
<div
168-
className={styles.imglist} >
169-
<StartUpPage className={classNames('z-10', { '!hidden': !isFirst})}></StartUpPage>
172+
<div className={styles.imglist}>
173+
<StartUpPage
174+
className={classNames("z-10", { "!hidden": !isFirst })}
175+
></StartUpPage>
170176
{renderList(imgList)}
171177
{hasNextPage ? (
172178
<Button
173179
onClick={onClickNextPage}
174180
className={styles.nextpagebtn}
175181
ref={nextPageBtnRef}
176182
>
177-
下一页{time === 0 ? '' : time}
183+
下一页{time === 0 ? "" : time}
178184
</Button>
179185
) : null}
180186
</div>

0 commit comments

Comments
 (0)