Skip to content

Commit

Permalink
Enforce activated class on track waypoint when using previous/next ha…
Browse files Browse the repository at this point in the history
…ndlers
  • Loading branch information
lovethebomb committed May 14, 2020
1 parent 3e4259b commit b6eca7f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions contentScript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(window, document) {

function FeedPlaylist() {
if (!window.playerview) {
if (!window.playerview || !window.Dom) {
console.error('[bandcampFeedPlaylist] player is not found.')
return null;
}
Expand All @@ -22,7 +22,7 @@
this.$position = this.$el.querySelector('#track_play_waypoints_controls_position');
this.$duration = this.$el.querySelector('#track_play_waypoints_controls_duration');

this.observe();
this.observe();
this.registerMediaKeys();
console.debug('[bandcampFeedPlaylist] injected');
}
Expand Down Expand Up @@ -82,6 +82,19 @@
let timer = setTimeout(this.handlerNextTrack, 1000);
timer = undefined;
}

// We try to force the waypoint offset to show 'activated' properly
const track = window.playerview._current_track_list_entry();
const $story = document.querySelector(`[data-trackid='${track.id}'`);

if (!$story) return

if (!window.Dom.inViewport($story)) {
// We push at the end of execution stack
setTimeout(() => {
this.$trackPlayWaypoint.classList.add('activated')
}, 0)
}
return;
}

Expand Down

0 comments on commit b6eca7f

Please sign in to comment.