简体   繁体   English

有jquery动画效果的问题

[英]Having issue with jquery animation effects

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. 如果您已按1次,则尝试按任何一个按钮。 The show and hide animation of forms is awful. 表单的显示和隐藏动画非常糟糕。

During anim. 在动画中。 在此输入图像描述

After anim. 动画后。 动画后的结果

How to fix this problems? 如何解决这个问题?

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. 获取每个选项卡的高度,然后将调整大小的动画实施到这些高度,而不是在隐藏或显示每个元素之后分别进行动画处理。

尝试与.animate().fadeIn() .fadeOut() .fadeTo(time,opacity)一起玩,而不仅仅是.show().show() .hide()

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. 如果您访问: http : //gtmetrix.com/reports/tural.no-ip.org/ANBNA45n您将看到页面加载非常缓慢,并且出现的口吃效果可能来自计算机出现问题与大量的信息进入。

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"); 您可以通过减少$(选择器)调用来尝试加快速度。在多次使用它们时缓存一些jQuery对象...还记得你可以在jQuery对象上链接函数jQO.addClass("foo").removeClass("bar"); is the same as jQO.addClass("foo"); jQO.removeClass("bar"); jQO.addClass("foo"); jQO.removeClass("bar"); 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++;
    }); 
})();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM