Skip to content

Commit

Permalink
Quick fix for race condition in JS.show()
Browse files Browse the repository at this point in the history
  • Loading branch information
silverdr committed Oct 5, 2024
1 parent d9cbbe9 commit 31dc9e6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions assets/js/phoenix_live_view/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ let JS = {
if(eventType === "remove"){ return }
let onStart = () => {
this.addOrRemoveClasses(el, inStartClasses, outClasses.concat(outStartClasses).concat(outEndClasses))
let stickyDisplay = display || this.defaultDisplay(el)
DOM.putSticky(el, "toggle", currentEl => currentEl.style.display = stickyDisplay)
window.requestAnimationFrame(() => {
this.addOrRemoveClasses(el, inClasses, [])
window.requestAnimationFrame(() => this.addOrRemoveClasses(el, inEndClasses, inStartClasses))
window.requestAnimationFrame(() => {
this.addOrRemoveClasses(el, inEndClasses, inStartClasses)
let stickyDisplay = display || this.defaultDisplay(el)
DOM.putSticky(el, "toggle", currentEl => currentEl.style.display = stickyDisplay)
})
})
}
let onEnd = () => {
Expand Down

0 comments on commit 31dc9e6

Please sign in to comment.