Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery-使用animate()函数重新创建slideDown()效果?_Jquery_Jquery Effects - Fatal编程技术网

jQuery-使用animate()函数重新创建slideDown()效果?

jQuery-使用animate()函数重新创建slideDown()效果?,jquery,jquery-effects,Jquery,Jquery Effects,如何使用$.animate函数重新创建jQuery的$.slideDown效果?将“高度”、“边距”、“边距底部”、“paddingTop”和“paddingBottom”动画化为“显示” 例如: $(...).animate({ "height": "show", "marginTop": "show", "marginBottom": "show", "paddingTop": "show", "paddingBottom": "show" });

如何使用$.animate函数重新创建jQuery的$.slideDown效果?

将“高度”、“边距”、“边距底部”、“paddingTop”和“paddingBottom”动画化为
“显示”

例如:

$(...).animate({
    "height": "show",
    "marginTop": "show",
    "marginBottom": "show",
    "paddingTop": "show",
    "paddingBottom": "show"
});
源代码:jQuery源代码

fxAttrs = [
    // height animations
    [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
    // width animations
    [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
    // opacity animations
    [ "opacity" ]
];
...

jQuery.each({
    slideDown: genFx("show", 1),
    slideUp: genFx("hide", 1),
    slideToggle: genFx("toggle", 1),
    fadeIn: { opacity: "show" },
    fadeOut: { opacity: "hide" }
}, function( name, props ) {
    jQuery.fn[ name ] = function( speed, callback ) {
        return this.animate( props, speed, callback );
    };
});
...

function genFx( type, num ) {
    var obj = {};

    jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
        obj[ this ] = type;
    });

    return obj;
}

为什么不直接使用slideDown()?因为animate()有一个步骤选项,我可以将一个函数附加到该选项上。假设这是隐藏的show instad for
。slideUp()