Skip to content

Instantly share code, notes, and snippets.

@NickDeckerDevs
Last active April 25, 2017 15:17
Show Gist options
  • Save NickDeckerDevs/617f81e834795e3aba68c2946c332e32 to your computer and use it in GitHub Desktop.
Save NickDeckerDevs/617f81e834795e3aba68c2946c332e32 to your computer and use it in GitHub Desktop.
Thread - Fix Orange Band Positioning
function fixBandPositioning(targetClass) {
if(!bandExists(targetClass)) return false;
$('.band-wrapper.'+targetClass).each(function() {
var currentBand = $(this);
if(window.outerWidth > 767) {
var bandHeight = currentBand.outerHeight();
var bandOffset = bandHeight / -Math.abs(4.233);
var bandMargin = (Math.round(bandOffset * 1000) / 1000) + 'px';
var bandContentOffset = (Math.round(Math.abs(bandOffset) * 1000) / 1000) + 'px';
currentBand.css('margin-left', bandMargin);
currentBand.find('> .band-skew').css('margin-left', bandContentOffset);
} else {
var bandMargin = currentBand.css('margin-left');
var bandContentOffset = currentBand.find('> .band-skew').css('margin-left')
if(bandMargin != '0px') {
currentBand.css('margin-left', '0px');
}
if(bandContentOffset != '0px') {
currentBand.find('> .band-skew').css('margin-left', '0px');
}
}
});
}
function bandExists(targetBand) {
if($('.band-wrapper.'+targetBand).length > 0) {
return true;
}
return false;
}
$(window).load(function() {
fixBandPositioning('left');
fixBandPositioning('right');
});
$(window).on('resize', function() {
fixBandPositioning('left');
fixBandPositioning('right');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment