Skip to content

Instantly share code, notes, and snippets.

View hasanm95's full-sized avatar

Hasan Mobarak hasanm95

View GitHub Profile
@hasanm95
hasanm95 / Javascript Essential Functions
Created August 20, 2020 05:18
jQuery like functions by vanila javascript
//Is element in viewport
// return boolean
function isInViewport(el) {
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)