Skip to content

Instantly share code, notes, and snippets.

@zeshanshani
Last active July 4, 2016 08:35
Show Gist options
  • Save zeshanshani/69ebe8ac087060b3676a7ba94211f5e4 to your computer and use it in GitHub Desktop.
Save zeshanshani/69ebe8ac087060b3676a7ba94211f5e4 to your computer and use it in GitHub Desktop.
Full Screen Banner with Offset. Default offset is header only.
/**
* Full Screen Banner with Offset Value
*
* Author: Zeshan Ahmed
* Author URI: http://www.zeshanahmed.com/
*/
jQuery(document).ready(function($) {
// To run on homepage only. Remove/update if required on other pages.
if ($('body').hasClass('home')) {
var $win = $(window),
$el = $('.visual'), // Banner selector.
$header = $('#header'); // Header selector.
function bannerFullScreenWithOffset() {
// To run only on > 1024px screens. Remove/update to run on all sizes.
if ($win.width() > 1024) {
var headerH = $header.outerHeight(),
height = $win.outerHeight() - headerH;
$el.css('max-height', height); // default is max-height, change to 'height' for fixed height.
}
}
// Run the function on 'ready' and 'resize'
$win.ready(bannerFullScreenWithOffset).resize(bannerFullScreenWithOffset);
// Run the function on 'load'. Also run it with 500ms delay on page load.
$win.load(function() {
bannerFullScreenWithOffset();
setTimeout(function() {
bannerFullScreenWithOffset();
}, 500);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment