snappymail/dev/Component/MaterialDesign/Checkbox.js

42 lines
999 B
JavaScript
Raw Normal View History

2015-11-15 08:23:16 +08:00
import ko from 'ko';
2019-07-05 03:19:24 +08:00
import { AbstractCheckbox } from 'Component/AbstractCheckbox';
2015-11-15 08:23:16 +08:00
export class CheckboxMaterialDesignComponent extends AbstractCheckbox {
2015-11-15 08:23:16 +08:00
/**
* @param {Object} params
*/
constructor(params) {
super(params);
2019-07-05 03:19:24 +08:00
this.animationBox = ko.observable(false).extend({ falseTimeout: 200 });
this.animationCheckmark = ko.observable(false).extend({ falseTimeout: 200 });
2015-11-15 08:23:16 +08:00
this.animationBoxSetTrue = this.animationBoxSetTrue.bind(this);
this.animationCheckmarkSetTrue = this.animationCheckmarkSetTrue.bind(this);
2015-11-15 08:23:16 +08:00
this.disposable.push(
this.value.subscribe((value) => {
this.triggerAnimation(value);
}, this)
);
}
animationBoxSetTrue() {
this.animationBox(true);
}
animationCheckmarkSetTrue() {
this.animationCheckmark(true);
}
triggerAnimation(box) {
if (box) {
this.animationBoxSetTrue();
setTimeout(this.animationCheckmarkSetTrue, 200);
2019-07-05 03:19:24 +08:00
} else {
2015-11-15 08:23:16 +08:00
this.animationCheckmarkSetTrue();
setTimeout(this.animationBoxSetTrue, 200);
2015-11-15 08:23:16 +08:00
}
}
}