gpt4 book ai didi

javascript - 我在哪里可以找到 JQuery 方法的实际代码?

转载 作者:行者123 更新时间:2023-11-30 07:40:15 24 4
gpt4 key购买 nike

有什么地方可以让我看到实际的代码以及 JQuery 方法的构造方式吗?例如,如何对 fadeIn() 和 slideUp() 方法进行编码?我想要它用于学习/研究目的,我尝试查看 JQuery.js 文件,但它很难阅读。然后我尝试去这里阅读:

http://code.jquery.com/jquery-2.0.3.js

但后来我找不到 slideUp 和 fadeIn 方法的实际代码。

最佳答案

我相信就是这样(它在链接的文件中;将其作为评论发布,但它太难破译了):

// Generate shortcuts for custom animations
jQuery.each({
slideDown: genFx("show"),
slideUp: genFx("hide"),
slideToggle: genFx("toggle"),
fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" },
fadeToggle: { opacity: "toggle" }
}, function( name, props ) {
jQuery.fn[ name ] = function( speed, easing, callback ) {
return this.animate( props, speed, easing, callback );
};
});

genFx 引用了这个方法(用于slideup\down):

// Generate parameters to create a standard animation
function genFx( type, includeWidth ) {
var which,
attrs = { height: type },
i = 0;

// if we include width, step value is 1 to do all cssExpand values,
// if we don't include width, step value is 2 to skip over Left and Right
includeWidth = includeWidth? 1 : 0;
for( ; i < 4 ; i += 2 - includeWidth ) {
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
}

if ( includeWidth ) {
attrs.opacity = attrs.width = type;
}

return attrs;
}

我猜它调用了涵盖通用功能的其他方法。这是我找到的唯一声明。

关于javascript - 我在哪里可以找到 JQuery 方法的实际代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19287041/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com