Skip to content

Commit

Permalink
fix transcript related selectors
Browse files Browse the repository at this point in the history
The original selectors were too broad and would match against all player's transcript related elements.
This broke autoscroll on pages with multiple players with transcripts.
  • Loading branch information
JoshMoreno committed Feb 24, 2020
1 parent f5e887f commit 27b0bbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions scripts/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,19 @@

// If transcript locked, scroll transcript to current highlight location.
if (this.autoScrollTranscript && this.currentHighlight) {
newTop = Math.floor($('.able-transcript').scrollTop() +
newTop = Math.floor(this.$transcriptDiv.scrollTop() +
$(this.currentHighlight).position().top -
($('.able-transcript').height() / 2) +
(this.$transcriptDiv.height() / 2) +
($(this.currentHighlight).height() / 2));
if (newTop !== Math.floor($('.able-transcript').scrollTop())) {
if (newTop !== Math.floor(this.$transcriptDiv.scrollTop())) {
// Set a flag to ignore the coming scroll event.
// there's no other way I know of to differentiate programmatic and user-initiated scroll events.
this.scrollingTranscript = true;
// only scroll once after moving a highlight
if (this.movingHighlight) {
$('.able-transcript').scrollTop(newTop);
this.movingHighlight = false;
}
this.$transcriptDiv.scrollTop(newTop);
this.movingHighlight = false;
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/preference.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,16 +816,16 @@

// tabbable transcript
if (this.prefTabbable === 1) {
$('.able-transcript span.able-transcript-seekpoint').attr('tabindex','0');
this.$transcriptDiv.find('span.able-transcript-seekpoint').attr('tabindex','0');
}
else {
$('.able-transcript span.able-transcript-seekpoint').removeAttr('tabindex');
this.$transcriptDiv.find('span.able-transcript-seekpoint').removeAttr('tabindex');
}

// transcript highlights
if (this.prefHighlight === 0) {
// user doesn't want highlights; remove any existing highlights
$('.able-transcript span').removeClass('able-highlight');
this.$transcriptDiv.find('span').removeClass('able-highlight');
}

// Re-initialize caption and description in case relevant settings have changed
Expand Down
2 changes: 1 addition & 1 deletion scripts/transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@

// Make transcript tabbable if preference is turned on.
if (this.prefTabbable === 1) {
$('.able-transcript span.able-transcript-seekpoint').attr('tabindex','0');
this.$transcriptDiv.find('span.able-transcript-seekpoint').attr('tabindex','0');
}

// handle clicks on text within transcript
Expand Down

0 comments on commit 27b0bbf

Please sign in to comment.