| 157 | |
| 158 | // 设置交叉观察器 (with cleanup) |
| 159 | setupIntersectionObserver() { |
| 160 | if (!('IntersectionObserver' in window)) return; |
| 161 | |
| 162 | const observer = new IntersectionObserver((entries) => { |
| 163 | entries.forEach(entry => { |
| 164 | if (entry.isIntersecting) { |
| 165 | entry.target.classList.add('animate-in'); |
| 166 | // Optionally unobserve after animation |
| 167 | observer.unobserve(entry.target); |
| 168 | } |
| 169 | }); |
| 170 | }, { |
| 171 | threshold: 0.1, |
| 172 | rootMargin: '0px 0px -50px 0px' |
| 173 | }); |
| 174 | |
| 175 | document.querySelectorAll('[data-animate]').forEach(el => { |
| 176 | observer.observe(el); |
| 177 | }); |
| 178 | |
| 179 | // Store observer for cleanup |
| 180 | this.observers.set('animations', observer); |
| 181 | } |
| 182 | |
| 183 | // 触摸优化 |
| 184 | setupTouchOptimization() { |