我有一个 jquery 代码,它连续上下移动一个 div,其中包含一个带有徽标的列表。动画在设定的时间间隔内重复,并且在 Chrome、FireFox 和 IE 9 和 8 中似乎都按预期工作(没有控制台错误)。
但是在 IE7 中,我收到“脚本错误”并且浏览器完全冻结...我认为 setInterval 和 clearInterval 无法正常工作,或者我搞砸了我的代码...
这里是:
//<!------------------LOGOS ------------------>
// the automatic scroll start immediately
$(document).ready(function () { membersLogos() });
// set the interval after which to restart the animated scroll
$(function () {
var intervalID;
var resetTimer = function () {
if (intervalID) { clearInterval(intervalID) };
intervalID = setInterval(function () {
membersLogos();
}, 190000);
};
});
// set the interval after which to restart the animated scroll
function membersLogos() {
var pane = $('#mypane');
if ($('#mypane').length) {
pane.jScrollPane({
animateScroll: true, //added
animateDuration: 95000, //added - length each way in milliseconds
stickToTop: true,
//autoReinitialise: true,
enableKeyboardNavigation: true
});
var api = pane.data('jsp');
var logosHeight = parseInt($('#mypane .jspPane').height());
//listen to the x-axis scrolling event
pane.bind('jsp-scroll-y', function (event, pos_y, at_top, at_bottom) {
//we're at the bottom now lets scroll back to the top
if (at_bottom) {
api.scrollToY(0);
$(this).unbind(event); //added with edit
$(this).bind('jsp-scroll-y', function (event, pos_y, at_top, at_bottom) {
if (at_top) {
$(this).unbind(event);
api.scrollToY(logosHeight);
}
});
}
});
//initial animate scroll to the top
api.scrollToY(logosHeight);
}
}
有什么想法或建议有什么问题吗?提前致谢!维克