Skip to content

Commit

Permalink
feat: Add loading spinner to OpenSeaDragon viewer
Browse files Browse the repository at this point in the history
This commit adds a Tailwind-based SVG loading spinner to the
OpenSeaDragon viewer.
  • Loading branch information
hepplerj committed Aug 1, 2024
1 parent f6647e6 commit 08fe9a5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
14 changes: 14 additions & 0 deletions static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,17 @@
.active {
font-weight: bold;
}

.loader {
border-top-color: #3498db;
animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
41 changes: 35 additions & 6 deletions templates/manuscript_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@
<div class="relative max-w-full mx-auto px-4 sm:px-6 lg:px-8 py-2">
<div class="mt-12 grid grid-cols-4 gap-2">
<div class="col-span-3">
<div id="loading-spinner" class="flex justify-center items-center h-full">
<svg class="h-32 w-32 animate-spin" viewBox="0 0 100 100">
<circle
fill="none"
stroke-width="10"
class="stroke-current opacity-40"
cx="50"
cy="50"
r="40"
/>
<circle
fill="none"
stroke-width="10"
class="stroke-current"
stroke-dasharray="250"
stroke-dashoffset="210"
cx="50"
cy="50"
r="40"
/>
</svg>
</div>
<div id="openseadragon_viewer" class="openseadragon">
<script type="text/javascript">
let page_url = encodeURI("{{ cleaned_url }}")
Expand All @@ -27,6 +49,11 @@
homeFillsViewer: false,
visibilityRatio: 1,
})

viewer.addHandler('open', function () {
document.getElementById('loading-spinner').style.display = 'none';
document.getElementById('openseadragon_viewer').classList.remove('hidden');
});
</script>
</div>
{% if previous_page %}
Expand Down Expand Up @@ -81,8 +108,10 @@
{% if manuscript_page.attached_images.all.1 %}
<hr class="mt-3 mb-3" />
<div class="mt-4">
<a class="underline hover:no-underline" href="{% url 'forensic_page' manuscript_page.attached_images.all.1.id %}">
<img class="w-32 h-32 object-cover" src="{{ manuscript_page.attached_images.all.1.image.url }}" alt="First Forensic Image">
<a class="underline hover:no-underline"
href="{% url 'forensic_page' manuscript_page.attached_images.all.1.id %}">
<img class="w-32 h-32 object-cover" src="{{ manuscript_page.attached_images.all.1.image.url }}"
alt="First Forensic Image">
<caption>View the forensic images for this page</caption>
</a>
</div>
Expand Down Expand Up @@ -152,7 +181,8 @@ <h3 class="text-center font-semibold text-1xl pb-4 mb-4 uppercase">Document Deta
<li><strong>Page</strong>: {{ manuscript_page.page_range }}</li>
<li><strong>Page tagged with</strong>:
{% for tag in manuscript_page.tags.all %}
<span class="inline-flex items-center rounded-md bg-blue-50 px-2 py-1 text-xs font-medium text-winterthur-dk-blue ring-1 ring-inset ring-blue-700/10">{{ tag.name }}</span>
<span
class="inline-flex items-center rounded-md bg-blue-50 px-2 py-1 text-xs font-medium text-winterthur-dk-blue ring-1 ring-inset ring-blue-700/10">{{ tag.name }}</span>
{% endfor %}
</li>
</ul>
Expand All @@ -169,9 +199,8 @@ <h3 class="text-center font-semibold text-1xl pb-4 mb-4 uppercase">Document Deta
<h2 class="text-center font-semibold text-1xl pb-4 mb-4 uppercase">Cite this page</h2>
<p><em>The Denig Manuscript</em>, Winterthur Museum, Garden & Library and the Roy Rosenzweig Center
for
History and New Media (2024--): p. {{ manuscript_page.page_range }}. <a
href="{% url 'manuscript' %}"
class="text-winterthur-dk-blue hover:underline">https://denig.rrchnm.org/manuscript/{{manuscript_page.id}}</a>
History and New Media (2024--): p. {{ manuscript_page.page_range }}. <a href="{% url 'manuscript' %}"
class="text-winterthur-dk-blue hover:underline">https://denig.rrchnm.org/manuscript/{{manuscript_page.id}}</a>
</p>
</div>
</div>
Expand Down

0 comments on commit 08fe9a5

Please sign in to comment.