Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function AnimationDiv(elemid){
  2. this.elemId = document.getElementById(elemid)// the link btw JS Obj and DOM Nodes!
  3. }
  4. AnimationDiv.prototype = {
  5. constructor: AnimationDiv,
  6. color: ['#ff00aa', '#ababab', '#00fafa', '#bfbfbf', '#c9c9c9', '#0a0a0a'],// color transition for each instance/obj of this class
  7. changeColor: function(){
  8. let index =0;
  9. let len = this.color.length;
  10. let timer = setInterval(()=>{
  11. if(index < len){
  12. this.elemId.style.backgroundColor = this.color[index];
  13. index++;
  14. }else{
  15. index =0;
  16. this.elemId.style.backgroundColor = this.color[index]
  17. }
  18. },2000)// color change occurs every 2 sec
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement