-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from EOEFANS/main
增加图片详情页跳转功能
- Loading branch information
Showing
9 changed files
with
164 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,7 @@ jobs: | |
|
|
||
| - name: Use pnpm to build | ||
| run: pnpm run build | ||
|
|
||
| # - name: post-build test | ||
| # run: pnpm test | ||
|
|
||
|
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * 给元素style添加属性。 | ||
| */ | ||
| export const ObjectToHtmlStyle = ( | ||
| obj: React.CSSProperties, | ||
| ele: HTMLElement | ||
| ) => { | ||
| Object.entries(obj).forEach(([key, value]) => { | ||
| if (value) { | ||
| //@ts-ignore | ||
| ele.style[key] = value; | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| let _ScrollBarWidthCached: number | null = null; | ||
|
|
||
| function hasScrollbar(): boolean { | ||
| return ( | ||
| document.body.scrollHeight > | ||
| (window.innerHeight || document.documentElement.clientHeight) | ||
| ); | ||
| } | ||
| export function getScrollBarSize(): number { | ||
| if (!hasScrollbar()) { | ||
| _ScrollBarWidthCached = 0; | ||
| } | ||
| if (typeof _ScrollBarWidthCached === "number") { | ||
| return _ScrollBarWidthCached; | ||
| } | ||
| const inner = document.createElement("div"); | ||
| ObjectToHtmlStyle( | ||
| { | ||
| width: "100%", | ||
| height: "200px", | ||
| }, | ||
| inner | ||
| ); | ||
| const outer = document.createElement("div"); | ||
| ObjectToHtmlStyle( | ||
| { | ||
| position: "absolute", | ||
| top: "0", | ||
| left: "0", | ||
| pointerEvents: "none", | ||
| visibility: "hidden", | ||
| width: "200px", | ||
| height: "150px", | ||
| overflow: "hidden", | ||
| }, | ||
| outer | ||
| ); | ||
| outer.appendChild(inner); | ||
| document.body.appendChild(outer); | ||
| const widthContained = inner.offsetWidth; | ||
| ObjectToHtmlStyle( | ||
| { | ||
| overflow: "scroll", | ||
| }, | ||
| outer | ||
| ); | ||
| let widthScroll = inner.offsetWidth; | ||
|
|
||
| if (widthContained === widthScroll) { | ||
| widthScroll = outer.clientWidth; | ||
| } | ||
|
|
||
| document.body.removeChild(outer); | ||
| _ScrollBarWidthCached = widthContained - widthScroll; | ||
| return _ScrollBarWidthCached; | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters