-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading indicator on large album list #19
Comments
This is an interesting idea, we may think about implementing some kind of lazy-loading in the future, but we must be careful to not break things for people who have overridden the partials of this component. For now, here is a trick to lazy-load the albums list using October's AJAX framework:
function onLoadGooglePhotosAlbums()
{
// Register the component dynamically when this handler is called
$component = $this->controller->addComponent('googlePhotosAlbums', 'googlePhotosAlbums', [
'albumPage' => 'google-photos/album',
'thumbHeight' => 160,
'thumbWidth' => 160,
'shouldCrop' => 1,
]);
// Specific to this component: ask to load gallery data. This may not be necessary in a future version
$component->onRun();
// Replace spinner by the gallery
return [
'#googlePhotosAlbums' => $this->renderComponent('googlePhotosAlbums'),
];
}
{# The container for the gallery #}
<div id="googlePhotosAlbums">
{# Inside, put a spinner or anything to be shown on page load. In this example, this is a Bootstrap 5 spinner #}
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
{# Some JS to trigger the onLoadGooglePhotosAlbums() handler after the page is loaded #}
<script>
document.addEventListener('DOMContentLoaded', function () {
oc.request(this, 'onLoadGooglePhotosAlbums'); // OC >= 3
// $(this).request('onLoadGooglePhotosAlbums'); // OC < 3 (needs jQuery)
});
</script> |
I will keep this issue open, so I remember to work on this when I get some time |
We have approximately 100 albums, and retrieving the list takes a long time. The same is true for albums with a large number of photos. Because the component's API call starts before the page is rendered, there is no chance of a loading indicator showing. It would be nice to have some JavaScript 'before API call' callback to allow a loading indicator.
The text was updated successfully, but these errors were encountered: