animating 'left' setting for a show-hide thingie...
don't get why this is not working...
- // default 'left' setting set at -200px in CSS... tried setting in JS for testing, doesn't work...
- // $('#main_nav').css('left',-200);
- mainNav_pos = $('#main_nav').css('left');
- console.log('mainNav_pos -- ' + mainNav_pos + ' -- initial');
-
- $('a#bars').click(function(e) {
- e.preventDefault();
- console.log(mainNav_pos);
- if (mainNav_pos < -100) {
- console.log('hidden');
- $('#main_nav').animate( { left:1 });
- }
- if (mainNav_pos > 0) {
- console.log(mainNav_pos);
- $('#main_nav').animate( { left: -200 });
- }
- });
in order to test whether element is visible or not, I have to test by asking whether "left" setting is greater-than or less-than a certain numerical value, since, viewing test stmts in console, sometimes if you set at, say -200, browser sets it at something like -198.8...
stmts like
if (mainNav_pos > 0) don't work (are ignored...) how can I make this work?
would appreciate some help...
thank you....