-
-
Save phaedryx/b760765e5449a95e0318 to your computer and use it in GitHub Desktop.
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
/* | |
This is what I have so far. The first part makes sure that the basket is invisible and that the basket link fades in on page load. | |
The second part is where I'm having the trouble. I need the top margin of both basket and basketlink elements to change based on their current margin-top css value. e.g. when their values are at -180px, they should be changed to 0px on the click event. | |
As far as Dw is concerned, it's all syntactically correct, but I have absolutely no idea; I only started with JavaScript this morning =/ | |
*/ | |
$(function () { | |
var d = 150; | |
$('#basket').each(function () { | |
$(this).stop().animate({ | |
'opacity': '0' | |
}, d += 150); | |
}); | |
var d = 150; | |
$('#basketlink input').each(function () { | |
$(this).stop().animate({ | |
'opacity': '1' | |
}, d += 150); | |
}); | |
$(function stuff() { | |
var margin = $('#basketlink').css('margin-top'); | |
alert(margin); | |
if (margin == '-180px') { | |
function () { | |
$('input', $(this)).stop().animate({ | |
'marginTop': '0px' | |
}, 200); | |
$('#basket').stop().animate({ | |
'marginTop': '0px', | |
'opacity': '1' | |
}, 200); | |
}); | |
} else { | |
function () { | |
$('input', $(this)).stop().animate({ | |
'marginTop': '-180px' | |
}, 200); | |
$('#basket').stop().animate({ | |
'marginTop': '-180px', | |
'opacity': '0' | |
}, 200); | |
}); | |
} | |
});); | |
$('#basketlink').click(stuff()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment