Skip to content

Commit 56bf58d

Browse files
committed
Add floating mp3 player
1 parent 3b7002b commit 56bf58d

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

lingoanki/templates/diary_tprs_play_audio.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
{% extends "diary.html" %} {% block title %}audio player{% endblock %} {% block
33
content %}
44

5+
<style>
6+
.audio-player {
7+
position: sticky;
8+
top: 0;
9+
background: white;
10+
z-index: 1000;
11+
padding: 1rem;
12+
display: flex;
13+
flex-direction: column;
14+
align-items: center;
15+
gap: 1rem;
16+
max-width: 400px;
17+
margin: auto;
18+
box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* subtle shadow */
19+
transition: all 0.3s ease; /* smooth transition */
20+
}
21+
</style>
22+
23+
524
<h2>{{ _('select an mp3 file to play') }}</h2>
625

726
<form id="audioform">
@@ -34,7 +53,20 @@ <h2>{{ _('select an mp3 file to play') }}</h2>
3453
<h3>{{ _('now playing') }}: {{ filename }}</h3>
3554

3655
<!-- Custom Audio Player -->
37-
<div style="display: flex; flex-direction: column; align-items: center; gap: 1rem; max-width: 400px; margin: auto;">
56+
<script>
57+
document.addEventListener('scroll', function() {
58+
const player = document.querySelector('.audio-player');
59+
if (window.scrollY > 50) { // when scrolled 50px down
60+
player.style.transform = 'scale(0.95)';
61+
player.style.opacity = '0.9';
62+
} else {
63+
player.style.transform = 'scale(1)';
64+
player.style.opacity = '1';
65+
}
66+
});
67+
</script>
68+
69+
<div class="audio-player">
3870
<audio id="audio" preload="metadata">
3971
<source src="{{ url_for('play_audio', filename=filename) }}" type="audio/mp3">
4072
Your browser does not support the audio element.

0 commit comments

Comments
 (0)