| 
									
										
										
										
											2018-05-01 17:05:36 -07:00
										 |  |  | <div class="virtual-list-header {shown ? 'shown' : ''} {fadedIn ? 'faded-in' : ''}" | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  |      ref:node > | 
					
						
							| 
									
										
										
										
											2018-05-01 17:05:36 -07:00
										 |  |  |   <svelte:component this={component} {virtualProps} /> | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  | </div> | 
					
						
							|  |  |  | <style> | 
					
						
							|  |  |  |   .virtual-list-header { | 
					
						
							|  |  |  |     position: absolute; | 
					
						
							|  |  |  |     top: 0; | 
					
						
							|  |  |  |     width: 100%; | 
					
						
							|  |  |  |     opacity: 0; | 
					
						
							|  |  |  |     z-index: 10; | 
					
						
							| 
									
										
										
										
											2018-02-11 22:50:20 -08:00
										 |  |  |     transition: none; | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |     display: none; | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   .virtual-list-header.shown { | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |     display: block; | 
					
						
							| 
									
										
										
										
											2018-02-11 22:50:20 -08:00
										 |  |  |     transition: opacity 0.333s linear; | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |   .virtual-list-header.faded-in { | 
					
						
							|  |  |  |     opacity: 1; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  | </style> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  |   import { virtualListStore } from './virtualListStore' | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |   import { doubleRAF } from '../../_utils/doubleRAF' | 
					
						
							| 
									
										
										
										
											2018-04-27 09:21:30 -07:00
										 |  |  |   import { mark, stop } from '../../_utils/marks' | 
					
						
							| 
									
										
										
										
											2018-04-30 08:29:04 -07:00
										 |  |  |   import { observe } from 'svelte-extras' | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   export default { | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:01 -07:00
										 |  |  |     oncreate () { | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |       this.observe('shown', shown => { | 
					
						
							|  |  |  |         if (shown) { | 
					
						
							|  |  |  |           this.doCalculateHeight() | 
					
						
							| 
									
										
										
										
											2018-08-29 21:42:57 -07:00
										 |  |  |           doubleRAF(() => this.set({ fadedIn: true })) //  animate in | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2018-08-29 21:42:57 -07:00
										 |  |  |           this.set({ fadedIn: false }) | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-08-29 21:42:57 -07:00
										 |  |  |       }, { init: false }) | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2018-04-29 22:13:41 -07:00
										 |  |  |     data: () => ({ | 
					
						
							|  |  |  |       fadedIn: false | 
					
						
							|  |  |  |     }), | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  |     store: () => virtualListStore, | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |     methods: { | 
					
						
							| 
									
										
										
										
											2018-04-30 08:29:04 -07:00
										 |  |  |       observe, | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:01 -07:00
										 |  |  |       doCalculateHeight () { | 
					
						
							| 
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 |  |  |         let { heightCalculated } = this.get() | 
					
						
							|  |  |  |         if (heightCalculated) { // only need to calculate once, it never changes | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |           return | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-08-29 21:42:57 -07:00
										 |  |  |         this.set({ heightCalculated: true }) | 
					
						
							| 
									
										
										
										
											2018-04-27 09:21:30 -07:00
										 |  |  |         requestAnimationFrame(() => { | 
					
						
							|  |  |  |           mark('VirtualListHeader gBCR') | 
					
						
							|  |  |  |           let rect = this.refs.node.getBoundingClientRect() | 
					
						
							|  |  |  |           stop('VirtualListHeader gBCR') | 
					
						
							| 
									
										
										
										
											2018-08-29 21:42:57 -07:00
										 |  |  |           this.store.setForRealm({ headerHeight: rect.height }) | 
					
						
							| 
									
										
										
										
											2018-04-12 21:17:57 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-02-11 19:15:21 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | </script> |