function autoScroll($message) {
var $item = $message.children(),
_count = $message[0].scrollTop,
_times = 0,
_height = $message.outerHeight(),
_scrollHeight = $message[0].scrollHeight,
_scrollTop = $message[0].scrollTop;
if (_scrollHeight > _height) {
global_timer = setInterval(function() {
_count += 1;
if (_count < _scrollHeight - _height) {
$message[0].scrollTop = _count;
} else {
clearInterval(global_timer);
_times = 1;
}
}, 50);
}
$message.on({
// 'touchstart': function() {
// clearInterval(global_timer);
// },
'touchstart': function() {
var e = e || window.event;
e.stopPropagation();
_count = $message[0].scrollTop;
clearInterval(global_timer);
},
'touchend': function() {
clearInterval(global_timer);
if (_times == 0) {
_count = $message[0].scrollTop;
global_timer = setInterval(function() {
_count += 1;
if (_count < _scrollHeight - _height) {
//直接从当前位置滚动
$message[0].scrollTop = _count;
} else {
clearInterval(global_timer);
_times = 1;
}
}, 50);
}
},
'scroll': function() {
_count = $message[0].scrollTop;
}
});
}
jQuery--文字滚动
最新推荐文章于 2024-01-23 18:00:00 发布