blt/assets/js/pages/homepage.page.js

43 lines
1.7 KiB
JavaScript
Raw Normal View History

parasails.registerPage('homepage', {
// ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
// ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
// ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
data: {
//…
},
// ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
// ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
// ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
beforeMount: function() {
//…
},
mounted: async function(){
this._setHeroHeight();
},
// ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
// ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
methods: {
clickHeroButton: async function() {
// Scroll to the 'get started' section:
$('html, body').animate({
scrollTop: this.$find('[purpose="scroll-destination"]').offset().top
}, 500);
},
// Private methods not tied to a particular DOM event are prefixed with _
_setHeroHeight: function() {
var $hero = this.$find('[purpose="full-page-hero"]');
var headerHeight = $('[purpose="page-header"]').outerHeight();
var heightToSet = $(window).height();
heightToSet = Math.max(heightToSet, 500);//« ensure min height of 500px - header height
heightToSet = Math.min(heightToSet, 1000);//« ensure max height of 1000px - header height
$hero.css('min-height', heightToSet - headerHeight+'px');
},
}
});