Skip to content

Commit

Permalink
animation and request new pictures
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristen Oliva committed May 5, 2016
1 parent 20e3118 commit 6b94686
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
16 changes: 8 additions & 8 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ body {
/* ---- grid ---- */

.grid {
background: #DDD;
background: #333333;
position: relative;
height: 100%;
overflow: auto;
Expand All @@ -34,10 +34,6 @@ body {

section {
position: relative;
/*min-height: 300px;*/
/*max-height: 1000px;*/
/*height: 900px;*/
/*height: 0%;*/
}

/* ---- .grid-item ---- */
Expand All @@ -54,14 +50,18 @@ section {

.artistInfo {
color: #333;
font-size: 10px;
letter-spacing: -.5px;
font-size: 12px;
letter-spacing: -.2px;
background: rgba(255, 255, 255, 0.8);
padding: 10px;
padding: 14px;
vertical-align: bottom;
position: absolute;
bottom: 0;
left: 0;
max-height: 340px;
}

.artistInfo p{
margin: 0;
}

31 changes: 23 additions & 8 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,33 @@
});
});

var animate = function(){
$('body').animate({scrollTop: $(document).scrollTop() + $(document).height()}, 15000, function(){
var $clone = $('.grid section:last').clone();
$('.grid').append($clone).packery('appended', $clone);
$('.grid section:first').remove();
animate();
});
function animate() {
getNewData();
$('.grid section:first').remove();
$("body").animate({scrollTop: $(document).height()}, 30000, animate);
}

animate();
animate()
};

function getNewData(){
$.ajax({
url: "data.json",
method: 'GET',
dataType: 'json',
success: function(data){
$newSection = $('<section>');
$.each(data, function(i, value) {
$newSection.append($('<div>').attr('class','grid-item').append($('<img>').attr('src',value.photoUrl)).append($('<div>').attr('class','artistInfo').append($('<div>').append($('<p>').text(value.bio)))));
});
$('.grid').append($newSection).packery('appended', $newSection);
},
error: function(err) {
console.log('err', err)
}
});
}

// Load first data from the API.
loadData();
})(jQuery);

0 comments on commit 6b94686

Please sign in to comment.