mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 22:42:32 -05:00
fix flash and morph
This commit is contained in:
1 parent
8723ce7f7a
commit
061580594c
5 files changed
+61
-6
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { actionable } from '@github/catalyst/lib/actionable'
|
||||
|
||||
export default actionable(class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
this.addEventListener('turbo:morph-element', this.onMorph)
|
||||
|
||||
this.show()
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
this.removeEventListener('turbo:morph-element', this.onMorph)
|
||||
|
||||
clearTimeout(this.closeTimeout)
|
||||
}
|
||||
|
||||
onMorph = (event) => {
|
||||
if (event.target !== this) return
|
||||
|
||||
this.show()
|
||||
}
|
||||
|
||||
show () {
|
||||
clearTimeout(this.closeTimeout)
|
||||
|
||||
this.hideAnimation?.cancel()
|
||||
|
||||
this.animate([
|
||||
{ transform: 'translateY(-100%)', opacity: 0 },
|
||||
{ transform: 'translateY(0)', opacity: 1 }
|
||||
], { duration: 200, easing: 'cubic-bezier(0.34, 1.56, 0.64, 1)' })
|
||||
|
||||
this.closeTimeout = setTimeout(this.close, 2000)
|
||||
}
|
||||
|
||||
close = (event) => {
|
||||
event?.preventDefault()
|
||||
|
||||
clearTimeout(this.closeTimeout)
|
||||
|
||||
this.hideAnimation = this.animate([
|
||||
{ transform: 'translateY(0)', opacity: 1 },
|
||||
{ transform: 'translateY(-100%)', opacity: 0 }
|
||||
], { duration: 150, easing: 'ease-in', fill: 'forwards' })
|
||||
|
||||
this.hideAnimation.onfinish = () => this.remove()
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user