Home › Forums › JavaScript › Drop Random Pins Onto Dumby Map
- This topic is empty.
-
AuthorPosts
-
November 25, 2014 at 2:36 pm #189214justdanParticipant
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.
November 25, 2014 at 5:40 pm #189220__ParticipantWell, 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.
November 26, 2014 at 9:38 am #189287__ParticipantSo, “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).
November 26, 2014 at 9:43 am #189289Paulie_DMemberOhhh “dumby” = “dummy”
Now I get it. :)
November 26, 2014 at 9:49 am #189292__ParticipantSorry, 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 : )
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.