Last active
April 25, 2017 15:17
-
-
Save NickDeckerDevs/617f81e834795e3aba68c2946c332e32 to your computer and use it in GitHub Desktop.
Thread - Fix Orange Band Positioning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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