자동으로 상단으로 스크롤하고 싶지만 사용자가 스크롤을 시작하면 배제됩니다.사용자가 스크롤을 시작하지 않으면 javascript가 자동으로 맨 위로 이동합니다.
현재 내가 가지고있는 것은 스크롤 애니메이션 자체가 스크롤하기 때문에 애니메이션을 조기에 중단합니다. 따라서 스크롤이 발생하면 "스크롤 중지"동작을 트리거합니다.
function stop_scrolling_to_top(){
// stop animation attached to selector
$('html, body').stop();
}
// scroll to the top automatically
$('html, body').animate({ scrollTop: 0}, 1400, "easeOutQuint", function(){
// callback when animation complete
do_not_do_when_scrolling(stop_scrolling_to_top);
});
// stop animation if scrolling starts
do_when_scrolling(stop_scrolling_to_top);
스크롤이 사람 또는 js에 의해 트리거되는지 확인하는 방법이 있습니까? 전적으로 더 좋은 방법이 있습니까?
'$ (창) .scroll (함수() {CONSOLE.LOG) ('스크롤';});'이 화재는 경우 않습니다 프로그래밍 방식으로 스크롤 하시겠습니까? – Johan
@Johan yessir do – rikAtee