Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AnimationDiv(elemid){
- this.elemId = document.getElementById(elemid)// the link btw JS Obj and DOM Nodes!
- }
- AnimationDiv.prototype = {
- constructor: AnimationDiv,
- color: ['#ff00aa', '#ababab', '#00fafa', '#bfbfbf', '#c9c9c9', '#0a0a0a'],// color transition for each instance/obj of this class
- changeColor: function(){
- let index =0;
- let len = this.color.length;
- let timer = setInterval(()=>{
- if(index < len){
- this.elemId.style.backgroundColor = this.color[index];
- index++;
- }else{
- index =0;
- this.elemId.style.backgroundColor = this.color[index]
- }
- },2000)// color change occurs every 2 sec
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement