Skip to content

Commit 95dd1db

Browse files
committed
Rework JS so we can use the latest version of Alpine.js
1 parent e84f1d9 commit 95dd1db

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@hotwired/turbo": "^7.0.0-rc.1",
25-
"alpinejs": "3.0.6",
25+
"alpinejs": "^3.9.3",
2626
"chroma-js": "^2.1.2",
2727
"plyr": "^3.6.8"
2828
}

resources/js/site.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ Alpine.store('ui', {
1010
]).colors(5),
1111
});
1212

13-
// Dark Blues: ['062e56', '001122']
13+
let plyr = new Plyr('audio', {
14+
controls: ['play', 'rewind', 'progress', 'fast-forward', 'current-time', 'settings'],
15+
iconUrl: '/img/plyr-sprite.svg',
16+
seekTime: 15
17+
});
1418

1519
Alpine.store('player', {
1620
plyr: null,
@@ -20,24 +24,19 @@ Alpine.store('player', {
2024
title: null,
2125
show: false,
2226
init() {
23-
this.plyr = new Plyr('audio', {
24-
controls: ['play', 'rewind', 'progress', 'fast-forward', 'current-time', 'settings'],
25-
iconUrl: '/img/plyr-sprite.svg',
26-
seekTime: 15
27-
});
28-
this.plyr.on('playing', event => {
27+
plyr.on('playing', event => {
2928
Alpine.store('player').playing = true
3029
});
31-
this.plyr.on('pause', event => {
30+
plyr.on('pause', event => {
3231
Alpine.store('player').playing = false
3332
});
34-
this.plyr.on('ended', event => {
33+
plyr.on('ended', event => {
3534
Alpine.store('player').playing = false
3635
});
3736
},
3837
playEpisode(title, audio_file, mime_type, episode_url) {
3938
if (this.audio_file !== audio_file) {
40-
this.plyr.source = {
39+
plyr.source = {
4140
type: 'audio',
4241
title: title,
4342
audio_file: audio_file,
@@ -52,14 +51,14 @@ Alpine.store('player', {
5251
},
5352
toggle(file) {
5453
if (this.playing && file === this.audio_file) {
55-
this.plyr.pause();
54+
plyr.pause();
5655

57-
// Events not sent when calling pause programatically
56+
// Events not sent when calling pause programmatically
5857
// after setting .source
5958
Alpine.store('player').playing = false
6059
return;
6160
}
62-
this.plyr.togglePlay()
61+
plyr.togglePlay()
6362
},
6463
});
6564

0 commit comments

Comments
 (0)