Именно эта линия вызывает мерцание. Я написал это расширение, чтобы удалить строку из функции шоу. Обратите внимание, что он всегда устанавливает для элемента отображения значение «блок».
Я в конце концов решил это по-другому. Я использовал элемент span и изменил его на div.
/** fixes flicker in jQuery show function */
var fxAttrs = [
// height animations
[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
// width animations
[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
// opacity animations
[ "opacity" ]
];
function genFx( type, num ){
var obj = {};
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){
obj[ this ] = type;
});
return obj;
}
(function($){
$.fn.extend({
show: function(speed,callback){
if ( speed ) {
return this.animate(genFx("show", 3), speed, callback);
} else {
for ( var i = 0, l = this.length; i < l; i++ ){
var old = jQuery.data(this[i], "olddisplay");
this[i].style.display = old || "";
if ( jQuery.css(this[i], "display") === "none" ) {
jQuery.data(this[i], "olddisplay", 'block');
}
}
// Set the display of the elements in a second loop
// to avoid the constant reflow
for ( var i = 0, l = this.length; i < l; i++ ){
this[i].style.display = jQuery.data(this[i], "olddisplay") || "";
}
return this;
}
}
});
})(jQuery);