0

このアニメーション関数にコールバックを追加したい -

$("a#goto-3").click(function() {
    $('html, body').animate({
       scrollTop: $("#landpoint-3").offset().top}, 1000, 'easeInOutCubic'
    );
    return false; 
});

これでscrollTopにそれを行うことができます...

$("a#goto-2").click(function() {
    $('html, body').animate({
       scrollTop: $("#landpoint-2").offset().top}, 1000, 'easeInOutCubic', function() {
         document.write('complete');  
       });
    return false; 
});

..しかし、アニメーション機能にそれを入れる運がない-私はこれが非常に簡単であることを知っています..前もって感謝します..

4

2 に答える 2

1
$("a#goto-3").click(function() {
    $('html, body').animate({
       scrollTop: $("#landpoint-3").offset().top}, 1000, 'easeInOutCubic', function() { callback stuff here; }
    );
    return false; 
});

1 つの要素のみをアニメーション化するようにしてください。html と body の両方でアニメーション化しています。

この例を参照してください: http://jsfiddle.net/HQUaD/2/

于 2013-02-12T14:21:48.467 に答える
-1
$('html, body').animate({
   scrollTop: $("#landpoint-3").offset().top}, 1000, 'easeInOutCubic', function() {
       // animation completed code
   }
);

こちらのドキュメントをご覧ください

または、次のように.when()を使用できます。

$.when($('html, body').animate({
   scrollTop: $("#landpoint-3").offset().top}, 1000, 'easeInOutCubic'))
.then(function() {
    // both animations completed code!
});
于 2013-02-12T14:21:49.870 に答える