Skip to content

Commit

Permalink
feat: motion sticky
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Dec 25, 2024
1 parent 9cfad3c commit b2d71bb
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 145 deletions.
61 changes: 61 additions & 0 deletions src/components/stateless/HorizontalScroll/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useRef } from 'react'

Check warning on line 1 in src/components/stateless/HorizontalScroll/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import { useRef } from 'react'

Check failure on line 1 in src/components/stateless/HorizontalScroll/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Install the 'eslint' package
import { motion, useTransform, useScroll } from 'motion/react'

Check warning on line 2 in src/components/stateless/HorizontalScroll/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused ``` import { motion, useTransform, useScroll } from 'motion/react' ```

const cards = [
{
url: 'https://picsum.photos/id/28/400/267',
title: 'Title 1',
id: 1,
},
{
url: 'https://picsum.photos/id/29/400/267',
title: 'Title 2',
id: 2,
},
{
url: 'https://picsum.photos/id/30/400/267',
title: 'Title 3',
id: 3,
},
{
url: 'https://picsum.photos/id/31/400/267',
title: 'Title 4',
id: 4,
},
{
url: 'https://picsum.photos/id/32/400/267',
title: 'Title 5',
id: 5,
},
]
const HorizontalScrollParallax = () => {
return (
<>
{cards.map((card) => (
<Card card={card} key={card.id} />
))}
</>
)
}

const Card = ({ card }) => {
return (
<div key={card.id} className="group relative h-[267px] w-[400px] overflow-hidden ">
<div
style={{
backgroundImage: `url(${card.url})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
}}
className="absolute inset-0 z-0 transition-transform duration-300 group-hover:scale-110"
></div>
<div className="absolute inset-0 z-10 grid place-content-center">
<p className="p-8 text-6xl font-black text-white uppercase bg-gradient-to-br from-white/20 to-white/0 backdrop-blur-lg">
{card.title}
</p>
</div>
</div>
)
}

export default HorizontalScrollParallax
34 changes: 0 additions & 34 deletions src/pages/motion/index.css

This file was deleted.

Loading

0 comments on commit b2d71bb

Please sign in to comment.