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
|
|
|
|
2021-01-27 17:59:15 +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
|
|
|
|
2020-07-20 21:47:33 +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();
|
2020-07-23 02:28:25 +08:00
|
|
|
setTimeout(this.animationCheckmarkSetTrue, 200);
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2015-11-15 08:23:16 +08:00
|
|
|
this.animationCheckmarkSetTrue();
|
2020-07-23 02:28:25 +08:00
|
|
|
setTimeout(this.animationBoxSetTrue, 200);
|
2015-11-15 08:23:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|