Skip to content

Commit

Permalink
✨ card 표시 transition 추가
Browse files Browse the repository at this point in the history
- 뷰포트에서 보여질 때 transition 추가 (opacity, transform)
  - intersectionObserver API 사용
  • Loading branch information
padosum committed Jan 1, 2023
1 parent 82f3e3a commit e84141e
Show file tree
Hide file tree
Showing 3 changed files with 788 additions and 36 deletions.
22 changes: 21 additions & 1 deletion src/client/App.js
Expand Up @@ -62,8 +62,28 @@ function App() {
window.addEventListener('resize', resizeAllGridItems);

resizeAllGridItems();
}

const achievements = [...document.querySelectorAll('.achievement-wrapper')];
achievements.forEach(item => {
let options = {
root: null,
rootMargin: '0px',
threshold: 0.3,
};

let observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
const title = entry.target.querySelector('.achievement-title').innerHTML;
if (entry.isIntersecting) {
entry.target.classList.remove('tilt');
} else {
entry.target.classList.add('tilt');
}
});
}, options);
observer.observe(item);
});
}
App();

if (module.hot) {
Expand Down

0 comments on commit e84141e

Please sign in to comment.