Created
August 14, 2010 05:35
-
-
Save kylehotchkiss/524024 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 getOffset() { | |
/* Get the offset for moving the nav */ | |
var width = $(document).width(); | |
var margin = (width - 720) / 2; | |
var offset = $(".place.display").offset(); | |
var position = $(".places").css("marginLeft"); | |
position = parseInt(position.substring(0, position.indexOf("p"))); | |
console.log(position); | |
if ( margin > offset.left ) { | |
if ( position < 0 ) { | |
var displacement = (-1 * offset.left) + margin; | |
console.log("Rule 3: Behind margin @ " + displacement + "px."); | |
return position + displacement; | |
} else { | |
var displacement = margin - offset.left; | |
console.log("Rule 2: Behind margin @ " + displacement + "px."); | |
return position + displacement; | |
} | |
} else { | |
var displacement = offset.left - margin; | |
console.log("Rule 1: Ahead of margin @ " + displacement + "px."); | |
return position - displacement; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment