Skip to content

Commit

Permalink
Update JQuery visibility check on sticky element
Browse files Browse the repository at this point in the history
Following a PR review[1], this commit changes the test on this.$sticky, in
order to verify if the object actually contains any elements.

Further details in the PR[2].

[1]
#368 (comment)

[2]
#368
  • Loading branch information
marcotranchino authored and kr8n3r committed Oct 22, 2024
1 parent 30322df commit eab85ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/assets/javascripts/_modules/table-of-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
this.isMonitoring = false
}
StickyOverlapMonitors.prototype.run = function () {
var stickyIsVisible = this.$sticky && this.$sticky.is(':visible')
var stickyIsVisible = this.$sticky.length > 0 && this.$sticky.is(':visible')
if (stickyIsVisible && !this.isMonitoring) {
document.addEventListener('focus', this.onFocus, true)
this.isMonitoring = true
Expand Down

0 comments on commit eab85ee

Please sign in to comment.