Created
March 1, 2013 00:35
-
-
Save boovius/5061451 to your computer and use it in GitHub Desktop.
Based off of Events and Scope video ... trying to get it so that it understands if the margin is greater than where it starts (5px) it will call the moveBack() function. This works but if someone clicks on a square twice before the animation has completed, it won't respond, since the margin-right must = 100px for the moveBack() to be called. Is …
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(){ | |
console.log(this); | |
function moveRight(el) { | |
$(el).animate({marginRight: 100 }, 1000); | |
} | |
function moveBack(el) { | |
$(el).animate({marginRight: 5 }, 1000 ); | |
} | |
$('#boxes li').on('click', function(){ | |
moveRight(this); | |
if ($(this).css("margin-right") === "100px" ) { | |
moveBack(this); | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment