Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This file is writen by Georgi Naumov
- * [email protected] for contacts and
- * suggestions.
- **/
- /**
- * I try to made a
- * scroller 'object'.
- */
- var scroller = (function(){
- var intervalId = null;
- var divToScroll = null;
- var maxScroll = null;
- return {
- startScroll : function() {
- /**
- * Protect from several scroll startups
- */
- if(intervalId != null) {
- return false;
- }
- divToScroll = document.getElementById("scroller");
- /**
- * 4 - size ot borders for every side.
- **/
- maxScroll = divToScroll.scrollWidth - divToScroll.offsetWidth + 8;
- intervalId = setInterval(function() {
- if(divToScroll.scrollLeft == maxScroll) {
- divToScroll.scrollLeft = 0;
- }
- divToScroll.scrollLeft += 20;
- }, 500);
- },
- stopScroll : function() {
- /**
- * If intervalId is null we don't
- * need to clear it.
- */
- if(intervalId == null) {
- return false;
- }
- clearInterval(intervalId);
- intervalId = null;
- }
- }
- })();
- scroller.startScroll();
Advertisement
Add Comment
Please, Sign In to add comment