Skip to content

Instantly share code, notes, and snippets.

@cycyewt
Created September 26, 2013 02:03
Show Gist options
  • Save cycyewt/6708866 to your computer and use it in GitHub Desktop.
Save cycyewt/6708866 to your computer and use it in GitHub Desktop.
$(function() {
var speed = -1,
banner = document.getElementById('banner'),
main1 = document.getElementById('main1'),
wrap1 = document.getElementById('wrap1'),
wrap2 = document.getElementById('wrap2'),
timer,
interval = 15,
left;
function scroll() {
left = banner.offsetLeft;
banner.style.left = (left <= -wrap1.offsetWidth) ? 0 : left + speed;
timer = setTimeout(scroll, interval);
}
wrap2.innerHTML = wrap1.innerHTML;
timer = setTimeout(scroll, interval);
main1.onmouseover = function() {
clearTimeout(timer);
}
main1.onmouseout = function() {
timer = setTimeout(scroll, interval);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment