나는 내 페이지에 동일한 코드가 있으며 jQuery 버전 1.6.4에서 잘 작동합니다. 나는 최신 jQuery 버전에서 그것을 테스트했고 실제로 그것의 동작을 변경했다. jQuery가 객체를 슬라이드하기 전에 객체를 표시하는 것처럼 보입니다. 내가 코드를 수정하고 스로틀/디버그 플러그 인을 추가하여 스크롤 이벤트를 여러 번 호출하지 않도록했습니다. 나는 지금 그것이 좋게 보인다라고 생각한다.
테스트를 고정 http://jsfiddle.net/QXJ53/
/*
* jQuery throttle/debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
$(document).ready(function(){
$(".totop").hide();
$(window).scroll($.throttle(1000, function(){
if ($(window).scrollTop()>100)
{
$('.totop').slideDown();
}
else
{
if($('.totop').is(':visible')){
$('.totop').slideUp();
}
}
}));
$('.totop a').click(function (e) {
e.preventDefault();
$('body,html').animate({scrollTop: 0}, 500);
});
});
감사합니다! – imGreg