다음 jquery 코드를 사용하여 느린 스크롤 애니메이션을 만듭니다. http://jsfiddle.net/fhj45f21/마우스 오버시 .scrollTop() 애니메이션을 일시 중지하는 방법은 무엇입니까? (jsfiddle included)
불행히도 마우스 오버시 애니메이션을 일시 중지하는 데 어려움이 있습니다. 누군가 좀 봐 주시고 저에게 힌트를 주시겠습니까?
function Scroller(y){
this.times = 0;
this.moveInter = 0;
this.backInter = 0;
this.moveBack = function() {
var self = this;
clearInterval(this.moveInter);
this.backInter = setInterval(function() {
self.times -= 5;
y.scrollTop(self.times);
if (self.times == 0) {
return self.startMove();
}
}, 1);
}
this.move = function() {
var self = this;
this.moveInter = setInterval(function() {
self.times++;
y.scrollTop(self.times);
if (self.times == 1200) {
return self.moveBack();
}
}, 50);
}
this.startMove = function() {
this.times = 0;
var self = this;
if (this.backInter != null) {
clearInterval(this.backInter);
}
window.setTimeout(function() {
self.move();
}, 1000);
}
}
jQuery('.textBox').each(function() {
y = jQuery(this);
var scroller = new Scroller(y);
scroller.startMove();
});
감사합니다. 여기
을로 마우스를? http://api.jquery.com/stop/ –