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