Bug Tracker

Opened 10 years ago

Closed 8 years ago

#4660 closed enhancement (worksforme)

fadeTo() does not fade-in elements after hide() or fadeOut() is called on them

Reported by: zachstronaut Owned by: timmywil
Priority: low Milestone: 1.7
Component: effects Version: 1.3.2
Keywords: fade, fadeOut, hide, fadeTo, 1.7-discuss Cc:
Blocked by: Blocking:

Description (last modified by ajpiano)

If you call $('#foo').hide() or $('#foo).fadeOut() then calling $('#foo').fadeTo(1000, 0.5) will NOT fade the element back in to 50% opacity.

You must do $('#foo').css('opacity', 0).show().fadeTo(1000, 0.5) which gets kind of old.

The fadeTo() method could be patched to do this on its own:

(function ($) {

var proxied = $.fn.fadeTo; $.fn.fadeTo = function() {

if ($(this).is(':hidden')) {

$(this).css('opacity', 0).show();

}

return proxied.apply(this, arguments);

}

})(jQuery);

Rather than proxy patching fadeTo() it would be nice if the method itself were patched in the jQuery library code.

Change History (20)

comment:2 Changed 10 years ago by mofle

This should really be fixed for 1.4.

comment:20 Changed 9 years ago by mattlunn

Wow... 10 months. This is old, tiring, and not very clean!

1.4 was out looooong ago :(

comment:21 Changed 9 years ago by SlexAxton

Milestone: 1.41.5
Priority: minorlow
Status: newopen

comment:22 Changed 8 years ago by john

Milestone: 1.next

We should look at fixing this properly in 1.7.

comment:23 Changed 8 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:24 Changed 8 years ago by dmethvin

+1, Seems like .fadeTo() should show hidden elements, shouldn't have back-compat issues.

comment:25 Changed 8 years ago by Rick Waldron

Description: modified (diff)

+1, Seems obvious

comment:26 Changed 8 years ago by jaubourg

+1, Looks like a bug to me.

comment:27 Changed 8 years ago by ajpiano

Description: modified (diff)

+1,

comment:28 Changed 8 years ago by timmywil

Description: modified (diff)

+1,

comment:29 Changed 8 years ago by danheberden

+1

comment:30 Changed 8 years ago by john

+1, Seems like we could just make sure it's visible before animating.

comment:31 Changed 8 years ago by scottgonzalez

+1

comment:32 Changed 8 years ago by addyosmani

+1

comment:33 Changed 8 years ago by jzaefferer

+1

comment:34 Changed 8 years ago by cowboy

+1

comment:35 Changed 8 years ago by ajpiano

Description: modified (diff)
Milestone: 1.next1.7

comment:36 Changed 8 years ago by gnarf

Owner: set to gnarf
Status: openassigned

comment:37 Changed 8 years ago by timmywil

Owner: changed from gnarf to timmywil

picking this one up

comment:38 Changed 8 years ago by timmywil

Resolution: worksforme
Status: assignedclosed

Looks like this is already fixed. http://jsfiddle.net/timmywil/cdrYt/

Let's always have test cases in tickets. ;)

Note: See TracTickets for help on using tickets.