Skip to content

Commit

Permalink
feat(genesis landing): change behaviour of backgroud img
Browse files Browse the repository at this point in the history
  • Loading branch information
rulfo71 committed Sep 28, 2022
1 parent 075f465 commit 2712f35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
23 changes: 9 additions & 14 deletions src/pages/Genesis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,23 @@ import { calculateDropStyle } from '../../common/calculateDropStyle'
export default function Genesis() {
const organizersRef = useRef()
const dropRef = useRef()
const genesisContainer = useRef()

const scrollPosition = useScrollPosition()
// calculate ring background img position and opacity
let backgroundImgPosition = `${scrollPosition}px`
let dropPosition = dropRef?.current?.offsetTop
let opacityBackground =
1 - scrollPosition / (dropPosition - window.innerHeight)
let displayBackground = scrollPosition > dropPosition ? 'none' : 'block'

window.onscroll = function () {
if (scrollPosition > 0) {
var opac = scrollPosition / dropPosition
genesisContainer.current.style.boxShadow = `inset 0 0 0 1000px rgba(0,0,0,${opac})`
}
}

const { dropImgWidth, backgroundDropPosition, displaybackgroundDrop } =
calculateDropStyle(scrollPosition, dropPosition)

return (
<>
<div
className='background-image'
style={{
top: `${backgroundImgPosition}`,
opacity: `${opacityBackground}`,
display: `${displayBackground}`,
}}
></div>
<div
className='background-drop'
style={{
Expand All @@ -56,7 +51,7 @@ export default function Genesis() {
style={{ maxWidth: `${dropImgWidth}%` }}
/>
</div>
<section className='genesisContainer'>
<section className='genesisContainer' ref={genesisContainer}>
<Header active='genesis' />
<div className='genesisMainText'>
<strong>Introducing Infinite Genesis in Bogotá</strong>
Expand Down
Binary file added src/static/genesis-background-square-low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 4 additions & 15 deletions src/styles/Genesis.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
.genesisContainer {
min-height: 100vh;
padding: 50px;
position: relative;
}

.background-image {
background-image: url('../static/genesis-background-square-low-half.png');
background-image: url('../static/genesis-background-square-low.png');
background-repeat: no-repeat;
background-size: cover;
background-position: top;
background-attachment: fixed;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: auto;
min-height: 120vh;
background-size: 100%;
background-position: center;
padding: 1rem;
}

.background-drop {
Expand Down

0 comments on commit 2712f35

Please sign in to comment.