Skip to content

Commit

Permalink
Add spinning feedback at the bottom of loading rows
Browse files Browse the repository at this point in the history
Fixes #130
  • Loading branch information
oparoz committed Sep 9, 2015
1 parent d7bdfab commit 7baa717
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
7 changes: 7 additions & 0 deletions css/public.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ body {
#gallery.hascontrols {
padding-bottom: 0;
}

#loading-indicator {
height: 32px;
width: 100%;
margin-top: 100px;
margin-bottom: 0;
}
24 changes: 11 additions & 13 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body:after {
float: left;
}

div.crumb.last a{
div.crumb.last a {
cursor: default;
}

Expand All @@ -32,9 +32,10 @@ div.crumb.last a{
padding: 8px;
border-radius: 3px 0 0 3px;
margin-left: 3px;
margin-right:0;
margin-right: 0;
border-right: 0;
}

#controls .button.right-sort-button {
float: left;
display: inline;
Expand All @@ -47,7 +48,7 @@ div.crumb.last a{
background-color: rgb(230, 230, 230);
}

#controls .sort-inactive img{
#controls .sort-inactive img {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=25)";
filter: alpha(opacity=25);
opacity: 0.25;
Expand Down Expand Up @@ -151,7 +152,7 @@ div.crumb.last a{

#gallery a.album .album-label,
#gallery a.image .image-label {
background: rgba(0,0,0,0.4);
background: rgba(0, 0, 0, 0.4);
}

#gallery a.image .image-label .title {
Expand Down Expand Up @@ -247,15 +248,6 @@ div.crumb.last a{
border-bottom-right-radius: 0;
}

#loading {
font-size: 16px;
color: #888;
position: absolute;
text-align: center;
top: 30%;
width: 100%;
}

/*Original ribbon design by Comatosed
http://www.bypeople.com/author/comatosed/*/
.ribbon {
Expand Down Expand Up @@ -306,3 +298,9 @@ http://www.bypeople.com/author/comatosed/*/
.ribbon.black:after {
border-color: #bbb #bbb transparent #bbb;
}

#loading-indicator {
height: 32px;
width: 100%;
margin-bottom: 50px;
}
2 changes: 0 additions & 2 deletions js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@
showLoading: function () {
$('#emptycontent').addClass('hidden');
$('#controls').removeClass('hidden');
$('#content').addClass('icon-loading');
},

/**
Expand All @@ -281,7 +280,6 @@
showNormal: function () {
$('#emptycontent').addClass('hidden');
$('#controls').removeClass('hidden');
$('#content').removeClass('icon-loading');
},

/**
Expand Down
2 changes: 1 addition & 1 deletion js/galleryrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
var scaleRatio = (this.width > this.targetWidth) ? this.targetWidth / this.width : 1;
var targetHeight = 200 * scaleRatio;
targetHeight = targetHeight.toFixed(3);
var row = $('<div/>').addClass('row loading');
var row = $('<div/>').addClass('row');
/**
* @param {*} row
* @param {GalleryImage[]|Album[]} items
Expand Down
16 changes: 8 additions & 8 deletions js/galleryview.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
}

this.clear();
$('#loading-indicator').show();

if (albumPath !== Gallery.currentAlbum) {
this.loadVisibleRows.loading = false;
Expand All @@ -99,8 +100,7 @@
// Loading rows without blocking the execution of the rest of the script
setTimeout(function () {
this.loadVisibleRows.activeIndex = 0;
this.loadVisibleRows(Gallery.albumMap[Gallery.currentAlbum],
Gallery.currentAlbum);
this.loadVisibleRows(Gallery.albumMap[Gallery.currentAlbum], Gallery.currentAlbum);
}.bind(this), 0);
},

Expand Down Expand Up @@ -163,6 +163,7 @@
// If we've reached the end of the album, we kill the loader
if (!(album.viewedItems < album.subAlbums.length + album.images.length)) {
view.loadVisibleRows.loading = null;
$('#loading-indicator').hide();
return;
}

Expand All @@ -180,10 +181,6 @@
if (view.requestId === row.requestId) {
return row.getDom().then(function (dom) {

// defer removal of loading class to trigger CSS3 animation
_.defer(function () {
dom.removeClass('loading');
});
if (Gallery.currentAlbum !== path) {
view.loadVisibleRows.loading = null;
return; //throw away the row if the user has navigated away in the
Expand All @@ -202,9 +199,11 @@

// No more rows to load at the moment
view.loadVisibleRows.loading = null;
$('#loading-indicator').hide();
}, function () {
// Something went wrong, so kill the loader
view.loadVisibleRows.loading = null;
$('#loading-indicator').hide();
});
}
// This is the safest way to do things
Expand Down Expand Up @@ -234,8 +233,9 @@

var currentSort = Gallery.config.albumSorting;
this.sortControlsSetup(currentSort.type, currentSort.order);
Gallery.albumMap[Gallery.currentAlbum].images.sort(Gallery.utility.sortBy(currentSort.type,
currentSort.order));
Gallery.albumMap[Gallery.currentAlbum].images.sort(
Gallery.utility.sortBy(currentSort.type,
currentSort.order));
Gallery.albumMap[Gallery.currentAlbum].subAlbums.sort(Gallery.utility.sortBy('name',
currentSort.albumOrder));
},
Expand Down
1 change: 1 addition & 0 deletions templates/part.content.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@
</div>
<div id="gallery" class="hascontrols"></div>
<div id="emptycontent" class="hidden"></div>
<div id="loading-indicator" class="loading"></div>
<input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="yes"/>
1 change: 1 addition & 0 deletions templates/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class="icon-confirm svg"></button>
data-token="<?php isset($_['token']) ? p($_['token']) : p(false) ?>">
</div>
<div id="emptycontent" class="hidden"></div>
<div id="loading-indicator" class="loading"></div>
<footer>
<p class="info"><?php print_unescaped($theme->getLongFooter()); ?></p>
</footer>
Expand Down

0 comments on commit 7baa717

Please sign in to comment.