Created
September 11, 2017 15:53
-
-
Save lesleh/7cf4e18f005f536bfc16b6fcc7ab9eea to your computer and use it in GitHub Desktop.
Disable unintersected animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global IntersectionObserver */ | |
(function () { | |
'use strict' | |
var selectors = '.home-hero, .site-header__logo' | |
function callback (entries) { | |
var entry = entries[0] | |
$(entry.target).css('animation', entry.isIntersecting ? '' : 'none') | |
} | |
// Apply listeners to all animated gradient elements | |
$(function () { | |
var observer = new IntersectionObserver(callback) | |
$(selectors).each(function (i, e) { | |
observer.observe(e) | |
}) | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment