Sha256: ea62043c514ba6e1439bdf5486c982a14f08b8843b6f7362e42358850e26f7c0
Contents?: true
Size: 952 Bytes
Versions: 5
Compression:
Stored size: 952 Bytes
Contents
$(document).ready(function() { if ($("#js-parallax-window").length) { parallax(); } }); $(window).scroll(function(e) { if ($("#js-parallax-window").length) { parallax(); } }); function parallax(){ if( $("#js-parallax-window").length > 0 ) { var plxBackground = $("#js-parallax-background"); var plxWindow = $("#js-parallax-window"); var plxWindowTopToPageTop = $(plxWindow).offset().top; var windowTopToPageTop = $(window).scrollTop(); var plxWindowTopToWindowTop = plxWindowTopToPageTop - windowTopToPageTop; var plxBackgroundTopToPageTop = $(plxBackground).offset().top; var windowInnerHeight = window.innerHeight; var plxBackgroundTopToWindowTop = plxBackgroundTopToPageTop - windowTopToPageTop; var plxBackgroundTopToWindowBottom = windowInnerHeight - plxBackgroundTopToWindowTop; var plxSpeed = 0.35; plxBackground.css('top', - (plxWindowTopToWindowTop * plxSpeed) + 'px'); } }
Version data entries
5 entries across 5 versions & 2 rubygems