mirror of
				https://github.com/scinote-eln/scinote-web.git
				synced 2025-10-25 13:37:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			16 lines
		
	
	
	
		
			358 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
	
		
			358 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| export default function isInViewPort(el) {
 | |
|   if (!el) return;
 | |
| 
 | |
|   const rect = el.getBoundingClientRect();
 | |
| 
 | |
|   return (
 | |
|     rect.top >= 0 &&
 | |
|     rect.left >= 0 &&
 | |
|     rect.bottom <=
 | |
|       (window.innerHeight ||
 | |
|         document.documentElement.clientHeight) &&
 | |
|     rect.right <=
 | |
|       (window.innerWidth ||
 | |
|         document.documentElement.clientWidth)
 | |
|   );
 | |
| }
 |