javascript - Animated add / remove class -
i'm looking use fadein / out when adding , removing of #left element in code. can remove class , animate same element?
var window_width = $(window).width(); var scroll_amount = window_width * .75; var left=$('#latest_wrapper'); $('#latest_wrapper #right').click(function() { $('#left').removeclass('none'); $('#latest_wrapper').scrollto('+=' + scroll_amount, 300); }); $('#latest_wrapper #left').click(function() { $('#latest_wrapper').scrollto('-=' + scroll_amount, 300); actual_left = left.scrollleft() - scroll_amount; if(actual_left <= 0){ $("#left").addclass('none'); } }); # html page <div id="latest_wrapper" data-offset="1"> <div id="left" class="arrow_wrapper none"> <i class="icon-angle-left"></i> </div> <div id="right" class="arrow_wrapper"> <i class="icon-angle-right"></i> </div> ... more
can remove class , animate same element? part of question can say:
$("#left").addclass('none').fadeout();
but if face css make class none display none, must animation first , add class.
$("#left").fadeout('normal', function(){ $(this).addclass('none'); });
you can same fadein()
Comments
Post a Comment