remove unnecessary rAF
This commit is contained in:
		
							parent
							
								
									436c8c05aa
								
							
						
					
					
						commit
						c97937eced
					
				
					 1 changed files with 22 additions and 19 deletions
				
			
		|  | @ -20,28 +20,31 @@ | ||||||
|   } |   } | ||||||
| </style> | </style> | ||||||
| <script> | <script> | ||||||
|  | 
 | ||||||
|  |   import { mark, stop } from '../_utils/marks' | ||||||
|  | 
 | ||||||
|   export default { |   export default { | ||||||
|     oncreate() { |     oncreate() { | ||||||
|       requestAnimationFrame(() => { |       mark('LazyImage oncreate()') | ||||||
|         let img = new Image() |       let img = new Image() | ||||||
|         let src = this.get('src') |       let src = this.get('src') | ||||||
|         let fallback = this.get('fallback') |       let fallback = this.get('fallback') | ||||||
|         img.onload = () => { |       img.onload = () => { | ||||||
|           requestAnimationFrame(() => { |         requestAnimationFrame(() => { | ||||||
|             this.set({ |           this.set({ | ||||||
|               displaySrc: src, |             displaySrc: src, | ||||||
|               hidden: true |             hidden: true | ||||||
|             }) |  | ||||||
|             requestAnimationFrame(() => { |  | ||||||
|               this.set({hidden: false}) |  | ||||||
|             }) |  | ||||||
|           }) |           }) | ||||||
|         } |           requestAnimationFrame(() => { | ||||||
|         img.onerror = () => { |             this.set({hidden: false}) | ||||||
|           this.set({displaySrc: fallback}) |           }) | ||||||
|         } |         }) | ||||||
|         img.src = src |       } | ||||||
|       }) |       img.onerror = () => { | ||||||
|  |         this.set({displaySrc: fallback}) | ||||||
|  |       } | ||||||
|  |       img.src = src | ||||||
|  |       stop('LazyImage oncreate()') | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| </script> | </script> | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue