Created
November 7, 2016 19:29
-
-
Save javanigus/d2c78cae0ba9eee7609e14a8d4358679 to your computer and use it in GitHub Desktop.
Fade out and slide element upwards as user scroll down
This file contains 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
(function ($) { | |
"use strict"; | |
// as user scrolls down / up, fade and move banner text | |
$(document).on("ready", function () { | |
var reFadeAndTranslate, deReFadeAndTranslate, \$bannerText; | |
\$bannerText = $("div.banner-text"); | |
reFadeAndTranslate = function () { | |
\$bannerText.css({ | |
"opacity": 1 - $(window).scrollTop() / 500, | |
"transform": "translateY(" + -($(window).scrollTop()/5) + "px)" | |
}); | |
} | |
deReFadeAndTranslate = _.debounce(reFadeAndTranslate, 10); | |
$(window).on("scroll", deReFadeAndTranslate); | |
}); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment