Forums

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

Home Forums JavaScript Drop Random Pins Onto Dumby Map

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #189214
    justdan
    Participant

    Hey guys,

    So I’m working on a project that is using a dumby map as a loader with pins falling. I’m trying to make it so that I can just put in some empty div’s that will represent some pins and then they will fall into place, but at random points on the dumby map. The idea was to loop over the div’s and animate each one falling onto the map with a random number. In theory this sounded great but when I tried it out instead of animating each div, the whole list moves. I’ll include a link for a quick little mockup in codepen below. You’ll notice when it loads that the boxes will all animate. I just need it to animate each div individually. I think I’m close, but I could be a bit off. As always, thank you for your time and help.

    http://codepen.io/justdan/pen/ByNZXO

    #189220
    __
    Participant

    Well, couple things. First off, you’re using the same random number on every iteration of the loop. Second, you’re applying the animation to the jquery object (the collection of pins) as a whole, instead of to the individual pins themselves.

    I think jquery has an .each() method, doesn’t it?

    pins.each(function(){
        // make random number
        // animate
    });
    

    Also, I have no clue what a “Dumby Map” is…? and google didn’t really help.

    #189287
    __
    Participant

    So, “dumby map” meaning “not a real map.” I figured you might mean something like that, but I wanted to make sure I wasn’t overlooking something.

    BTW, GSutherland’s post and my own are actually the same suggestion. jQuery allows you to call most of its methods either on a jQuery collection object (what I showed), or on the jQuery function itself (what GSutherland showed), and pass the collection object as an argument.

    Also, in your demo, do you need all those scripts for something else on your page? You should need only jQuery (which you can have codepen load automatically — click on the gear icon on the JavaScript box).

    #189289
    Paulie_D
    Member

    Ohhh “dumby” = “dummy”

    Now I get it. :)

    #189292
    __
    Participant

    Sorry, I should have gave that part some extra detail plus proper spelling.

    Well, you spelled it the same way every time, so…

    : p

    Have fun : )

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.