0

私はここからこのコンパクトなニュースリーダーを手に入れました。以下は、リンクをクリックしたときのプレビューのイーズインとイーズアウトをアニメーション化するためのコードです。ページ全体のサイズを300から600に変更します。グーグルを実行し、jqueryのアニメーション部分が要素のCSSプロパティをアニメーション化します。だから私はそこから働きました。うまくいったと思っていたのですが、うまくいかなかったので、最初からやり直そうと思いました。

誰かがこれを読んで説明できますか?たとえば、私が推測しているのは、「ページ要素の上部のcssを-300pxにアニメーション化する...残りの行が理解できないことです。

助け、嫌がらせ、またはポインタをありがとう。

$current.stop().animate({'top':'-300px'},600,'easeOutBack',function(){
                            $(this).css({'top':'310px'});

sdfadssf

            $items.each(function(i){
                var $item = $(this);
                $item.data('idx',i+1);

                $item.bind('click',function(){
                    var $this       = $(this);
                    $cn_list.find('.selected').removeClass('selected');
                    $this.addClass('selected');
                    var idx         = $(this).data('idx');
                    var $current    = $cn_preview.find('.cn_content:nth-child('+current+')');
                    var $next       = $cn_preview.find('.cn_content:nth-child('+idx+')');

                    if(idx > current){
                        $current.stop().animate({'top':'-300px'},600,'easeOutBack',function(){
                            $(this).css({'top':'310px'});
                        });
                        $next.css({'top':'310px'}).stop().animate({'top':'5px'},600,'easeOutBack');
                    }
                    else if(idx < current){
                        $current.stop().animate({'top':'310px'},600,'easeOutBack',function(){
                            $(this).css({'top':'310px'});
                        });
                        $next.css({'top':'-300px'}).stop().animate({'top':'5px'},600,'easeOutBack');
                    }
                    current = idx;
                });
            });
4

1 に答える 1

5

説明します。

$current. //the element you are on
    stop(). //stop all running animations
    animate( //start a new animation
        {'top':'-300px'}, //animate till this element's top style is -300px
        600, //the animation will take 600ms
        'easeOutBack', //it will use the EaseOutBack easing function
        function(){ //callback, that gets called as soon as the animation finishes
            $(this).css({'top':'310px'}); //set the element's top style to 310px
        }
    );

つまり、この関数はあまり賢くはありません。それはアニメートし、最終的にはとにかく別の場所にジャンプします..とにかく、私が助けてくれたことを願っています:)

于 2012-01-22T14:48:50.733 に答える