Skip to content

Instantly share code, notes, and snippets.

View iliketomatoes's full-sized avatar

Giancarlo Soverini iliketomatoes

View GitHub Profile
@iliketomatoes
iliketomatoes / is-element-in-viewport.js
Last active March 8, 2016 08:57
Determine if an element is inside the window viewport
/**
* Determine if an element is in the viewport
* @param {HTMLElement} el
* @return {Boolean}
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&