使用 jQuery 缓动的 Javascript 集成

发布于 2024-11-18 20:39:17 字数 683 浏览 7 评论 0原文

我正在努力使这段代码工作,基本上我有这一段代码:

<script type="text/javascript" src="jquery-easing.js"></script>
<script type="text/javascript">
$(document).ready(function(){

hidden = true;
$(".btn-slide").click(function () {
if(hidden == false) {

    $("#photodisplay").slideUp(1000, method, callback);
    $("#gallery").slideDown(1000, method, callback);
    hidden = true;
} else {
    $("#photodisplay").slideUp(1000, method, callback);
    $("#gallery").slideDown(1000, method, callback);
    hidden = false;
}
});
});
</script>

当使用slideUp和“慢”在Javascript中正常编写时,效果很好,但我只想包括缓动,因为目前它有点静态。 我该如何调整它才能使 jQuery 正常工作?任何帮助都会很棒,提前致谢,

索菲

I'm struggling to make this code work, basically I have this section of code:

<script type="text/javascript" src="jquery-easing.js"></script>
<script type="text/javascript">
$(document).ready(function(){

hidden = true;
$(".btn-slide").click(function () {
if(hidden == false) {

    $("#photodisplay").slideUp(1000, method, callback);
    $("#gallery").slideDown(1000, method, callback);
    hidden = true;
} else {
    $("#photodisplay").slideUp(1000, method, callback);
    $("#gallery").slideDown(1000, method, callback);
    hidden = false;
}
});
});
</script>

This when written normally in Javascript using the slideUp and 'slow' works fine but I just want to include the easing as at the moment it's a bit static.
How can I adjust this so that the jQuery works? Any help would be great, thanks in advance,

Sofi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

表情可笑 2024-11-25 20:39:17

我不确定你的意思,但lideUp和slideDown有三个参数。

.slideUp( [duration,] [easing,] [callback] )

所以你可以做的是:

$('#photodisplay').slideUp(1000, "linear", callback);

function callback() {
    alert("The photodisplay finished the slideup");
}

除了使用隐藏变量之外,你还可以使用以下方法检查选择器是否可见:

$('#photodisplay').is(':hidden')

I'm not sure what you mean but slideUp and slideDown have three parameters.

.slideUp( [duration,] [easing,] [callback] )

So what you can do is:

$('#photodisplay').slideUp(1000, "linear", callback);

function callback() {
    alert("The photodisplay finished the slideup");
}

And instead of using the hidden variable you could also check whether or not the selector is visible using:

$('#photodisplay').is(':hidden')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文