mirror of
https://github.com/hanzo-apps/hanzo.io.git
synced 2026-10-30 19:15:19 +00:00
23 lines
578 B
JavaScript
23 lines
578 B
JavaScript
$(function(){
|
|
var scheduled = false;
|
|
$(window).on('scroll touchmove mousewheel', function(){
|
|
if (!scheduled) {
|
|
requestAnimationFrame(function(){
|
|
var $els = $('.parallax .foreground');
|
|
var scrollTop = $(this).scrollTop();
|
|
|
|
$els.each(function() {
|
|
var $el = $(this);
|
|
var offset = $el.offset();
|
|
|
|
var yOffset = 50 + 100 * ((scrollTop-offset.top)/$el.height());
|
|
|
|
$el.css('background-position', '50% ' + yOffset + '%');
|
|
})
|
|
scheduled = false;
|
|
})
|
|
scheduled = true;
|
|
}
|
|
});
|
|
});
|