Skip to content

Commit

Permalink
Do not change a user defined display mode for elements, after show/hide
Browse files Browse the repository at this point in the history
  • Loading branch information
Kronuz committed Dec 5, 2013
1 parent 5190d40 commit be269e1
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions scripts/src/jquery.animate-enhanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,31 @@ Changelog:
// deal with shortcuts
if (!parts && val == 'show') {
cleanStart = 1;
if (hidden) e.css({'display': _domElementVisibleDisplayValue(e.context.tagName), 'opacity': 0});
} else if (!parts && val == "hide") {
if (hidden) {
elem = e[0];
if (elem.style) {
display = elem.style.display;

// Reset the inline display of this element to learn if it is
// being hidden by cascaded rules or not
if (!jQuery._data(elem, 'olddisplay') && display === 'none') {
display = elem.style.display = '';
}

// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
if ( display === '' && jQuery.css(elem, 'display') === 'none' ) {
jQuery._data(elem, 'olddisplay', _domElementVisibleDisplayValue(elem.context.tagName));

This comment has been minimized.

Copy link
@chriskuehl

chriskuehl Jan 9, 2014

Contributor

elem.context.tagName is causing an error for me in Chrome and iOS Safari (issue #146). Changing it to elem.tagName fixes the error. Any thoughts?

}

if (display === '' || display === 'none') {
elem.style.display = jQuery._data(elem, 'olddisplay') || '';
}
}
e.css('opacity', 0);
}
} else if (!parts && val == 'hide') {
cleanStart = 0;
}

Expand Down Expand Up @@ -702,7 +725,17 @@ Changelog:

// if we used the fadeOut shortcut make sure elements are display:none
if (prop.opacity === 'hide') {
self.css({'display': 'none', 'opacity': ''});
elem = self[0];
if (elem.style) {
display = jQuery.css(elem, 'display');

if (display !== 'none' && !jQuery._data(elem, 'olddisplay')) {
jQuery._data(elem, 'olddisplay', display);
}
elem.style.display = 'none';
}

self.css('opacity', '');
}

// run the main callback function
Expand Down

0 comments on commit be269e1

Please sign in to comment.