SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top