Skip to content

Instantly share code, notes, and snippets.

@elricco
Created July 19, 2018 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elricco/52eda4083a7bebfd5050fa758013cb21 to your computer and use it in GitHub Desktop.
Save elricco/52eda4083a7bebfd5050fa758013cb21 to your computer and use it in GitHub Desktop.
$(function() {
function fullpageElement($indicator, $selector) {
let indicatorHeight = $indicator.height();
let indicatorWidth = $indicator.width();
let indicator = indicatorHeight;
let $selectedElement = $selector;
if((100 * indicatorHeight) / indicatorWidth < 56.25) {
indicator = indicatorWidth;
$selectedElement.height((indicator/100)*56.25);
$selectedElement.width(indicator);
} else {
indicator = indicatorHeight;
$selectedElement.height(indicator);
$selectedElement.width((indicator/56.25)*100);
}
positionElements($selectedElement);
}
function positionElements(selector) {
selector.each(function(index) {
var thewidth = $(this).width() / 2;
var theheight = $(this).height() / 2;
//console.log(thewidth + ' ' + theheight);
$(this).css({
'margin-left':-thewidth,
'margin-top':-theheight
});
});
}
$(window).on('resize', function() {
fullpageElement($('#index-login'), $('#video-fullpage'));
console.log('resize');
});
fullpageElement($('#index-login'), $('#video-fullpage'));
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment