Skip to content

Commit a372895

Browse files
committed
Smoothen the intro transition on homepage
1 parent aa62782 commit a372895

File tree

2 files changed

+38
-45
lines changed

2 files changed

+38
-45
lines changed

packages/homepage/src/screens/home/hero/BoxAnimation/index.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function Box({ position, rotation, onDrag, onDragStop }) {
128128
}
129129

130130
export default function App({ boxes, showPlane }) {
131-
const [prop, set] = useSpring(() => ({ intensity: 0.6, color: '#fff' }));
131+
const [prop, set] = useSpring(() => ({ intensity: 0, color: '#fff' }));
132132
const [animationDisabled, setAnimationDisabled] = React.useState(false);
133133
const [dragging, setDragging] = React.useState(false);
134134

@@ -141,16 +141,8 @@ export default function App({ boxes, showPlane }) {
141141
}, []);
142142

143143
useEffect(() => {
144-
if (!boxes.length) {
145-
return;
146-
}
147-
148-
set({ intensity: 1 });
149-
150-
setTimeout(() => {
151-
set({ intensity: 0.6 });
152-
}, 300);
153-
}, [boxes, set]);
144+
set({ intensity: 0.6 });
145+
}, [set]);
154146

155147
if (animationDisabled) {
156148
return (
@@ -177,7 +169,7 @@ export default function App({ boxes, showPlane }) {
177169
}}
178170
resize={{ polyfill: ResizeObserver }}
179171
>
180-
<ambientLight intensity={0.5} />
172+
<a.ambientLight {...prop} />
181173

182174
<a.spotLight
183175
{...prop}

packages/homepage/src/screens/home/hero/index.js

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
import hero from '../../../assets/images/hero-ide-home.png';
2020

2121
import BoxAnimation from './BoxAnimation';
22-
import { applyParallax } from '../../../utils/parallax';
2322

2423
export default () => {
2524
const [boxes, setBoxes] = useState([]);
@@ -106,13 +105,6 @@ export default () => {
106105

107106
const ideRef = useRef();
108107

109-
useEffect(() => {
110-
applyParallax(ideRef.current, {
111-
speed: 2,
112-
center: true,
113-
});
114-
}, []);
115-
116108
return (
117109
<HeroWrapper>
118110
<BoxAnimation boxes={boxes} showPlane={showPlane} />
@@ -151,32 +143,41 @@ export default () => {
151143
</motion.div>
152144
</motion.div>
153145

154-
<HeroBottom>
155-
<div ref={ideRef}>
156-
<CountText>
157-
<span style={{ fontWeight: 600, color: 'white' }}>
158-
{sandboxesCreatedCount}{' '}
159-
</span>
160-
{sandboxesCreatedCount === 1 ? 'sandbox' : 'sandboxes'} created
161-
since you opened this page
162-
</CountText>
163-
164-
<div style={{ position: 'relative' }}>
165-
<StyledEditorLink
166-
href="/s/m7q0r29nn9"
167-
target="_blank"
168-
rel="noreferrer noopener"
169-
>
170-
<InspiredText>
171-
Inspired by the sandboxes created by drcmda
172-
</InspiredText>
173-
Open Sandbox
174-
</StyledEditorLink>
175-
176-
<HeroImage alt="editor with project open" src={hero} />
146+
<motion.div
147+
initial={{ opacity: 0, y: 40 }}
148+
animate={{ opacity: 1, y: 0 }}
149+
transition={{
150+
duration: 0.5,
151+
delay: 0.3,
152+
}}
153+
>
154+
<HeroBottom>
155+
<div ref={ideRef}>
156+
<CountText>
157+
<span style={{ fontWeight: 600, color: 'white' }}>
158+
{sandboxesCreatedCount}{' '}
159+
</span>
160+
{sandboxesCreatedCount === 1 ? 'sandbox' : 'sandboxes'} created
161+
since you opened this page
162+
</CountText>
163+
164+
<div style={{ position: 'relative' }}>
165+
<StyledEditorLink
166+
href="/s/m7q0r29nn9"
167+
target="_blank"
168+
rel="noreferrer noopener"
169+
>
170+
<InspiredText>
171+
Inspired by the sandboxes created by drcmda
172+
</InspiredText>
173+
Open Sandbox
174+
</StyledEditorLink>
175+
176+
<HeroImage alt="editor with project open" src={hero} />
177+
</div>
177178
</div>
178-
</div>
179-
</HeroBottom>
179+
</HeroBottom>
180+
</motion.div>
180181

181182
<Border />
182183
</HeroWrapper>

0 commit comments

Comments
 (0)