Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    93
    Thanks
    12
    Thanked 0 Times in 0 Posts

    mootools - flicking an elements class (addClass/removeClass) - best practice

    Hi all.

    I am a rookie in Mootools but have a background of Js development.

    I am wondering what advice people have on flickering an items class on and off. Say to get an effect of the border flashing on and off.

    So the way I see it I addClass and then removeClass using setTimeout, and a closure and a for loop.

    thus enabling me to flick the border on and off a certain number of times.
    off top of my head something like this: (maybe errors just used to demonstrate what I mean)
    Code:
    var reps = 100;
    
    reps.each(function(i){
    
      setTimeout(function(){
          var pos = i;
    
          if(i%2){
              $$(.blah).addClass('on');
          }else{
              $$(.blah).removeClass('on);
          }
      }, (pos + 10) * 1000);
    
    });
    Code:
    #css
    .blah {
       border:1px solid;
    }
    .on {
       border:1px solid red;
    }
    I am wondering if there is a better way to do this in Mootools?

    As always any light shedding on the matter is hugely appreciated.

    Thanks

  • #2
    New Coder
    Join Date
    Nov 2008
    Posts
    93
    Thanks
    12
    Thanked 0 Times in 0 Posts
    sussed

    Code:
    $('morphExample').set('morph', {
      link: 'chain',
      duration: 1000
    });
    $('morphExample').morph('.two').morph('.one').morph('.two').morph('.one');


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •