Skip to content

Instantly share code, notes, and snippets.

View ddave592's full-sized avatar

David Gomes ddave592

View GitHub Profile
@ddave592
ddave592 / handleVisibleOnScroll.js
Last active December 19, 2019 17:26
event listener that adds class to element when in view
if (window.location.href.match(/\/500k-tournament-special-test/g)) {
const onLoadScrollHandler = () => {
var $window = window;
var $elem = document.getElementById("animation");
function isScrolledIntoView($elem, $window) {
var docViewTop = document.documentElement.scrollTop;
var docViewBottom = docViewTop + $window.innerHeight;
var elemTop = $elem.getBoundingClientRect().top;