mounted() {
this.eventScroll()
},
eventScroll() {
// 选择你想要监听的元素
const targetLogo = document.getElementById('logoanimation');
// 创建并配置IntersectionObserver
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
targetLogo.style.transform = 'scale(1)'
} else {
targetLogo.style.transform = 'scale(0)'
}
});
});
// 开始监听
observer.observe(targetLogo);
}
给要加动画效果的元素设置css样式 默认不显示
transition: transform 1s ease-in-out;
transform: scale(0);