| 
									
										
										
										
											2018-01-30 09:38:14 -08:00
										 |  |  | <div class="pseudo-virtual-list-item" | 
					
						
							| 
									
										
										
										
											2018-01-30 21:02:07 -08:00
										 |  |  |      aria-hidden="{{hide}}" | 
					
						
							| 
									
										
										
										
											2018-01-30 09:38:14 -08:00
										 |  |  |      pseudo-virtual-list-key="{{key}}" | 
					
						
							| 
									
										
										
										
											2018-01-30 21:17:01 -08:00
										 |  |  |      style="height: {{shouldHide ? `${height}px` : ''}};" | 
					
						
							| 
									
										
										
										
											2018-01-30 09:38:14 -08:00
										 |  |  |      ref:node> | 
					
						
							| 
									
										
										
										
											2018-01-30 21:17:01 -08:00
										 |  |  |   {{#if !shouldHide}} | 
					
						
							| 
									
										
										
										
											2018-01-30 09:38:14 -08:00
										 |  |  |     <:Component {component} | 
					
						
							|  |  |  |                 virtualProps="{{props}}" | 
					
						
							|  |  |  |                 virtualIndex="{{index}}" | 
					
						
							| 
									
										
										
										
											2018-02-04 10:05:01 -08:00
										 |  |  |                 virtualLength="{{length}}" | 
					
						
							| 
									
										
										
										
											2018-01-30 09:38:14 -08:00
										 |  |  |     /> | 
					
						
							|  |  |  |   {{/if}} | 
					
						
							| 
									
										
										
										
											2018-01-29 19:22:28 -08:00
										 |  |  | </div> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-30 21:17:01 -08:00
										 |  |  |   import { scheduleIdleTask } from '../../_utils/scheduleIdleTask' | 
					
						
							|  |  |  |   import { mark, stop } from '../../_utils/marks' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-29 19:22:28 -08:00
										 |  |  |   export default { | 
					
						
							|  |  |  |     oncreate() { | 
					
						
							| 
									
										
										
										
											2018-01-30 21:17:01 -08:00
										 |  |  |       this.observe('isIntersecting', isIntersecting => { | 
					
						
							|  |  |  |         if (isIntersecting) { | 
					
						
							|  |  |  |           mark('render') | 
					
						
							|  |  |  |           this.set({hide: false}) | 
					
						
							|  |  |  |           stop('render') | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           // unrender lazily; it's not a critical UI task | 
					
						
							|  |  |  |           scheduleIdleTask(() => { | 
					
						
							|  |  |  |             mark('unrender') | 
					
						
							|  |  |  |             if (!this.get('isIntersecting')) { | 
					
						
							|  |  |  |               this.set({hide: true}) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             stop('unrender') | 
					
						
							|  |  |  |           }) | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-30 09:38:14 -08:00
										 |  |  |       let intersectionObserver = this.get('intersectionObserver') | 
					
						
							|  |  |  |       intersectionObserver.observe(this.refs.node) | 
					
						
							| 
									
										
										
										
											2018-01-30 21:17:01 -08:00
										 |  |  |     }, | 
					
						
							|  |  |  |     computed: { | 
					
						
							|  |  |  |       shouldHide: (isIntersecting, isCached, hide) => { | 
					
						
							|  |  |  |         if (isCached) { | 
					
						
							|  |  |  |           return true // if it's cached, always unrender immediately until proven it's intersecting | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return !isIntersecting && hide | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-01-29 19:22:28 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | </script> |