Skip to content

Commit

Permalink
fixup: restore old event trigger behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhas07 committed Dec 20, 2024
1 parent 17dc58b commit 3fdd6fc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,19 @@ class ScrollSpy extends BaseComponent {
}

let maxIntersectionRatio = 0
let element = null
for (const [key, val] of this._intersectionRatio.entries()) {
if (val > maxIntersectionRatio) {
const element = targetElement(key)
this._activeTarget = element
element = targetElement(key)
maxIntersectionRatio = val
}
}

if (element !== null) {
this._process(element)
return
}

if (this._activeTarget !== null) {
this._process(this._activeTarget)
}
Expand Down Expand Up @@ -208,6 +213,11 @@ class ScrollSpy extends BaseComponent {
this._activateParents(target)

target.classList.add(CLASS_NAME_ACTIVE)
if (target === this._activeTarget) {
return
}

this._activeTarget = target
EventHandler.trigger(this._element, EVENT_ACTIVATE, { relatedTarget: target })
}

Expand Down

0 comments on commit 3fdd6fc

Please sign in to comment.