4
我有一小段JQuery,用於摺疊我的標題,更改其大小,然後將其粘貼到屏幕的一側。除了一部分以外,所有功能都可以工作,每次用戶滾動時都會觸發高度「切換」功能,這會讓人非常惱火。JQuery滾動檢測一次觸發
有沒有一種方法可以檢測滾動只有一次或只切換一次?
$(window).scroll(function() {
var width = $(document).width() - 205;
var height = $(document).height();
$('#me').animate({
marginLeft: width,
width: '22px',
height: 'toggle',
borderLeftWidth: "10px",
borderRightWidth: "10px"
}, 1000, function() {
$("#me:first").css("margin-top","-90px");
var div = $('#me');
$('#me h1').css("font-size","30px");
var start = $(div).offset().top;
$(div).css("height", height);
$.event.add(window, "scroll", function() {
var p = $(window).scrollTop();
$(div).css('position',((p)>start) ? 'fixed' : 'static');
$(div).css('top',((p)>start) ? '0px' : '');
});
});
});
使用標誌並將其設置爲true onect它被觸發 – Champ