2012-11-06 5 views
1

div에서 텍스트를 세로로 자동 스크롤 (한 속도로)하려고하고 사용자가 커서를 가리키고 있지만 코드가 작동하지 않는 것처럼 보일 때 일시 중지하려고합니다. 어떻게 이것을 달성 할 수 있습니까?jQuery vertical autoscroll 작동하지 않음

자바 스크립트

<div id="scroll">Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here<br /> 
     <br /> 
     Content here and more content here </div>​ 

은 또한, 나 또한 여기에 내 코드 업로드 한

$('#scroll').children().animate({'margin-top': '-=' + ($('#scroll').children().height()-100)}, 10000); 

HTML : http://jsfiddle.net/5DmZh/를이 지금까지 내 코드입니다.

답변

2

더 효과적인 방법은 #scroll 안에 다른 래퍼를 배치하고 모든 자식 요소의 위치를 ​​지정하는 대신 애니메이션을 적용하는 것입니다.

jsfiddle에서 코드를 확인하십시오. 애니메이션을 계속 반복하길 원합니다.

+0

+1 멋진 솔루션을 얻으려면 나도 이와 같은 작업을하려고했습니다. –

관련 문제