Last active
July 14, 2019 10:23
-
-
Save haydenbleasel/9301427 to your computer and use it in GitHub Desktop.
Medium-style vertical fading parallax scroll modifier for Stellar.js
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
// Custom transform and opacity modifier for Stellar.js | |
$.stellar.positionProperty.transfade = { | |
setPosition: function(element, newLeft, originalLeft, newTop, originalTop) { | |
var distance = newTop - originalTop; | |
var rate = $(window).height() / 5; | |
element.css('transform', 'translate3d(0, ' + distance + 'px, 0').css('opacity', 1 - (distance / rate)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesomecake.