Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit da2381e

Browse files
authored
fix(global): wallpaper out content scroll issue (#1343)
1 parent e593343 commit da2381e

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/containers/layout/GlobalLayout/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const GlobalLayoutContainer: FC<TProps> = ({
6969
{/* @ts-ignore */}
7070
<Addon />
7171
<Skeleton>
72+
<Wallpaper wallpaper={wallpaper} wallpapers={wallpapers} />
7273
{/* @ts-ignore */}
7374
<CustomScroller
7475
instanceKey={BODY_SCROLLER}
@@ -81,7 +82,6 @@ const GlobalLayoutContainer: FC<TProps> = ({
8182
>
8283
<Wrapper>
8384
<SEO metric={metric} config={seoConfig} />
84-
<Wallpaper wallpaper={wallpaper} wallpapers={wallpapers} />
8585
<InnerWrapper metric={metric} sidebarPin={sidebarPin}>
8686
{/* @ts-ignore */}
8787
<ContentWrapper offsetLeft={sidebarPin}>

src/containers/layout/GlobalLayout/styles/wallpaper.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
import styled from 'styled-components'
2+
import { animate } from '@/utils/css'
23

34
export const Wrapper = styled.div<{ effect: string }>`
4-
${({ effect }) => effect || ''};
5-
position: fixed;
5+
position: absolute;
66
top: 0;
7-
height: 100vh;
8-
width: 100vw;
7+
height: 100%;
8+
width: 100%;
9+
10+
${({ effect }) => effect || ''};
911
12+
/* adjust s value for speed */
1013
/* position: fixed; */
1114
/* see https://www.zhangxinxu.com/wordpress/2015/11/css3-will-change-improve-paint/ */
1215
will-change: transform;
16+
/**
17+
* 可以横向滚动,有点意思。。
18+
* @link https://stackoverflow.com/questions/37903824/how-can-i-make-infinite-flowing-background-with-only-css
19+
*/
20+
21+
/* animation: ${animate.animatedBg} 3000s linear; */
1322
transition: all 0.3s;
1423
`
1524
export const InnerWrapper = styled.div`

utils/css/animations.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
import { keyframes } from 'styled-components'
22

3+
const animatedBg = keyframes`
4+
from {
5+
background-position: 0 0;
6+
}
7+
/*use negative width if you want it to flow right to left else and positive for left to right*/
8+
to {
9+
background-position: -10000px 0;
10+
}
11+
`
12+
313
const shake = keyframes`
414
from,
515
to {
@@ -110,6 +120,7 @@ const animate = {
110120
breath,
111121
blink,
112122
jump,
123+
animatedBg,
113124
}
114125

115126
export default animate

0 commit comments

Comments
 (0)