javascript - why doesn't this line of code work? -
im trying make user can't click #shareheart twice in row, making animation screw up. maybe i'm trying create active state without adding , removing classes?
why doesn't work? first piece of code what's not working, it's not following if statement, did wrong here?
if($('.share-text').not(':animated') && $('.share-text span').is(':visible')) { // }
here's full code:
$('#shareheart').click(function() { if ($('.share-text:animated').length == 0 && $('.share-text span').is(':visible')) { $('.share-text span').animate({'opacity': '0'}, 800, function() { $("#share-what").fadeout(400) $('.share-text').stop(true, false).animate({'width': 'toggle','padding-left': 'toggle','padding-right': 'toggle'}, 800) $('#short-url').css('background-image', "url('images/drink.png')"); }) } else { $('.share-text').stop(false, true).animate({'width': 'toggle','padding-left': 'toggle','padding-right': 'toggle'}, 800, function() { $('.share-text span').animate({'opacity': '1'}, 800) }); } });
alternatively, can combine condition single selector:
if($(".share-text:not(:animated) span:visible").length) { }
the condition return 0
(a false value) if share-text
animated, or if span invisible.
Comments
Post a Comment