Don't animate expanding columns when restoring
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static classes = [ "collapsed" ]
|
||||
static classes = [ "collapsed", "noTransitions" ]
|
||||
static targets = [ "column", "button" ]
|
||||
|
||||
connect() {
|
||||
this.#disableTransitions()
|
||||
this.#restoreColumns()
|
||||
requestAnimationFrame(() => this.#enableTransitions())
|
||||
}
|
||||
|
||||
toggle({ target }) {
|
||||
@@ -19,6 +21,22 @@ export default class extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
#disableTransitions() {
|
||||
this.columnTargets.forEach(column => {
|
||||
if (this.noTransitionsClass) {
|
||||
column.classList.add(this.noTransitionsClass)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#enableTransitions() {
|
||||
this.columnTargets.forEach(column => {
|
||||
if (this.noTransitionsClass) {
|
||||
column.classList.remove(this.noTransitionsClass)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#toggleColumn(column) {
|
||||
this.#collapseAllExcept(column)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user