MCPcopy Create free account
hub / github.com/Silentely/eSIM-Tools / setupIntersectionObserver

Method setupIntersectionObserver

src/js/performance.js:159–181  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers 1

initMethod · 0.95

Calls 3

unobserveMethod · 0.95
observeMethod · 0.95
setMethod · 0.45

Tested by

no test coverage detected