Last active
August 29, 2015 14:22
-
-
Save johnbhartley/8864457749fa9d0face5 to your computer and use it in GitHub Desktop.
Randomly places images inside a gallery in different absolute spot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PlaceImages: function(galH, galW) { | |
// galH and galW are specified width/height | |
// either input in the function or could use width/height of gallery | |
var gal = $('.hp-gallery-images'); | |
var imgs = $('.hp-gallery img'); | |
imgs.each( function (index, el) { | |
var randNum_T = Math.round(Math.random() * galH); | |
var randNum_L = Math.round(Math.random() * galW); | |
var randClass = Math.round(Math.random() * 5); | |
var newIMG = $('<img />').attr({src: this.src, alt: 'space'}).addClass('layer-'+randClass).css({'top': randNum_T + 'px', 'left': randNum_L}); | |
gal.append(newIMG); | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment