open-consul/website/source/assets/javascripts/app/homepage.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-04-05 09:03:01 +00:00
//homepage.js
var APP = APP || {};
(function () {
APP.Homepage = (function () {
return {
ui : null,
init: function () {
var _this = this;
//cache elements
this.ui = {
$doc: $(window),
2014-04-09 04:00:59 +00:00
$hero: $('#jumbotron'),
$collapse: $('.navbar-collapse')
2014-04-05 09:03:01 +00:00
}
this.addEventListeners();
},
addEventListeners: function(){
var _this = this;
if(APP.Utils.isMobile)
return;
_this.ui.$doc.scroll(function() {
2014-04-09 04:00:59 +00:00
//if collapseable menu is open dont do parrallax. It looks wonky. Bootstrap conflict
if( _this.ui.$collapse.hasClass('in'))
return;
2014-04-05 09:03:01 +00:00
var top = _this.ui.$doc.scrollTop(),
speedAdj = (top*0.8),
speedAdjOffset = speedAdj - top;
_this.ui.$hero.css('webkitTransform', 'translate(0, '+ speedAdj +'px)');
_this.ui.$hero.find('.container').css('webkitTransform', 'translate(0, '+ speedAdjOffset +'px)');
})
}
}
}());
}(jQuery, this));