Smooth out this jQuery toggle animation?

后端 未结 5 1517
甜味超标
甜味超标 2020-12-31 19:38

The animation produced by my jQuery function is shaky, and I\'ve been looking through different SO solutions, such as adding jquery.easing, but no luck. Is

5条回答
  •  误落风尘
    2020-12-31 20:24

    Andrew's solution is correct, but I would still put the css like this (if javascript is off): .videoblock{width:560px; height: 315px; overflow:hidden}

    and add the simultaneous animation:

    $('.videoblock').css('height','0');
    $(".entry-title").click(function() {
        $this = $(this);
        $content = $this.closest('.videotoggle').find(".videoblock");
        if (!$this.is('.active-title')) {
    
            $('.active-title').removeClass('active-title');
            $this.addClass('active-title');
            $(".videoblock:visible").animate({height: "0"}, { duration: 400, queue: false });
            $content.animate({height: "315"}, { duration: 400, queue: false });
        }
    });
    

    Here is the link to the final: http://jsfiddle.net/gwLcD/21/

提交回复
热议问题