Skip to content

Commit

Permalink
Merge pull request #2303 from alphagov/fix-sticky-js
Browse files Browse the repository at this point in the history
Fixes sticky element glitch
  • Loading branch information
andysellick authored Nov 26, 2021
2 parents 3a377fb + d3df85a commit 0940ef7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/assets/javascripts/modules/sticky-element-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
StickyElementContainer.prototype.init = function () {
if (!this.stickyElement) return

window.onresize = this.onResize
window.onscroll = this.onScroll
window.onresize = this.onResize.bind(this)
window.onscroll = this.onScroll.bind(this)
setInterval(this.checkResize.bind(this), this.interval)
setInterval(this.checkScroll.bind(this), this.interval)
this.checkResize()
Expand Down Expand Up @@ -71,7 +71,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
StickyElementContainer.prototype.checkScroll = function () {
if (this.hasScrolled) {
this.hasScrolled = false
this.hasResized = true

this.windowVerticalPosition = this.getWindowPositions().scrollTop

Expand Down

0 comments on commit 0940ef7

Please sign in to comment.