Created
June 26, 2012 20:53
-
-
Save ericwwsun/2998882 to your computer and use it in GitHub Desktop.
Javascript: Background Position control by js, IE8 included
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
var backgroundPos, | |
xPos, | |
yPos; | |
if( $j("html").hasClass("ie8")) { // html class... you know... it's useful | |
xPos = $j(this).css("background-position-x"); | |
yPos = Number($j(this).css("background-position-y").replace(/[^0-9-]/g, '')); | |
} else { | |
backgroundPos = $j(this).css("backgroundPosition").split(" "); | |
xPos = backgroundPos[0], | |
yPos = Number(backgroundPos[1].replace(/[^0-9-]/g, '')); | |
} | |
yPos = yPos + 310; // this value will be the y shift distance in your background image | |
$j(this).css("backgroundPosition", xPos + " " + yPos+ "px"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment