@krisdages/aurelia-bootstrap
Version:
Bootstrap components written in Aurelia.
40 lines (32 loc) • 932 B
JavaScript
import {inject, bindable} from "aurelia-framework";
import velocity from "velocity-animate";
import {bootstrapOptions} from "../utils/bootstrap-options";
export class AubsCollapseCustomAttribute {
collapsed = false;
showClass;
constructor(element) {
this.element = element;
}
bind(){
this.showClass = bootstrapOptions.version === 4 ? 'show' : 'in';
}
attached() {
if (this.collapsed) {
this.element.style.display = 'none';
}
this.isAttached = true;
}
collapsedChanged() {
if (!this.isAttached) {
return;
}
if (this.collapsed) {
velocity(this.element, 'slideUp');
this.element.classList.remove(this.showClass);
} else {
this.element.classList.add(this.showClass);
velocity(this.element, 'slideDown');
}
}
}