Skip to content

Commit 391ff82

Browse files
author
Ives van Hoorne
committed
Perf improvements
1 parent 58964d0 commit 391ff82

File tree

7 files changed

+65
-36
lines changed

7 files changed

+65
-36
lines changed

src/homepage/src/components/LoadInView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class LoadInView extends React.PureComponent {
1414
}
1515

1616
listen = () => {
17-
if (!this.state.show && this.elPos && getScrollPos().y + 300 > this.elPos) {
17+
if (!this.state.show && this.elPos && getScrollPos().y + 100 > this.elPos) {
1818
requestAnimationFrame(() => {
1919
this.setState({ show: true });
2020
});

src/homepage/src/components/Navigation.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ export default () => (
7171
<StyledLogo width={50} height={50} />
7272
</Left>
7373
<Right>
74-
<Item
75-
href="https://medium.com/@compuives"
76-
target="_blank"
77-
rel="noopener noreferrer"
78-
>
79-
Examples
80-
</Item>
8174
<Item
8275
href="https://medium.com/@compuives"
8376
target="_blank"
@@ -92,12 +85,7 @@ export default () => (
9285
>
9386
GitHub
9487
</Item>
95-
<Item
96-
href="https://github.com/CompuIves/codesandbox-client"
97-
target="_blank"
98-
rel="noopener noreferrer"
99-
button
100-
>
88+
<Item href="/s" target="_blank" rel="noopener noreferrer" button>
10189
Create Sandbox
10290
</Item>
10391
</Right>

src/homepage/src/pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Footer from '../screens/home/Footer';
88
import RecentPublications from '../screens/home/RecentPublications';
99

1010
export default () => (
11-
<div style={{ marginBottom: 900 }} v>
11+
<div>
1212
<Animation />
1313
<NPMFeature />
1414
<CycleFeature />

src/homepage/src/screens/home/Animation/Title.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export default ({ template }) => (
124124
</Button>
125125

126126
<Button
127-
href={sandboxUrl({ id: template.shortid })}
127+
href={`https://codesandbox.io/search?refinementList%5Btemplate%5D%5B0%5D=${
128+
template.name
129+
}`}
128130
color={template.color}
129131
secondary
130132
>

src/homepage/src/screens/home/Animation/canvas/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Canvas {
77
stage: HTMLCanvasElement;
88
ctx: CanvasRenderingContext2D;
99
dots: Array<Dot> = [];
10-
waves: Array<Wave> = [];
10+
wave: Wave = null;
1111

1212
lastDelta: number = Date.now();
1313
cubeX: number = 1300;
@@ -41,14 +41,21 @@ class Canvas {
4141
}
4242
}
4343

44+
lowPerf = false;
45+
4446
loop = () => {
4547
const now = Date.now();
4648
const delta = now - this.lastDelta;
47-
if (getScrollPos(now).y > this.stage.height) {
49+
if (getScrollPos(now).y > this.stage.height || delta < 33) {
4850
requestAnimationFrame(this.loop);
4951
return;
5052
}
5153

54+
if (delta > 2000) {
55+
this.lowPerf = true;
56+
this.dots = this.dots.filter(x => Math.random() > 0.5);
57+
}
58+
5259
this.ctx.clearRect(0, 0, this.stage.width, this.stage.height);
5360

5461
let distX;

src/homepage/src/screens/home/Animation/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,15 @@ export default class Animation extends React.PureComponent {
7575

7676
startTimer = () => {
7777
this.timeout = setTimeout(() => {
78-
requestAnimationFrame(() => {
79-
if (!this.state.templateSelected) {
80-
this.setState({
81-
templateIndex:
82-
(this.state.templateIndex + 1) % this.state.templates.length,
83-
});
84-
85-
this.startTimer();
86-
}
87-
});
88-
}, 5000);
78+
if (!this.state.templateSelected) {
79+
this.setState({
80+
templateIndex:
81+
(this.state.templateIndex + 1) % this.state.templates.length,
82+
});
83+
84+
this.startTimer();
85+
}
86+
}, 6000);
8987
};
9088

9189
setCanvas = canvas => {

src/homepage/src/screens/home/Footer.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const Container = styled.div`
1111
padding-bottom: 3rem;
1212
`;
1313

14-
const Column = styled.div`flex: 1;`;
14+
const Column = styled.div`
15+
flex: 1;
16+
`;
1517

1618
const Title = styled.h5`
1719
font-size: 1.125rem;
@@ -54,8 +56,8 @@ export default () => (
5456
<Title>CodeSandbox</Title>
5557
<List>
5658
<li>
57-
<a href="/s/new" target="_blank" rel="noopener noreferrer">
58-
Create A Sandbox
59+
<a href="/s" target="_blank" rel="noopener noreferrer">
60+
Create Sandbox
5961
</a>
6062
</li>
6163
<li>
@@ -74,16 +76,48 @@ export default () => (
7476
<Column>
7577
<Title>About</Title>
7678
<List>
77-
<li>Blog</li>
78-
<li>GitHub</li>
79+
<li>
80+
<a
81+
href="https://medium.com/@compuives"
82+
target="_blank"
83+
rel="noopener noreferrer"
84+
>
85+
Blog
86+
</a>
87+
</li>
88+
<li>
89+
<a
90+
href="https://github.com/CompuIves/codesandbox-client"
91+
target="_blank"
92+
rel="noopener noreferrer"
93+
>
94+
GitHub
95+
</a>
96+
</li>
7997
</List>
8098
</Column>
8199

82100
<Column>
83101
<Title>Social</Title>
84102
<List>
85-
<li>Twitter</li>
86-
<li>Discord</li>
103+
<li>
104+
<a
105+
href="https://twitter.com/codesandboxapp"
106+
target="_blank"
107+
rel="noopener noreferrer"
108+
>
109+
Twitter
110+
</a>
111+
</li>
112+
<li>
113+
<a
114+
href="https://discord.gg/KE3TbEZ"
115+
target="_blank"
116+
rel="noopener noreferrer"
117+
>
118+
Discord
119+
</a>
120+
</li>
87121
</List>
88122
</Column>
89123
</Container>

0 commit comments

Comments
 (0)