2012-08-09 17 views
1

我在全屏畫廊的底部放置了一個「向下滾動」按鈕。 (有全屏畫廊下面的內容。)結合jquery fadeOut和scrollTop:不完全褪色

Here's a link到我的頁面,所以你可以看看你自己。

我的問題不是特定的Galleria,但這是我正在使用的。因此,我使用Galleria API創建了一個新元素,並將其添加到Galleria容器中。

那麼我這個元素上使用scollTop然後淡出(後增加一個ID,進一步班,有的HTML的元素):

this.$('scrollnote').attr('id', 'scrollnotecontainer').html("<h6>Scroll down</h6>").addClass('hide-for-touch').click(function(){ 
    $('html, body').animate({ 
     scrollTop: $("#scrollnotecontainer").offset().top 
    }, 900);   
    $(this).fadeOut(); 
}); 

問題:當你點擊這個「滾動對於「div」,一切都按預期工作,但這個元素並沒有完全淡出。

當我刪除:

$('html, body').animate({ 
     scrollTop: $("#scrollnotecontainer").offset().top 
    }, 900); 

了(離開淡出)的圖片,元素確實完全淡出。

任何人都可以幫忙嗎?

回答

1

也許嘗試這樣做呢?淡出會在滾動完成後發生,以防發生同時造成問題的情況:

this.$('scrollnote').attr('id', 'scrollnotecontainer').html("<h6>Scroll down</h6>").addClass('hide-for-touch').click(function(){ 
    $('html, body').animate({ 
     scrollTop: $("#scrollnotecontainer").offset().top, 
     complete: function() { $(this).fadeOut(); } 
    }, 900);   
}); 
+0

謝謝。我認爲你的回答是正確的,但是我仍然有同樣的問題。這導致我相信這是別的東西導致元素不能正常消退。我沒有設置會導致此問題的元素的類,儘管這可能與我在頁面上使用基礎(foundation.zurb.com)這一事實有關?不確定,但如果我刪除該滾動操作,它會消失。 – hazymat 2012-08-09 17:03:24