jquery 动画效果有问题

发布于 2024-12-15 07:33:41 字数 342 浏览 3 评论 0原文

此处为实时示例

  • 按任意按钮。你能看到摇晃的下滑效果吗?事实上它必须是平稳且缓慢地滑落。
  • 如果您已按任何按钮一次,请尝试按另一个按钮。表单的显示和隐藏动画很糟糕。

动画期间。 在此处输入图像描述

动画之后。 动画后的结果

如何解决此问题?

Live Example Here

  • Press any of buttons. Can you see shaky slideDown effect? In fact it must be smooth and slow slide down.
  • If you've pressed for 1 time any of buttons try to press another one. The show and hide animation of forms is awful.

During anim.
enter image description here

After anim.
Result after animation

How to fix this problems?

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

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

发布评论

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

评论(4

慵挽 2024-12-22 07:33:41

当选项卡中的每个元素隐藏或显示时,似乎会发生抖动。

获取每个选项卡的高度,并将调整大小动画实现到这些高度,而不是在每个元素隐藏或显示后单独设置动画。

The shakiness seems to be happening when each of the elements in the tab is hidden or displayed.

Get the height of each of your tabs and implement your resizing animation to those heights rather than individually animating after each element is hidden or displayed.

情归归情 2024-12-22 07:33:41

尝试使用 .animate().fadeIn() .fadeOut() .fadeTo(time,opacity) code> 而不仅仅是 .show().hide()

Try to play with .animate() and .fadeIn() .fadeOut() .fadeTo(time,opacity) instead of just .show() or .hide()

ゃ人海孤独症 2024-12-22 07:33:41

对我来说加载得很好。然而,它首先加载确实花了很长时间。如果您访问:http://gtmetrix.com/reports/tural.no- ip.org/ANBNA45n 您会发现您的页面加载速度非常缓慢,并且您看到的卡顿效果可能是由于您的计算机出现了传入信息量的问题。

It's loading quite well for me. However it did take a long time for it to load in the first place. If you go to: http://gtmetrix.com/reports/tural.no-ip.org/ANBNA45n You'll see that your page is loading quite slowly and the stuttering effect you are seeing is probably coming from your computer having issues with the amount of information coming in.

白日梦 2024-12-22 07:33:41

您可以尝试通过减少 $(selector) 调用来加快速度..当您多次使用它们时缓存一些 jQuery 对象...还记得您可以在 jQuery 对象上链接函数.. jQO .addClass("foo").removeClass("bar");jQO.addClass("foo"); 相同jQO.removeClass("bar");

就像这样......

(function(){
    var signin = $("#signin"), signup = $("#signup"), signin_f = $("#signin_form"), holder = $("#holder"), signup_f = $("#signup_form"), f_container = $("#form_container");
    $(".button").click(function () {
        if (counter === 0) {
            signin.removeClass('default_radius').addClass('right_radius');
            signup.removeClass('default_radius').addClass('left_radius');
            $("#first").animate({
                marginTop: "-=150px",
            }, 500);
        }
    });
    signup.click(function () {
        if (counter === 0) {
            holder.addClass('red_border').slideDown("slow");
            f_container.show();
            signup_f.show(0);
        } else {
            signin_f.hide(0);
            holder.switchClass( "green_border", "red_border", 1000 );
            f_container.animate({height:"260px"},1000);
            signup_f.show(0);
        }
        counter++;
    });
    signin.click(function () {
        if (counter === 0) {
            holder.addClass('green_border').slideDown("slow");
            f_container.show();
            signin_f.show(1000);
        } else {
            signup_f.hide(0);
            holder.switchClass( "red_border", "green_border", 1000 );
            f_container.animate({height:"110px"},1000);
            signin_f.show(0);
        }
        counter++;
    }); 
})();

You can try and speed things up a bit by making less $(selector) calls.. cache some of your jQuery objects when you are using them multiple times... also remember you can chain functions on jQuery objects.. jQO.addClass("foo").removeClass("bar"); is the same as jQO.addClass("foo"); jQO.removeClass("bar");

like so...

(function(){
    var signin = $("#signin"), signup = $("#signup"), signin_f = $("#signin_form"), holder = $("#holder"), signup_f = $("#signup_form"), f_container = $("#form_container");
    $(".button").click(function () {
        if (counter === 0) {
            signin.removeClass('default_radius').addClass('right_radius');
            signup.removeClass('default_radius').addClass('left_radius');
            $("#first").animate({
                marginTop: "-=150px",
            }, 500);
        }
    });
    signup.click(function () {
        if (counter === 0) {
            holder.addClass('red_border').slideDown("slow");
            f_container.show();
            signup_f.show(0);
        } else {
            signin_f.hide(0);
            holder.switchClass( "green_border", "red_border", 1000 );
            f_container.animate({height:"260px"},1000);
            signup_f.show(0);
        }
        counter++;
    });
    signin.click(function () {
        if (counter === 0) {
            holder.addClass('green_border').slideDown("slow");
            f_container.show();
            signin_f.show(1000);
        } else {
            signup_f.hide(0);
            holder.switchClass( "red_border", "green_border", 1000 );
            f_container.animate({height:"110px"},1000);
            signin_f.show(0);
        }
        counter++;
    }); 
})();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文