Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Better way ? and how to make it nicer

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #205295
    Greg
    Participant

    Okay, so I want to create a grid of icons such that, the last icon in the array gets pulled then added to the front of the array. I couldn’t figure out how to do this using just arrays, but here is my pen.

    http://codepen.io/Paeon/pen/NqBoKj

    So it works but…
    As I’m barely capable in jQuery, is there a better way to do this? And,
    is there any way I can use easing or animation so that pulling of the last item kind of fades out and then fades in when prepended to the containing div?

    Thanks!!

    #205302
    Shikkediel
    Participant

    Same function, just a few less characters :

    setInterval(moveLast2First, 1000);
    
    function moveLast2First() {
    
        var popped = $("#skillblock div:last");
    
        $('#skillblock').prepend(popped);
    }
    

    And this will fade the element:

    setInterval(moveLast2First, 1000);
    
    function moveLast2First() {
    
        var popped = $("#skillblock div:last");
    
        popped.fadeOut(400, function() {
            popped.prependTo('#skillblock').fadeIn();
        });
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.