Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var intervalId;
- var bgPosition = {
- x: 0,
- y: 0
- };
- var pixelOffset = 160;
- var maxCycle = 10;
- var i = 0;
- function scrollBackground(id) {
- if (i == maxCycle){
- i = 0;
- }
- bgPosition.x = i * pixelOffset;
- i++;
- $('.rotator').css('background-position', bgPosition.x + 'px ' + bgPosition.y + 'px');
- }
- function setBakcgroundToDefault() {
- $('.rotator').css('background-position', 0 + 'px ' + 0 + 'px');
- }
- $(document).ready(function () {
- $('.rotator').hover(function () {
- var intervalDelay = 500;
- var currentID = $(this).attr('id');
- intervalId = setInterval(scrollBackground(currentID), intervalDelay);
- }, function () {
- setBakcgroundToDefault();
- clearInterval(intervalId);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement