diff --git a/src/js/components/LazyLoadListener.js b/src/js/components/LazyLoadListener.js index 3ce1f4c7..a9d29778 100755 --- a/src/js/components/LazyLoadListener.js +++ b/src/js/components/LazyLoadListener.js @@ -19,8 +19,8 @@ export default class LazyLoadListener extends React.Component{ } handleScroll(e){ - if( (window.innerHeight + window.scrollY) >= document.body.offsetHeight ){ - if( !this.state.loading ){ + if( (window.innerHeight + window.scrollY) >= (document.body.offsetHeight - 80) ){ + if( !this.state.loading && this.props.enabled ){ this.setState({ loading: true }) this.props.loadMore(); } @@ -30,6 +30,10 @@ export default class LazyLoadListener extends React.Component{ } render(){ - return
+ return ( +
+
+
+ ) } } \ No newline at end of file diff --git a/src/js/views/Album.js b/src/js/views/Album.js index 0b14193a..86b59b3a 100755 --- a/src/js/views/Album.js +++ b/src/js/views/Album.js @@ -66,7 +66,6 @@ class Album extends React.Component{ } loadMore(){ - if( !this.props.album.tracks_more ) return this.props.spotifyActions.getURL( this.props.album.tracks_more, 'SPOTIFY_ALBUM_LOADED_MORE' ); } @@ -118,7 +117,7 @@ class Album extends React.Component{
{ this.props.album.tracks ? : null } - this.loadMore() }/> + this.loadMore() }/>
diff --git a/src/js/views/Artist.js b/src/js/views/Artist.js index bba09849..6c2ab45f 100755 --- a/src/js/views/Artist.js +++ b/src/js/views/Artist.js @@ -81,7 +81,6 @@ class Artist extends React.Component{ } loadMore(){ - if( !this.props.artist.albums_more ) return this.props.spotifyActions.getURL( this.props.artist.albums_more, 'SPOTIFY_ARTIST_ALBUMS_LOADED', this.props.params.uri ); } @@ -164,7 +163,7 @@ class Artist extends React.Component{

Albums

- this.loadMore() }/> + this.loadMore() }/>
) diff --git a/src/js/views/Playlist.js b/src/js/views/Playlist.js index 00b1ccce..c94477ed 100755 --- a/src/js/views/Playlist.js +++ b/src/js/views/Playlist.js @@ -54,7 +54,6 @@ class Playlist extends React.Component{ } loadMore(){ - if( !this.props.playlist.tracks_more ) return this.props.spotifyActions.getURL( this.props.playlist.tracks_more, 'PLAYLIST_LOADED_MORE_TRACKS', this.props.playlist.uri ); } @@ -155,7 +154,7 @@ class Playlist extends React.Component{
{ this.props.playlist.tracks ? this.removeTracks(tracks_indexes) } reorderTracks={ (indexes, index) => this.reorderTracks(indexes, index) } /> : null } - this.loadMore() }/> + this.loadMore() }/>
diff --git a/src/js/views/Search.js b/src/js/views/Search.js index 40051712..80c957df 100755 --- a/src/js/views/Search.js +++ b/src/js/views/Search.js @@ -47,9 +47,7 @@ class Search extends React.Component{ } loadMore(type){ - if( this.props[type+'_more'] ){ - this.props.spotifyActions.getURL( this.props[type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+type.toUpperCase()); - } + this.props.spotifyActions.getURL( this.props[type+'_more'], 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_'+type.toUpperCase()); } renderResults(){ @@ -91,7 +89,7 @@ class Search extends React.Component{
- this.loadMore('artists') }/> + this.loadMore('artists') }/>
) @@ -102,7 +100,7 @@ class Search extends React.Component{
- this.loadMore('albums') }/> + this.loadMore('albums') }/>
) @@ -113,7 +111,7 @@ class Search extends React.Component{
- this.loadMore('playlists') }/> + this.loadMore('playlists') }/>
) @@ -124,7 +122,7 @@ class Search extends React.Component{
- this.loadMore('tracks') }/> + this.loadMore('tracks') }/>
) diff --git a/src/js/views/User.js b/src/js/views/User.js index 5493546a..190d2500 100755 --- a/src/js/views/User.js +++ b/src/js/views/User.js @@ -33,7 +33,6 @@ class User extends React.Component{ } loadMore(){ - if( !this.props.user.playlists_more ) return this.props.spotifyActions.getURL( this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED', this.props.params.uri ) } @@ -83,7 +82,7 @@ class User extends React.Component{
- this.loadMore() }/> + this.loadMore() }/>
diff --git a/src/js/views/discover/DiscoverCategory.js b/src/js/views/discover/DiscoverCategory.js index 382928e6..a7ed4ec4 100755 --- a/src/js/views/discover/DiscoverCategory.js +++ b/src/js/views/discover/DiscoverCategory.js @@ -30,9 +30,7 @@ class DiscoverCategory extends React.Component{ } loadMore(){ - if (this.props.category.playlists_more){ - this.props.spotifyActions.getURL( this.props.category.playlists_more, 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED', 'category:'+this.props.params.id ); - } + this.props.spotifyActions.getURL( this.props.category.playlists_more, 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED', 'category:'+this.props.params.id ); } render(){ @@ -54,7 +52,7 @@ class DiscoverCategory extends React.Component{
- this.loadMore() }/> + this.loadMore() }/> ); } diff --git a/src/js/views/discover/DiscoverNewReleases.js b/src/js/views/discover/DiscoverNewReleases.js index a6a50f7f..fe63e323 100755 --- a/src/js/views/discover/DiscoverNewReleases.js +++ b/src/js/views/discover/DiscoverNewReleases.js @@ -21,7 +21,6 @@ class DiscoverNewReleases extends React.Component{ } loadMore(){ - if (!this.props.new_releases_more) return this.props.spotifyActions.getURL(this.props.new_releases_more, 'SPOTIFY_NEW_RELEASES_LOADED'); } @@ -43,7 +42,7 @@ class DiscoverNewReleases extends React.Component{
- this.loadMore() }/> + this.loadMore() }/> ); } diff --git a/src/js/views/library/LibraryAlbums.js b/src/js/views/library/LibraryAlbums.js index 8ddd73bc..e4b75dfd 100755 --- a/src/js/views/library/LibraryAlbums.js +++ b/src/js/views/library/LibraryAlbums.js @@ -29,7 +29,6 @@ class LibraryAlbums extends React.Component{ } loadMore(){ - if( !this.props.library_albums_more ) return this.props.spotifyActions.getURL( this.props.library_albums_more, 'SPOTIFY_LIBRARY_ALBUMS_LOADED' ); } @@ -173,7 +172,7 @@ class LibraryAlbums extends React.Component{
{ this.renderView(albums) } - this.loadMore() }/> + this.loadMore() }/>
); } diff --git a/src/js/views/library/LibraryArtists.js b/src/js/views/library/LibraryArtists.js index 748c23dc..f1d8ec2f 100755 --- a/src/js/views/library/LibraryArtists.js +++ b/src/js/views/library/LibraryArtists.js @@ -26,7 +26,6 @@ class LibraryArtists extends React.Component{ } loadMore(){ - if( !this.props.library_artists_more ) return this.props.spotifyActions.getURL( this.props.library_artists_more, 'SPOTIFY_LIBRARY_ARTISTS_LOADED' ); } @@ -127,7 +126,7 @@ class LibraryArtists extends React.Component{
{ this.renderView(artists) } - this.loadMore() }/> + this.loadMore() }/>
); } diff --git a/src/js/views/library/LibraryLocalAlbums.js b/src/js/views/library/LibraryLocalAlbums.js index f0b95b30..dac9dc63 100755 --- a/src/js/views/library/LibraryLocalAlbums.js +++ b/src/js/views/library/LibraryLocalAlbums.js @@ -36,7 +36,7 @@ class LibraryLocalAlbums extends React.Component{ } } - loadMore(){ + moreURIsToLoad(){ var uris = [] if (this.props.albums && this.props.local_albums){ for (var i = 0; i < this.props.local_albums.length; i++){ @@ -50,7 +50,12 @@ class LibraryLocalAlbums extends React.Component{ } } - if (uris && uris.length > 0) this.props.mopidyActions.getAlbums(uris) + return uris + } + + loadMore(){ + var uris = this.moreURIsToLoad() + this.props.mopidyActions.getAlbums(uris) } setSort(value){ @@ -147,7 +152,7 @@ class LibraryLocalAlbums extends React.Component{
{this.renderView(albums)} - this.loadMore() }/> + 0)} loadMore={ () => this.loadMore() }/>
) } diff --git a/src/js/views/library/LibraryTracks.js b/src/js/views/library/LibraryTracks.js index e1f0c5aa..544e4672 100755 --- a/src/js/views/library/LibraryTracks.js +++ b/src/js/views/library/LibraryTracks.js @@ -23,7 +23,6 @@ class LibraryTracks extends React.Component{ } loadMore(){ - if( !this.props.tracks_more ) return this.props.spotifyActions.getURL( this.props.tracks_more, 'SPOTIFY_LIBRARY_TRACKS_LOADED_MORE' ); } @@ -33,7 +32,7 @@ class LibraryTracks extends React.Component{
{ this.props.tracks ? : null } - this.loadMore() }/> + this.loadMore() }/>
); diff --git a/src/scss/app.scss b/src/scss/app.scss index 9b71437f..cda2f2f3 100755 --- a/src/scss/app.scss +++ b/src/scss/app.scss @@ -22,6 +22,7 @@ @import 'components/header'; @import 'components/notifications'; @import 'components/dropdown-field'; +@import 'components/loader'; @import 'views/artist'; @import 'views/user'; diff --git a/src/scss/components/_loader.scss b/src/scss/components/_loader.scss new file mode 100755 index 00000000..b50200e9 --- /dev/null +++ b/src/scss/components/_loader.scss @@ -0,0 +1,24 @@ + +.lazy-loader { + padding: 20px 0 40px; + + .loader { + @include animate(); + opacity: 0; + margin: 0 auto; + width: 30px; + height: 30px; + border: { + radius: 100%; + style: solid; + color: $mid_grey; + width: 2px; + } + border-top-color: transparent; + } + + &.loading .loader { + @include spin(); + opacity: 1; + } +} \ No newline at end of file diff --git a/src/scss/global/_variables.scss b/src/scss/global/_variables.scss index d9366a58..662e6e92 100755 --- a/src/scss/global/_variables.scss +++ b/src/scss/global/_variables.scss @@ -49,6 +49,18 @@ $bp_shallow: 650px; animation-timing-function: linear; } +@keyframes spin { + from { transform: rotate(0); } + to { transform: rotate(360deg); } +} + +@mixin spin( $duration: 0.5s ){ + animation-name: spin; + animation-duration: $duration; + animation-timing-function: linear; + animation-iteration-count: infinite; +} + @mixin blur( $size: 10px ) { -webkit-filter: blur( $size ); filter: blur( $size );