1
我以前爲我正在製作的網站上的藝術家部分編寫了簡單的手風琴。手風琴的作品非常棒,但是由於每個部分的內容大小不同,我決定最好讓每個部分滑動到屏幕的頂部,以避免每個參觀者自己手動滾動。自定義jquery Slide-to-div腳本與手風琴不配合使用
但是,我遇到了一個小問題 - 我寫的當前腳本似乎發生了什麼,以使每個部分滑入視圖,取決於要滑動的div與視口/屏幕相關的位置,動畫不會似乎功能正常...它幾乎就像它需要重置自己或某事,以瞭解新的ID被觸發?? ...我不知道...
這是我目前的標記看起來像:
HTML
<div id="locate_artist_01"><!-- Unique ID assigned to each artist wrapper -->
<div class="artist_leadimg">
<h3 class="artist_bandname">ARTIST NAME</h3><!-- Band Name -->
<div class="artist_toggle_trigger" id="artist_01" title="Show/Hide"></div><!-- Toggle Button -->
</div><!-- .artist_leadimg -->
<div class="artist_toggle_container"></div>
</div>
<!-- ....repeated for each artist, but with different unique ID's -->
JQUERY - 手風琴
$(document).ready(function(){
//Hide (Collapse) the toggle containers on load
$('.artist_toggle_container').hide();
//On Click
$('.artist_toggle_trigger').click(function(){
if($(this).parent().next().is(':hidden')) { //If immediate next container is closed...
$('.artist_toggle_trigger').removeClass('artist_toggle_active').parent().next().slideUp(); //Remove all "active" state and slide up the immediate next container
$(this).toggleClass('artist_toggle_active').parent().next().slideDown(); //Add "active" state to clicked trigger and slide down the immediate next container
}
return false; //Prevent the browser jump to the link anchor
});
});
JQUERY - 滑動以藝術家 - 這是一部分,我需要請
$(document).ready(function(){
$('#artist_01').click(function(){
$('html, body').animate({
scrollTop: $("#locate_artist_01").offset().top
}, "slow");
});
$('#artist_02').click(function(){
$('html, body').animate({
scrollTop: $("#locate_artist_02").offset().top
}, "slow");
});
$('#artist_03').click(function(){
$('html, body').animate({
scrollTop: $("#locate_artist_03").offset().top
}, "slow");
});
$('#artist_04').click(function(){
$('html, body').animate({
scrollTop: $("#locate_artist_04").offset().top
}, "slow");
});
$('#artist_05').click(function(){
$('html, body').animate({
scrollTop: $("#locate_artist_05").offset().top
}, "slow");
});
});
我希望有人能指出我在正確的援助方向,因爲我覺得非常接近得到這個工作正常,但我只是不知道足夠的Java/jQuery的尚未解決我可能會失蹤...
感謝您提前給予幫助。
驚人的解決方案。十分感謝你的幫助!似乎也很好,根據螢火蟲沒有奇怪的錯誤或衝突:) – 2011-02-13 05:49:47